Home > Backend Development > PHP Tutorial > 参数确实是true,但是仍是有警告mysql_fetch_row() expects parameter 1 to be resource

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

WBOY
Release: 2016-06-13 12:17:55
Original
2194 people have browsed it

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

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


问题:通过调试,已经可以成功查询到号码的原状态。此时$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 指令为执行

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template