我有一個需要修復的個人項目。下面的代碼應該從工作人員帳戶中提取一筆金額(借記帳戶),但它會返回空白並顯示錯誤。請根據具體情況,提供錯誤或遺漏步驟的幫助。我很新的PHP
這裏是我的代碼php退出代碼不起作用
// connect db
<?php
$username="root";
$server="localhost";
$dbname="workers_db";
$password="worded";
$conn=mysql_connect($server,$username,$password);
mysql_select_db($dbname) or die ("SERVER ERROR".mysql_error());
?>
// check
<?php
if(isset($_GET['withdraw']))
{
$Req="SELECT * FROM balance";
$query=mysql_query($Req);
$nums=mysql_fetch_assoc($query);
//echo $nums['CurrentB'];
$amount=$_GET['amount'];
$newB= ceil($nums['CurrentB']- $amount);
///////////////
if($newB>5000)
{
$amount=$_GET['amount'];
$withdrawal="UPDATE balance SET CurrentB=$newB,LastWithdraw=$amount,date=now() WHERE b_id=1; ";
$query2=mysql_query($withdrawal);
//$nums=mysql_fetch_assoc($query2);
if($query2)
{
$Req="SELECT * FROM balance";
$query=mysql_query($Req);
$nums=mysql_fetch_assoc($query);
echo "Your new current account balance is". ' '.$nums['CurrentB'];
echo "<br/>Your Last Withdrawal was ". ' '.$nums['LastWithdraw'];
echo "<br/>Your Last Withdrawal Date was on". ' '.$nums['date'];
}
}
else
{
echo 'INSUFFICIENT BALANCE TO CONTINUE THIS TRANSACTION';
}
///////////////
}
else
{
$Req="SELECT * FROM balance";
$query=mysql_query($Req);
$nums=mysql_fetch_assoc($query);
echo "Your current account balance is". ' '.$nums['CurrentB'];
}
?>
<?php
if(!isset($_GET['withdraw']))
{
?>
//the form
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="GET" enctype="multipart/form-data">
Amount to Withdraw:  <input type="text" name="amount">
<input type="Submit" name="withdraw" value="Proceed">
</form>
<?php
}
?>
//end
<br/><a href="index.php">EXIT</a>
顯示的錯誤是什麼? –
這是顯示「不足的餘額繼續此交易」。預計會顯示賬戶= <5000. – Alama
@Alex的內容包括b_id,CurrentB,Withdraw,日期 – Alama