no database selected
#1
Posted 04 July 2006 - 05:09 PM
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
Posted 04 July 2006 - 05:40 PM
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
Posted 04 July 2006 - 08:02 PM
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
Posted 05 July 2006 - 04:21 AM
liveman, on Jul 5 2006, 02:01 AM, said:
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
Posted 05 July 2006 - 12:06 PM
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());
that is my code
#6
Posted 05 July 2006 - 12:32 PM
pukirocks, on Jul 5 2006, 01:05 PM, said:
mysql_select_db($database_somedatabase, $somedatabase) or die(mysql_error());
that is my code
That will not get you anywhere I am afraid.
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
Posted 05 July 2006 - 12:33 PM
$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
Edited by .Matt, 05 July 2006 - 12:36 PM.
#8
Posted 05 July 2006 - 12:55 PM
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
Posted 05 July 2006 - 01:00 PM
#10
Posted 05 July 2006 - 01:01 PM
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
Posted 05 July 2006 - 01:02 PM
#12
Posted 05 July 2006 - 01:06 PM
It should be like....
$host_somedatabase = "somethinghere";
#13
Posted 05 July 2006 - 02:18 PM
$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
Posted 05 July 2006 - 02:34 PM
$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
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
Posted 05 July 2006 - 03:27 PM
$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
Posted 05 July 2006 - 03:42 PM
?
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
Posted 05 July 2006 - 04:23 PM
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
Posted 05 July 2006 - 04:35 PM
$user_someuser = "database username"; $pass_somepassword = "your password";
Remember
Fill them in (by replacing in between the quotes) with your details.
#19
Posted 06 July 2006 - 12:04 AM
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
Posted 10 July 2006 - 01:58 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
