2013-10-07 157 views
-1

請幫我解決這個錯誤。請看看我的代碼..PHP解析代碼錯誤

的錯誤是:

"Parse error: syntax error, unexpected '=' in\\...delete_user.php on line 21" 

線21具有這樣的:

if ($_SERVER['REQUEST_METHOD'] = = 'POST') { 

請幫助。我不知道如何檢查語法,因爲我是新來的PHP代碼..

感謝, 簡


<?php # Script 1.7 delete_user.php 

$page_title = 'Delete a User'; 
//include ('includes/header.html');// 
echo '<h1>Delete a User</h1>'; 

// Check for a valid user ID value:// 
if ((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = $_GET['id']; 
} elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = $_POST['id']; 
    } else { echo '<p class="error">This page has been accessed in error.</p>'; 
     //include ('includes/footer.html');// 
    exit(); 

} 


require_once ('../mysqli_connect.php'); 



if ($_SERVER['REQUEST_METHOD'] = = 'POST') { 


if ($_POST['sure'] = = 'Yes') { $q = "DELETE FROM users10 WHERE user_id=$id LIMIT 1";   
$r = @mysqli_query($dbc, $q); 




if (mysqli_affected_rows($dbc) = = 1) { echo '<p>The user has been deleted.</p>'; 
} else { echo '<p class="error">The user could not be deleted due to a system error. 
</p>'; 
     echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; 
} 

} else { echo '<p>The user has NOT been deleted.</p>'; 

} 

} else { 


$q = "SELECT CONCAT(last_name, ',', first_name) FROM users10 WHERE user_id=$id"; 
$r = @mysqli_query($dbc, $q); if (mysqli_num_rows($r) = = 1) { $row =  
mysqli_fetch_array($r, MYSQLI_NUM); 


echo "<h3>Name: $row[0]</h3> Are you sure you want to delete this user?"; 



    echo '<form action="delete_user.php" method="post"> 
    <input type="radio" name="sure" value="Yes" /> Yes 
    <input type="radio" name="sure" value="No" checked="checked" /> No 
    <input type="submit" name="submit" value="Submit" /> 
    <input type="hidden" name="id" value="' . $id . '" /> 
    </form>'; 

    } else { echo '<p class="error">This page has been accessed in error.</p>'; } 

    } 
    mysqli_close($dbc); 


    ?> 

+0

[參考? - 這是什麼錯誤PHP意味着]可能重複(http://stackoverflow.com/questions/12769982/reference-what-這個錯誤意味着在php中) – BlitZ

+3

這個問題似乎是脫離主題,因爲它是關於一個錯字。 – j08691

回答

4

我想你可能只是有一個額外的空間,在這裏:

if ($_SERVER['REQUEST_METHOD'] = = 'POST') { 

試試這個(改變 「= =」 到 「==」):

if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
+1

嗨quasivivo,我試過你的建議和廁所!它的作品神奇。就這樣?呵呵。對於我對代碼的忽略感到抱歉...我真的很感謝你的幫助和時間來回答我的問題...非常感謝...更多的權力...歡呼.....簡 – jane

3

嘗試刪除使您= =之間的空間就==

+1

嗨ameagher,非常感謝,我有嘗試了你的建議,而且效果很好......所以這個小錯誤造成了不同,我花了數小時試圖弄清楚......然後,就像這樣? heheh。再次,非常感謝和更多的權力....簡 – jane