When I try to execute the code, I get an error saying unexpected 'While'. Any idea on where I'm going wrong here? I'm attempting to only let a user bid if they aren't already the highest bidder. All was well until I tried adding in my if... else statement.
<?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());
}
}
?>