mysql - mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/domain/public_html/config.php on line 31 -


i know problem. have 2 hosting , b , 1 mysql base. on hosting site works same web page (i copy file b) on hosting b doesn't work perfectly. host, login , password date base ok because see news etc. when try login admin panel see:

warning: mysql_num_rows() expects parameter 1 resource, boolean given in /home/dmcmetal/domains/mydomain.com/public_html/config.php on line 31 

i add config.php file mysql_error(); , see:

 wrong in syntax obok '=='1' limit 1' w linii 1 

here part of config.php file:

function get_user_data($id=-1) { if($id==-1) {     $id=$_session['id']; } $result=  mysql_query("select * `users` `id`=='{$id}' limit 1"); if($result==false)     die(mysql_error()); if(mysql_num_rows($result)==0) { // 31 line     return false; } return mysql_fetch_assoc($result); 

}

can have idea why works on hosting , doesn't work on hosting b ?

there syntax error in query, using double equals when mysql syntax requires single one. causing error since there no number of rows. please change to

$result=  mysql_query("select * `users` `id` = '{$id}' limit 1"); 

then remember mysql_* functions deprecated advise switch mysqli or pdo


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -