RE: [PHP-DB] Problems with queries

From: Date: Thu, 10 Aug 2000 19:37:30 +0000
Subject: RE: [PHP-DB] Problems with queries
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1942@lists.php.net to get a copy of this message
> $db = > mysql_connect("isocor.cem.itesm.mx:3306","root","xxxxxxx"); > mysql_select_db("otra",$db); > $result = mysql_query("SELECT * FROM usuarios;",$db); > printf("First Name: %d<br>\n", mysql_result($result,0,"id")); Suggestion #1: Whenever you're posting code...NEVER put real server information (especially root password for MySQL). I would suggest changing that IMMEDIATELY. Not everyone on this list is your friend (I blanked it out for this posting but the damage has already been done). Plus now if you have the MySQL daemon running as ROOT user you now have a real potential security risk if you're using a 3.22.x so you may want to change your system user passwords and check the log files as well. :) > Warning: Supplied argument is not a valid MySQL result resource in > /export/home2/homepage/docs/otra.php4 on > line 8 Suggestion #2: This is usually a sign either your mysql_connect or mysql_query failed. Add echo mysql_error($db) underneath each line that connects to MySQL ex. $db = mysql_connect("isocor.cem.itesm.mx:3306","root","xxxxxxx"); echo mysql_error($db); mysql_select_db("otra",$db); echo mysql_error($db); $result = mysql_query("SELECT * FROM usuarios;",$db); echo mysql_error($db); printf("First Name: %d<br>\n", mysql_result($result,0,"id")); echo mysql_error($db); This should then tell you where you messed up...my guess is the fact in your MySQL_query line you have a ; ...which isn't necessary and probably breaking the script (removing that will probably solve your problem but using mysql_error is a good troubleshooting practise anyways). Sincerely, Craig Vincent ------------------------- Senior Programmer Jazzmonkey Media Inc. http://www.jazzmonkey.com ------------------------- > -----Original Message----- > From: Glenn Miller [mailto:gmiller@campus.cem.itesm.mx] > Sent: Thursday, August 10, 2000 3:21 PM > To: php-db@lists.php.net > Subject: [PHP-DB] Problems with queries > > > Hello > > First Name: 0 > > I'm sure the connection functions, but cannot make any queries... > > Any ideas will be appreciated... > >

« previous php.db (#1942) next »