gxzsd gxzsd -4 years ago 131
MySQL Question

Warning: mysql_result(): Unable to jump to row 0 on MySQL

I want to select an id from a table using the query:

$demo_id = mysql_result(mysql_query("SELECT id FROM demo_tbl WHERE a_val='a' and b_val='b' LIMIT 1"),0);


This query works perfectly if it satisfies the condition. But if there is no such record then the above mentioned error shows. I dont want to use mysql_num_rows(). Is there any way to find whether $demo_id has value or not.

Answer Source
if(!$demo_id){
//no return
}else{
//demo_id has value
}

base on the manual:

http://php.net/manual/en/function.mysql-result.php

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download