Having a problem with this error
Im getting this error.. Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\inc\class.core.php on line 34
if(mysql_num_rows(mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'")) == 1)
return TRUE;
el开发者_如何学运维se
return FALSE;
This
mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'")
is appareantly not returning a resource, but a boolean. The manual will tell you (i presume) that it returns false in case of an error.
So that query returned an error.... run it seperately instead of in one line for clearity. run it like this
mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'") or die("error")
Look up in the manual how to put the mysql error in that die()
.
mysql_query() is returning false. It means the SQL query returns no rows as result. You should modify your code to
$result = mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'");
if($result){
$number_rows = mysql_num_rows($result);
echo "The table has $number_rows columns with this name";
} else {
echo "No columns with this name";
}
精彩评论