我正在尝试运行此功能,但无法使其工作,我做错了什么(输出说我的fetch数组arg无效)?
$link = mysql_connect('localhost', 'over_app', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$result = mysql_query("SELECT Pic.PicID FROM Pics.Pic Pic LEFT JOIN SeenPics.Seen Seen ON Pic.PicID = Seen.PicID");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while($row = mysql_fetch_array($result)) { echo "Your Pic ID: $row['PicID']"; }
注意 Pic
表位于Pics
数据库中,Seen
表位于SeenPics
数据库
答案 0 :(得分:0)
mysql_query
返回布尔值false
,查询失败..执行此操作
$result = mysql_query("SELECT Pic.PicID FROM Pic LEFT JOIN Seen ON Pic.PicID = Seen.PicID");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while($row = mysql_fetch_array($result)) {
echo "Your Pic ID: $row['PicID']";
}
mysql_*
See this comment 现在我们已经掌握了完整的事实 - 即您尝试跨多个数据库进行连接...问题是您的查询不完整...试试这个:
SELECT Pic.PicID FROM Pics.Pic Pic LEFT JOIN SeenPics.Seen Seen ON Pic.PicID = Seen.PicID