faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 32 people (38%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

After connecting to MySQL using PHP, only MYSQL_QUERY() works. If I try to use MySQL_num_rows, I get a parse error. What am I doing wrong?

Feb 6th, 2002 20:37
Jason Huebel, Henrik Hansen, Sri Vathsa, Nathan Wallace,


This problem is likely due to an improperly written SELECT statement 
in the mysql_query statement.  To get more useful error reporting from 
your mysql_query statements, use the following syntax:
$query = "SELECT * from some_table";
$result = mysql_query($query) or die("Invalid query:" .mysql_error());
$numresult = mysql_num_rows($result);
You will likely find that the problem is in the $query you created.  
For instance, if some_table doesn't exist within the database you are 
connected to, mysql_num_rows will fail unless you catch the mysql 
error with the die() statement shown above.