2016-07-16 41 views
0

不工作我有一個問題,我的代碼否則在PHP

$save = mysql_real_escape_string($_POST['save']); 
$query1 = "SELECT * from users WHERE user_id=".$_SESSION['user']; 
$result = mysql_query($query1); 

while($row = mysql_fetch_array($result)) { 
    // Get money from column 
    $money = $row['money']; 

    if($money >= $save) 

     $query1 = "UPDATE users SET savings = savings + $save, money = money - $save WHERE user_id=".$_SESSION['user']; 

     $update1 = mysqli_query($conn,$query1); // call 1st query 
     echo 'Money transferred successfully!!!'; 
    } else { 
     echo 'U NO MONEY IN CHECKING!!!!'; 
    } 
?> 

else語句不工作,我得到這個錯誤:

Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\wamp\www\bank.php on line 44

+0

'如果($錢> = $保存)'應該是'if($ money> = $ save){' –

+0

@TheCodesee它仍然不工作 –

回答

0

請看到你沒有打開一個括號{在if語句之後。

更改此:

if($money >= $save) 

要:

if($money >= $save) { 
+0

仍然不工作ng bro –

+0

您尚未關閉while循環大括號。請關閉它。 –

0

你缺少的if聲明開幕大括號:

if($money >= $save) { 
    // Here --------^