PHP解析代码错误

时间:2013-10-07 17:18:58

标签: php parsing

请帮我解决此错误。请看我的代码..

错误是:

"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); 


   ?> 

2 个答案:

答案 0 :(得分:4)

我想你可能只有一个额外的空间:

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

试试这个(将“= =”更改为“==”):

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

答案 1 :(得分:3)

尝试删除= = ==

之间的空格