Can't Select database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Can't Select database

Post by rfigley »

Can't seem to select teh database.

Here's the code I'm using. Have done this before without a problem until the phpMyAdmin was upgraded to 2.3.2 with MySQL 3.23.53a . Now when I try creating a new database I can't connect. The existing ones are working fine though. Just the new ones aren't working.

Code: Select all

$db = mysql_connect("localhost","user","password")
or die("Could not open connection to database");
echo "First Line of database connection works  <BR>";

mysql_select_db("database",$db)
or die("Unable to select the database.");


I keep getting:

"First Line of database connection works
Unable to select the database.

Any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try using mysql_error() for debugging, it generally gives fairly useful error messages:

Code: Select all

$db = mysql_connect("localhost","user","password") or die(mysql_error()); 

mysql_select_db("database",$db) or die(mysql_error());
Mac
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post by rfigley »

OK, it's giving me an "Access Denied" for my user name with this database.
Could it be something with teh permissions. Ive already tried those settings with no results so far
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

To check out your grants do:

Code: Select all

mysql> SHOW GRANTS FOR your_user@your_host;
from the MySQL command line.

Or in phpMyAdmin just go to the index page then click the users link and then the grants link next to your username. From here you can setup the privileges for that user.

http://www.mysql.com/doc/en/Privileges.html

Mac
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post by rfigley »

The grants shown are the same as those for the databases that I CAN access.
Post Reply