The error indicates that johndoe doesn't have permissions to any database. If he did, it should look like:
mysql> show grants for root@localhost; +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ > -----Original Message----- > From: Anthony Ritter [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 02, 2002 2:06 PM > To: Rick Emery > Subject: Rick... > > > Rick, > After typing in: > > mysql> SHOW GRANTS FOR johndoe@localhost; > > I get an ERROR 1064 > > Regards, > TR > .......................................... > > ----- Original Message ----- > From: Rick Emery <[EMAIL PROTECTED]> > To: 'Anthony Ritter' <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Tuesday, April 02, 2002 12:31 PM > Subject: RE: [PHP] Re: Connecting to a DB using PHP and mysql... > > > > at the mysql command line, type: > > mysql> show grants for johndoe@localhost; > > > > what does it show? > .................................. > > > > -----Original Message----- > > From: Anthony Ritter [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, April 02, 2002 1:08 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] Re: Connecting to a DB using PHP and mysql... > > > > > > Craig, > > I tried the following. > > > > I was able to connect to mysql but not to the database "contacts". > > > > TR > > ....................................................... > > > > <HTML> > > <BODY> > > <? > > define("DATABASE_HOST", "localhost"); > > define("DATABASE_USER", "johndoe"); > > define("DATABASE_PASSWORD", "abc"); > > define("DATABASE_NAME", "contacts"); > > > > $connection=mysql_connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD); > > if(!$connection) > > { > > echo "Couldn't connect."; > > exit; > > } > > $db=mysql_select_db(DATABASE_NAME,$connection); > > if(!$db) > > { > > echo "Couldn't connect to the database."; > > exit; > > } > > $sql="SELECT * FROM leads"; > > $mysql_result=mysql_query($sql, $connection); > > $num_rows=mysql_num_rows($mysql_result); > > > > if($num_rows==0) > > { > > echo "There is no information"; > > } > > else > > { > > echo"<TABLE ALIGN=\"Center\" BORDER=\"1\">"; > > echo"<TR><TH><FONT FACE =\"Arial\" SIZE=\"2\">First Name</TH><TH><FONT > FACE > > =\"Arial\" SIZE=\"2\">Last Name</TH><TH><FONT FACE =\"Arial\" > > SIZE=\"2\">email</TH><TH><FONT FACE =\"Arial\" SIZE=\"2\">State</TH>"; > > > > while($row=mysql_fetch_array($mysql_result)) > > { > > $fname=$row["fname"]; > > $lname=$row["lname"]; > > $email=$row["email"]; > > $state=$row["state"]; > > $ID=$row["ID"]; > > echo " <TR><TH><FONT FACE =\"Arial\" SIZE=\"2\">$fname</TH><TH><FONT FACE > > =\"Arial\" SIZE=\"2\">$lname</TH><TH><FONT FACE =\"Arial\" > > SIZE=\"2\">$email</TH><TH><FONT FACE =\"Arial\" > > SIZE=\"2\">$state</TH></TR>"; > > } > > } > > mysql_close($connection); > > ?> > > </BODY> > > </HTML> > > ........................................... > > > > Craig Donnelly wrote in message: > > Try this for your connection: > > ............................................ > > <? > > > > > > // Database constants > > > define("DATABASE_HOST", "localhost"); > > > define("DATABASE_USER", "root"); > > > define("DATABASE_PASSWORD", "*YOUR_PASS*"); > > > define("DATABASE_NAME", "*YOUR_DB_NAME*"); > > > > > > // Establish connection > > > $dbLink = mysql_connect(DATABASE_HOST, DATABASE_USER, > DATABASE_PASSWORD); > > > if(!$dbLink) { > > > print "Unable to connect to the database, please contact > Sysadmin > > > asap."; > > > } else { > > > $dbUse = mysql_select_db(DATABASE_NAME, $dbLink); > > > } > > > > > > ?> > > > > > > > -------------------------------------------------------------------------- > > -- > > > Hope it helps ya, > > > > > > Craig > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > --- > > [This E-mail scanned for viruses by IAS, an Archiventure Company] > > > > > > --- > [This E-mail scanned for viruses by IAS, an Archiventure Company] > --- > [This E-mail scanned for viruses by IAS, an Archiventure Company] > > --- [This E-mail scanned for viruses by IAS, an Archiventure Company] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php