首页 > 后端开发 > php教程 > 参数确实是true,但是还是有警告mysql_fetch_row() expects parameter 1 to be resource?

参数确实是true,但是还是有警告mysql_fetch_row() expects parameter 1 to be resource?

WBOY
发布: 2016-06-23 13:36:52
原创
1135 人浏览过

function checkCancelUserStop($phoneNum){	$con = mysql_connect("localhost", "root", "");	if(!$con)	{		echo "<script language=\"JavaScript\">			 alert('数据库连接失败!');  			 </script>";		echo "<script language='javascript' type='text/javascript'>";		echo "window.location.href='$url'";		echo "</script>";		return;	}		$result = mysql_select_db ("teleservice",$con);	if(!$result)	{		echo "<script language=\"JavaScript\">			 alert('选择数据库失败!');  			 </script>";		echo "<script language='javascript' type='text/javascript'>";		echo "window.location.href='$url'";		echo "</script>";		return;	}	$result = mysql_query("SET NAMES 'GBK'");	if(!$result)	{		echo "<script language=\"JavaScript\">			 alert('设置字符集失败!');  			 </script>";		echo "<script language='javascript' type='text/javascript'>";		echo "window.location.href='$url'";		echo "</script>";		return;	}	$query = "select state			  from phoneDetail			  where phoneDetail.phoneNum = $phoneNum";	if($result) 	{		echo "<script language=\"JavaScript\">			 alert('查询号码原状态成功!');  			 </script>";		echo "<script language='javascript' type='text/javascript'>";		echo "window.location.href='$url'";		echo "</script>";			} else {		echo "<script language=\"JavaScript\">			 alert('查询号码原状态失败!');  			 </script>";		echo "<script language='javascript' type='text/javascript'>";		echo "window.location.href='$url'";		echo "</script>";		return;	}	$oldState = "正常开通";	while($row = mysql_fetch_row($result))	{		echo "in while loop...";		$oldState = $row[0];		echo $oldState;	}	if($oldState == "主动停机") {		echo "yes";		return true;	} else {		echo "no";		return false;	}	mysql_close($con);}
登录后复制


问题:通过调试,已经可以成功查询到号码的原状态。此时$result = 1;但是后面fetch_row的时候,不能进入到while循环中,出现了警告:Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in H:\wamp\www\frr_cancelUserStop.php on line 58
请问:$result = 1确实是1(true)的啊,那为什么进不了循环?
怎么才能取得结果呢?
谢谢各位!


回复讨论(解决方案)

我知道怎么错了,少写了一句话。不好意思。

SQL 指令为执行

我也遇到了这种错误,能不能帮忙看下?
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in D:\WWW\blog\show_pub.php on line 7
代码:
error_reporting(E_ALL^E_NOTICE);
session_start();
include "conn/conn.php";
$pubsql = "select * from tb_public where id= ".$_GET['id'];
$pubrst = mysql_query($pubsql,$link);
$pubrow = mysql_fetch_row($pubrst);
echo "

".$pubrow[2]."
登录后复制
";
?>

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板