douganggu4392 2012-04-04 04:45
浏览 9
已采纳

mysql执行中的php错误

Ok I have this code:

//this is the hi.php//
<?php
//highlight items//
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("juliver", $con);

$result = mysql_query("SELECT * FROM hi WHERE pp='2'");

$hi = "";

while($row = mysql_fetch_array($result)) //<--- this is the line 13//
  {
  $hi .= "<div id='hicontainer'><a id='download_now' class='imgx' href='#?w=700' rel='popup'><img src='".$row['name']."' />";
  $hi .= "<p>".$row['title']."</p>";
  $hi .= "<a href='#?w=700' id='".$row['id']."' rel='popup' class='imgx'>View full</a>    </div>";
  }

//Lots of lots of code here I just specified those code which in error.//

mysql_close($con);

?>

and heres where im going to display the output actually.

<td>
<!--highlight items-->
<div id="tbtitle">
<img src="Images/galleryicon.png"/><p>Highlight items</p>
</div>
<div id="tblgal">
<? echo $hi; ?>
</div>
</td>

But i get an error saying: "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\madeinusa\hi.php on line 13."

please, im stuck with this. Thank you in advance.

  • 写回答

6条回答 默认 最新

  • douguanci9158 2012-04-04 04:50
    关注

    You probably have an error in your query "SELECT * FROM hi WHERE pp='2'"
    Try executing that query directly in mysql and see what happens. Make sure you have the table names and columns spelt right.

    Also, try quoting the table names and columns in backtick ` characters to avoid accidentally using MySQL reserved words.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用