php警告为什么?无法解决 [英] php warning why ? unable to solve it

查看:40
本文介绍了php警告为什么?无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一条警告消息,我不明白为什么并且无法解决,(见下文)

I am getting a warning message which I don't understand why and unable to resolve, (see below)

Warning: Supplied argument is not a valid MySQL result resource in /detail.php on line 34

这是我的代码:

$rs = mysql_query($strSQL);
 $strSQL = "SELECT * FROM <tablename> WHERE id=" . $_GET["serviceName"];
 // Loop the recordset $rs
  while($row = mysql_fetch_array($rs))   **(line 34) here ***
{
 echo $row['ID']."<br />";
       echo $row['serviceName']."<br />";
     // Close the database connection
mysql_close();
?>

</dl>
<p><a href="li.php">Return to the list</a></p>
  </body>

</html>

提前谢谢,我也没有得到这个网页上的任何数据,谢谢...singhy

thanks in advance, I am not getting any of the data on this webpage either,thanks...singhy

推荐答案

查询失败 - 您需要在 MySQL 中用引号将字符串括起来:

The query is failing - you need to wrap quotes around strings in MySQL:

$strSQL = "SELECT * FROM gu_service_cat WHERE id = '" .$_GET["serviceName"] ."'";

$strSQL = "SELECT * FROM gu_service_cat WHERE id = '" . $_GET["serviceName"] . "'";

另外,$rs 应该低于 $strSQL...

plus, the $rs should be BELOW the $strSQL...

这篇关于php警告为什么?无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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