在进行相当常规的查询时,我突然收到以下错误:
Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource
这是我的代码:
$query = "SELECT * FROM ImageGalleryPhotos ORDER BY ImageOrder";
$result = mysql_query($query);
/* create one master array of the records */
$imagesArray = array();
// here is the line where I'm getting the error I listed up top:
if(mysql_num_rows($result)) {
while($image = mysql_fetch_assoc($result)) {
$imagesArray[] = array('image'=>$image);
}
}
echo json_encode($imagesArray);
// And here I'm getting error # 2 (see below):
mysql_free_result($result);
?>
错误 #2 是:<b>Warning</b>: mysql_free_result(): supplied argument is not a valid MySQL result resource
奇怪的是,当我在没有“ORDER BY”业务的情况下进行搜索时,一切正常,如下所示:
$query = "SELECT * FROM ImageGalleryPhotos";