MySql PHP No Database Selected

Started by G_G, March 11, 2011, 07:26:26 pm

Previous topic - Next topic

G_G

I dunno why but I'm getting the mysql_error "No Database selected." However here is my code.
$host = "localhost";
$user = "---";
$pass = "---";
$db = "---";
$connection = mysql_connect($host, $user, $pass);
$database = mysql_select_db($db);
$query = "SELECT * FROM users;";
$result = mysql_query($query);


For obvious reasons, I blocked out the user, pass, and database. Now obviously I'm connecting. I'm not getting any errors from connecting, or from the database selection. Any ideas?

Blizzard

Instead of mysql_select_db, try just running the query "USE your_database_name_here;".
Also, have you made sure that this user has access to that database?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

*facepalm* I didn't give database access to the user. Fail. Thanks Blizz!