我有以下PHP:
<?php
$con = mysql_connect("localhost","foo","bar");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("zed", $con);
$getTagID = $_GET["id"];
//make a loop that outputs each coupon that has been tagged that
$alphaTagSQL = mysql_query("SELECT * FROM coupon_tags WHERE tagID = '$getTagID'");
$alphaTagSQLArr[] = mysql_fetch_array($alphaTagSQL);
foreach($alphaTagSQLArr as $mouse)
{
$nzed = $mouse["couponID"];
$brah = mysql_query("SELECT * FROM coupons WHERE couponID = '$nzed'");
$pen[] = mysql_fetch_row($brah);
}
foreach($pen as $ruler)
{
echo $pen;
}
?>
我想做的是从
$_GET
中选择tagID,然后将其与表couponID
中与之匹配的所有coupon_tags
匹配,然后将这些coupon_ID
匹配到表retailerName
中的coupons
,其中couponID
与字段id
匹配。然后,我只想按字母顺序列出它们。我只是遇到一些问题-即,出现错误Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource
。有什么帮助吗?
最佳答案
尝试改变
$brah = mysql_query("SELECT * FROM coupons WHERE couponID = '$nzed'");
进入
$brah = mysql_query("SELECT * FROM coupons WHERE couponID = '$nzed'") or die(mysql_error());
它将为您提供有关查询为什么失败的更多信息。