我的查询有什么问题?
$check_select = mysql_num_rows(mysql_query("SELECT * FROM `user` WHERE user_id = '$user_fbid'"));
if($check_select > 0){
mysql_query("INSERT INTO `user` (user_id, name, photo) VALUES ('$user_fbid', '$user_fnmae', '$user_image')");
}
它回来了
mysql_num_rows()期望参数1是资源,在中给出布尔值
答案 0 :(得分:2)
$row = mysql_query("SELECT * FROM user WHERE user_id = '{$user_fbid}'");
$check_select = mysql_fetch_array($row);
if($check_select > 0){
mysql_query("INSERT INTO user (user_id, name, photo) VALUES ('{$user_fbid}', '{$user_fnmae}', '{$user_image}')");
}
AND使用mysql停止工作! 使用mysqli或pdo
答案 1 :(得分:1)
尝试使用以下
$check_select = mysql_num_rows(mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE user_id = '$user_fbid'")));
if($check_select > 0){
mysql_query("INSERT INTO `user` (user_id, name, photo) VALUES ('$user_fbid', '$user_fnmae', '$user_image')");
}