PHP 警告:mysql_num_rows() 期望参数 1 是资源,布尔值在第 57 行的/home/website/public_html/facebook/fbclogin.php 中给出 [英] PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/website/public_html/facebook/fbclogin.php on line 57

查看:66
本文介绍了PHP 警告:mysql_num_rows() 期望参数 1 是资源,布尔值在第 57 行的/home/website/public_html/facebook/fbclogin.php 中给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
mysql_fetch_array() 需要参数 1是资源,选择中给出的布尔值
警告:mysql_fetch_* 期望参数 1 为是资源,布尔值错误

警告:mysql_num_rows() 期望参数 1 是资源,布尔值在第 57 行的/home/website/public_html/facebook/fbclogin.php 中给出

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/website/public_html/facebook/fbclogin.php on line 57

这是一行:

if (mysql_num_rows($rs)) $u = mysql_fetch_array($rs); else $u="";

这就是它的周围:

// with the user id from facebook retrived with the API,
// search for a user already registered with this process:
$rs = mysql_query( "select * from users where fb_userid='$fb_user'" );

if (mysql_num_rows($rs)) $u = mysql_fetch_array($rs); else $u="";

if (is_array($u)) {

为什么我会收到这个错误,我应该怎么做才能阻止它发生?

Why am I getting this error and what should I do to stop it from happening?

提前致谢.

推荐答案

这意味着 MySQL 查询没有正确执行.您可以使用它来找出问题所在:

This means the MySQL query did not execute correctly. You can use this to figure out what went wrong:

$rs = mysql_query( "select * from users where fb_userid='$fb_user'" ) 
or die(mysql_error());

尽管在这种情况下,问题似乎是您没有将表名和列名括在所需的 ` 标记内,所以请尝试

although in this case it seems the problem is that you have not enclosed table and column names within the required ` marks, so try

$rs = mysql_query( "select * from `users` where `fb_userid`='$fb_user'" ) 
or die(mysql_error());

这篇关于PHP 警告:mysql_num_rows() 期望参数 1 是资源,布尔值在第 57 行的/home/website/public_html/facebook/fbclogin.php 中给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆