<分区>
编辑请看下方
大家好。我的错误是在我的 while 循环中。我不得不在其中添加一个 @ 以使其停止向我发出警告。它工作得很好。一切都完美更新。但是,与其拼凑它,我真的不想隐藏我的错误。
我只是不知道它有什么问题。就像我说的,我的 while 循环(第 113 行)给了我这个:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xx/xxxxxxx/xxx/admin/price_chng.php on line 113
这是代码。
if($manu < 15){
$row_count = 0;
$query = "SELECT * FROM `phone_models` WHERE `manufacture_id`=" . $manu . ";";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
if($row_count < 5){
echo ("<form action='price_chng.php' method='post' name='newprice' id=" . $row['id'] . ">");
echo "<td>" . $row['label'] . "<br>";
echo("<input name='newprice' type='text' id=" . $row['id'] . " size='10' value=" . $row['buyback_price'] . "><br>");
echo("<input type='hidden' name='ud_id' value='$row[id]'>");
echo("<input name='doSave' type='submit' id='doSave' value='Save'></form></td>");
$row_count++;
}else{
$row_count = 0;
echo("</tr><tr>");
}
}
}else{
echo("</tr></td>");
}
感谢任何帮助!谢谢,伙计们!
编辑:更新了代码。我从声明中删除了 or die ,因为我希望警告停止。我忘了把它放回去。当我把它放回去时,我有这个错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
而且,我的代码是:
if($manu < 15){
$row_count = 0;
$query = "SELECT * FROM `phone_models` WHERE `manufacture_id`=" . $manu . ";";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
if($row_count < 5){
echo ("<form action='price_chng.php' method='post' name='newprice' id=" . $row['id'] . ">");
echo "<td>" . $row['label'] . "<br>";
echo("<input name='newprice' type='text' id=" . $row['id'] . " size='10' value=" . $row['buyback_price'] . "><br>");
echo("<input type='hidden' name='ud_id' value='$row[id]'>");
echo("<input name='doSave' type='submit' id='doSave' value='Save'></form></td>");
$row_count++;
}else{
$row_count = 0;
echo("</tr><tr>");
}
}
}
else{
echo("</tr></td>");
}