-1

私は次のコードを持っていますが、オークションの目的でしばらくは完成していないと思いますが、私が見る限り、この段階では機能するはずです。しかし、私はしません。誰かが私の間違いを指摘できるかどうか疑問に思った. ブラウザによると、php スクリプトの else は予期しないものです。それを削除すると、ブラウザーは最後に終了 html タグを期待しなくなります。ご提案いただきありがとうございます。乾杯

<?php


$hostuser = $_GET['user'];

$auc = $_GET['auc'];


//Connect to database

$con = mysql_connect('localhost', 'root', 'password');
$db = mysql_select_db("users");



$auction = mysql_query("

SELECT * FROM auction WHERE host = '$hostuser'

");

$row = mysql_fetch_array ($auction);

$current_bid = $row['current_bid'];
$current_bid_user = $row['current_bid_user'];
$time_started = $row['time_started'];


if ($current_bid == 0) {

$current_bid = "No bids have yet been submitted.  Be the first to make a bid.";

}


include ('auction_1.php');

if ($bid > $current_bid) {

$current_bid = $bid;
$bidsubmitted = "";

{
else

$bidsubmitted = "Your bid must exceed the current bid";

}






 ?>

<html>

<form action = 'auction_1.php' method ='POST'>

<br>
Current bid: <?php echo $current_bid; ?>
<br>
<br>
Time Left:

<table>
            <br>
            <br>
            <tr>
            <td>
            Your bid:
            </td>
            <td>
            <input type = 'text' name = 'userbid'>
            </td>
            </tr>
</table>
<p>
<input type='submit' name='bid' value='Bid'>

<?php echo $bidsubmitted; ?>




</html>
4

3 に答える 3

2

あなたは中括弧を逃しました:

if ($bid > $current_bid) {
    $current_bid = $bid;
    $bidsubmitted = "";

} else {
    $bidsubmitted = "Your bid must exceed the current bid";
}

また、(そして非常に重要な)コードは安全ではありません。PDOまたはを使用MySQLiして、ユーザーデータをデータベースに挿入します。

$con = mysql_connect('localhost', 'root', 'password');
$db = mysql_select_db("users");

$auction = mysql_query("

SELECT * FROM auction WHERE host = '$hostuser' //This is bad.

");
于 2012-12-04T18:41:48.063 に答える
0

他の前に見逃し}たのは、このようになるはずです

if ($bid > $current_bid) {

$current_bid = $bid;
$bidsubmitted = "";

}
else{

$bidsubmitted = "Your bid must exceed the current bid";

}
于 2014-06-06T07:17:19.703 に答える
0

ブラケットを閉じなかっただけです

  } // instead of '{'
else{

$bidsubmitted = "Your bid must exceed the current bid";

}
于 2012-12-04T18:47:45.073 に答える