我一直收到“没有收到数据”错误,我知道谷歌Chrome浏览器很常见,所以我尝试在IE浏览器中遇到连接问题错误。这是我的脚本,我真的看不出是什么导致了这个错误。
$getAlName = mysql_query("SELECT * FROM categories WHERE id=" . $cat);
$alName = mysql_feth_assoc($getAlName);
$images = mysql_query("SELECT * FROM images WHERE category=" . $alName['name']);
while($imgs = mysql_fetch_object($images)) {
$url = $imgs->url;
$id = $imgs->id;
echo ("<img src='" . $url . "'></img>\n");
}
答案 0 :(得分:1)
您需要在字符串周围添加单引号:
"SELECT * FROM images WHERE category = '" . $alName['name']) . "'";
...而且你也输了一个拼写错误,使用mysql_fetch_assoc
代替mysql_feth_assoc($getAlName);
答案 1 :(得分:1)
//Make a subquery and you'll thank yourself later:
$q = "SELECT URL, ID FROM images WHERE category IN ".
"( SELECT * FROM categories WHERE id=" . $cat . ")";
echo $q; // just to test. no data received probably has to do with no output to
// the browser. This will output to the browser.
$images = mysql_query($q);
// this is the same.
while($imgs = mysql_fetch_object($images)) {
$url = $imgs->url;
$id = $imgs->id;
echo ("<img src='" . $url . "'></img>\n");
}