此程序是爲了刪除記錄時,給定的ID。php刪除記錄使用ID
PHP:
if ($_GET['type']=="file"){
$servername = "localhost";
$username = "****";
$password = "****";
$dbname = "****";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_error($conn)) {
die("Connection failed: " . mysqli_connect_error($conn));
}
$sql = "SELECT id,user, FROM CreationsAndFiles WHERE id =".$_GET['id']." LIMIT 1";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
if ($row['user'] == $login_session){
$sql = "DELETE FROM CreationsAndFiles WHERE id=".$_GET['id'];
if(mysqli_query($conn, $sql)){echo "deleted";}
}
mysqli_close($conn);
//header("location: index.php?page=CreationsAndFiles");
}
標題是type=file&id=9
存在這樣的情況id=9
它沒有明顯的理由是行不通的記錄。
錯誤是什麼? –
這條語句'if($ row ['user'] == $ login_session){...',你在哪裏定義了'$ login_session'? –
也許你可以在你的if塊中添加一些'echo'語句來查看執行過程中的哪個路徑? – Jeff