Php and MySQL

software development


i’ve got to newbi questions:

  1. I was just trying to connect to a MySql database with php, all the coding is correct to my knowledge(copied it from a tutorial) changing the required codes. But i always keep getting an error ‘Unable to locate the members database at this time.’ (its a custome error message, see below)

Heres what i did

Our List of Jokes <?php $host = ""; $username = "xxdaggerxx"; $password = "computer";

$dbcnx = @mysql_connect($host, $username, $password);
if (!$dbcnx) {
echo( “

Unable to connect to the database server at this time.

” );
if (! @mysql_select_db(“members”) ) {
echo( “

Unable to locate the members database at this time.

” );

We shld have connected

  1. TO make things worst, as i was workin with this script and when i logged into MySQL through the Telnet (which i did perfactly before) i could’nt run any commands! I was able to login with my password and username but once im in i get this error message ‘ERROR 1044: Access denied…’ when running any commands. But only the SHOW DATABASES command worked, commands involving tables never worked… more intrestingly the php my admin thing works. I was able do this with out any troubles before.

please helP!


It sounds like the database “members” is not running. Are you sure this has been started?

The easiest way to make sure (easier than telnet) is to use phpmyadmin. The nice folks at Dreamhost have preloaded this on all sites. At the admin panel click on “Goodies” then “mysql” then click on the name of your database, which should be “”. After phpmyadmin opens up, on the left side, under the bold word “home” should be the database members, with all of its tables listed underneath.

I’m not sure how you are setting all this up, but “members” sounds more like a table than a database to me.

ps. using mysql_pconnect in place of mysql_connect may save you some conqueries.



hi jeff i tried what you told me and yes, ‘members’ is a Table and its running on phpmyadmin just fine. But i cant use telnet or any script. I changed the coding for my script to the following:

<?php $usr = "xxdaggerxx"; $pwd = "XXXXXX"; $db = "members"; $host = ""; $cid = mysql_pconnect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } $sql = 'SELECT count( * ) FROM members'; $result = mysql_db_query($db,$sql,$cid); if (!$result) { echo("ERROR: " . mysql_error() . "\n"); } echo ("result is $result"); ?>

It should have just connected to and send queries to the ‘members’ table, But i keep getting this error:
ERROR: Access denied for user: ‘’ to database 'members’
Did the same using telnet and get the same error.
Did i configure mysql database wrongly?



From what you are saying, both your database, and the table you are interested in are named “members” If this is true, it should work.

Also, remember that capitalization matters. I had that problem once.

Is phpmyadmin working okay? From there you can clearly see the database name, and the table names. On the phpmyadmin screen, the first name, in bold is the database name, all the names underneath are the tables in that database. I personally would find it confusing to name a table the same as a database.



The database’s name is ‘Suffication_Members’ and the table’s name is ‘members’. Phpmyadmin works fully, im able to connect from there only but cant from my scripts…
hold on! i’ve been connecting through the wrong database!! im suppose to connect to ‘Suffication_Members’! not members. :smiley:
sry if i have caused u any trouble :smiley:
(i have realise this when i was typing this message :D)