Php 这个错误有问题吗

Php 这个错误有问题吗,php,mysql,Php,Mysql,我收到了这个错误。。 警告:mysql_num_rows()希望参数1是资源,布尔值在第34行的C:\xampp\htdocs\inc\class.core.php中给出 if(mysql_num_rows(mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'")) == 1) return TRUE; else return FALSE; 这个 显然不是返回一个资源,而是一个布尔值。手册会告诉你(我想)如果出

我收到了这个错误。。 警告:mysql_num_rows()希望参数1是资源,布尔值在第34行的C:\xampp\htdocs\inc\class.core.php中给出

if(mysql_num_rows(mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'")) == 1)
    return TRUE;
else
    return FALSE;
这个

显然不是返回一个资源,而是一个布尔值。手册会告诉你(我想)如果出现错误,它会返回false

所以那个查询返回了一个错误。。。。为了清晰起见,将其分开运行,而不是一行运行。像这样运行

mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$column."'") or die("error")
在手册中查找如何将mysql错误放入
die()

mysql\u query()返回false。这意味着SQL查询不会返回任何行作为结果。您应该将代码修改为

$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";
}

@johncode的可能重复:这个问题本身被标记为重复——应该被标记为不重复的问题的重复。
$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";
}