Jump to content


no database selected


19 replies to this topic

#1 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 04 July 2006 - 05:09 PM

hi everybody, long time no see, but this site's still the best.
i have a problem a login webpage i've made with the login feature in DW, it works in localhost perfectly but on line i get this error
"No Database Selected" please help
thanks

#2 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 04 July 2006 - 05:40 PM

Hi,

This means one of two things basically, in your connection settings you have failed to specify a table you are using

or..

You have not create the table. Its unlikely to be the second as you say the message is no database selected which is the wrong error for this, and unlikely to be the 1st as you say it works fine on localhost.

So check the connection settings, and the mysql table.

I believe there are also some pretty damn complicated reasons why this error can arise but im sure its one of the 2 i have mentioned.

Edited by .Matt, 04 July 2006 - 05:42 PM.


#3 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 04 July 2006 - 08:02 PM

make sure where you connect it looks something like

 mysql_connect(host,user,pass) or die(mysql_error());
 mysql_select_db(database) or die(mysql_error()); // THAT LINE IS WHY THE ERROR IS THERE!
What it is saying is that it is trying to access a query but dosn't know what database to connect to!

#4 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 04:21 AM

View Postliveman, on Jul 5 2006, 02:01 AM, said:

make sure where you connect it looks something like

 mysql_connect(host,user,pass) or die(mysql_error());
 mysql_select_db(database) or die(mysql_error()); // THAT LINE IS WHY THE ERROR IS THERE!
What it is saying is that it is trying to access a query but dosn't know what database to connect to!

I should hope no ones connections look like that lol :)

Achualy i assumed since it worked fine on localhost that this was in place correctly.

#5 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 12:06 PM

mysql_connect($host_somehost,$user_someuser,$pass_somepassword) or die(mysql_error());
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

that is my code

#6 Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 05 July 2006 - 12:32 PM

View Postpukirocks, on Jul 5 2006, 01:05 PM, said:

mysql_connect($host_somehost,$user_someuser,$pass_somepassword) or die(mysql_error());
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

that is my code

That will not get you anywhere I am afraid. :D

What other user's have posted should of fixed the problem:

mysql_connect ( 'localhost', 'user', 'password' ) or die(mysql_error());
mysql_select_db ( 'database' ) or die(mysql_error());

In your code, $somedatabase is not defined. ;)

#7 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 12:33 PM

aha, ok you are using the handles...

$somedatabase = mysql_connect($host_somehost, $user_someuser, $pass_somepassword) or die(mysql_error());
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

Either use that or remove the second variable from mysql_select_db

edit: ahah Choas King, same time post ;) -What pukirocks posted is not wrong as such, just forgot to finish it off lol.

Edited by .Matt, 05 July 2006 - 12:36 PM.


#8 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 12:55 PM

thanks!!!!!! i'm a newb so please be patient, LOL
i wrote this and get rid of "no DB selected but get this error:
"Warning: mysql_connect(): Can't connect to MySQL server on 'localhost' (10061) in"
when i try to use my login php

$somedatabase = mysql_connect($host_somedatabase, $user_someuser, $pass_somepassword) or die(mysql_error());
  mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());


#9 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 01:00 PM

i thinks is a problem with my histing service but i'm not sure

#10 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 01:01 PM

OK, what do you have set as $host_somedatabase? It should be something like localhost or 127.0.0.1 unless specified by your host.

and also does the server you are working on run mySQL?

edit: yes as your post before says, it may be your host. Its more than likely. Posted at the same time ;)

Edited by .Matt, 05 July 2006 - 01:03 PM.


#11 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 01:02 PM

all in line 19 that is the line where $somedatabase = mysql_connect($host_somedatabase, $user_someuser, $pass_somepassword) or die(mysql_error()); in placed

#12 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 01:06 PM

no i mean what is the variable $host_somedatabase set as?

It should be like....

$host_somedatabase = "somethinghere";


#13 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 02:18 PM

hi!! in

$host_somedatabase = "somethinghere";

i got nothing in "somethinghere" as a matter of fact i got no "somethinghere", and also as a matter of fact o don't know were to put it i think it is in
$somedatabase = mysql_connect($host_somedatabase, $user_someuser, $pass_somepassword) or die(mysql_error());
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

and bo something like
$somedatabase = mysql_connect($host_somedatabase, = somethinghere$user_someuser, $pass_somepassword) or die(mysql_error());
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

or be just in the line before something like

$host_somedatabase = "somethinghere";

you can tell i'm helpless so thanks in advance

#14 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 02:34 PM

ahh OK. I thought you were a little more advanced sorry :D

$host_somedatabase = "localhost"; // Leave this intact.

// Change the following
$user_someuser = "database username"; 
$pass_somepassword = "your password";
$database_somedatabase = "DB name";

$somedatabase = mysql_connect($host_somedatabase, $user_someuser, $pass_somepassword) or die(mysql_error());

mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

There are better ways using define and arrays but this will do you :D

ps. Your doing fine as for a begginer, already having mysql_error() on your connection/queries is very rare lol. You wouldn't believe the amount of people that don't do it when they start off.

Edited by .Matt, 05 July 2006 - 02:36 PM.


#15 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 03:27 PM

i got this

$host_somedatabase = "this was probided by my hosting service"; // Leave this intact.

// Change the following
$user_someuser = "database username";
$pass_somepassword = "your password";
$database_somedatabase = "DB name";

$somedatabase = mysql_connect($host_somedatabase, $user_someuser, $pass_somepassword) or die(mysql_error());

mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());

and then got this

"Access denied for user: 'someuser@some#' to database 'somedatabase'"

i thinks this is an issue of my hosting service but i really don't know

p.d. i hope someday i'll maybe answer your questions and give the site something back

#16 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 03:42 PM

"this was probided by my hosting service"

?

Well, if you have crated the database, i suspect your problem is you have create the user/added it to the database.

Check out this video tutorial. I will show you better than i can in words.

http://www.speed-hos...ls/x2/mysql.htm

#17 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 05 July 2006 - 04:23 PM

hi!!! i got rid of "Access denied for user: 'someuser@some#' to database 'somedatabase"

and got "Warning: mysql_connect(): Access denied for user: 'ODBC@some#' (Using password: NO) in \\some#\somedirectory\someurl on line 27

line 27 is

$somedatabase = mysql_connect($host_somehost, $user_someuser, $pass_somepass) or die(mysql_error());


#18 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 July 2006 - 04:35 PM

Ok, that means you havent provided a username or password :D

$user_someuser = "database username";
$pass_somepassword = "your password";

Remember :D

Fill them in (by replacing in between the quotes) with your details.

#19 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 06 July 2006 - 12:04 AM

all these posts are getting nowhere fast...

first make sure mysql is supported by your host, if they don't, thats the problem. if they do, create a database.

run this code, it's straitforward.
<?
mysql_connect("localhost", "username", "password") or die( mysql_error() );
mysql_select_db("db_name") or die( mysql_error() );
?>

find the type of server your host is running for mysql (usually localhost). then find your username and password for you mysql access. (replace the text in mysql_connect() with your actual username & password).

then get the name of the database you created and replace the text in mysql_select_db() with the real database name....

by the way if you have cpanel then the username/password is usually the same as your cpanel login info.

Edited by coolaid, 06 July 2006 - 12:06 AM.


#20 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 10 July 2006 - 01:58 PM

i got it!!!! thanks everybody!!!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users