在写php时用到这样一个问题,代码如下:
$sql="select * from sina";
mysql_connect("localhost","root","root");
mysql_select_db("message");
$temp=mysql_query($sql);
while($row=mysql_fetch_row($temp)){
echo $row[1];
}
其中这一段语句一直出错$row=mysql_fetch_row($temp),我百度了半天才找到答案,因为当$row=mysql_fetch_row($temp)的结果为空时会出错,需要在$row前面加上一个@才行——@$row=mysql_fetch_row($temp)。这样就不会出错了。