当我尝试执行代码时,我收到一条错误,说出意外的'而'。我知道我在哪里出错吗?我试图只让用户出价,如果他们不是最高出价者。一切顺利,直到我尝试添加我的if ... else语句。
<?php
session_start();
require_once("dbconnect.inc");
$accountid=$_SESSION['accountid'];
$itemid=$_POST['itemid'];
mysql_query("SELECT accountid FROM bidhistory
WHERE biditem = '$itemid' ORDER BY bidhistoryid DESC");
$result=mysql_query($sql)
while($row = mysql_fetch_array($result)){
$checkaccountid = $row['accountid'];
if($checkaccountid == $accountid){
echo "You are the highest bidder!";
}
else {
$sql="INSERT INTO bidhistory (accountid, biditemid)
VALUES ($accountid, $itemid)";
mysql_query("
UPDATE bidhistory
SET bidprice = bidprice + 1
WHERE biditemid = " .
@mysql_escape_string($itemid));
$result=mysql_query($sql) or die("Error in adding bid for item: ".mysql_error());
}
}
?>
答案 0 :(得分:0)
需要添加分号
$result=mysql_query($sql)
所以...
$result=mysql_query($sql);