Why i have this error and how to fix this, I've double checked everything and all is okay
: mysql_num_rows(): supplied argument is not a valid MySQL result resource in on line :mysql_num_rows():第行上提供的参数不是有效的MySQL结果资源
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like WHERE postID='81' AND userIP='2x2.2x0.x5.xxx'' at line 1
Here is sql
$ip_sql = mysql_query("SELECT userIP FROM like WHERE postID='$id' AND userIP='$ip'");
$count = mysql_num_rows($ip_sql) or die(mysql_error());
if($count==0)
{...
LIKE
是保留字-请将其转义
$ip_sql = mysql_query("SELECT userIP FROM `like` WHERE postID='$id' AND userIP='$ip'");
LIKE
是SQL中的关键字,使用´
SELECT userIP FROM `like` WHERE postID='$id' AND userIP='$ip
Try connecting first. Are you looking for the null case? If so you have to search a certain row not $count as a whole.
$conn = mysql_connect("localhost", "user", "pass");
$ip_sql = mysql_query("SELECT userIP FROM like WHERE postID='$id' AND userIP='$ip'",$conn);
$count = mysql_num_rows($ip_sql) or die(mysql_error());
if ($count['postID'}==""){
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.