PHP代码不删除数据库记录

时间:2015-11-30 13:15:11

标签: php sql database

   <?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$servername = "servername";
$username = "username";
$password = "password";
$dbname = "dbname";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
$twitterhandle = $_GET['twitter_handle']; 
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// sql to delete a record
$sql = "DELETE FROM collected_tweets WHERE handle ='".$twitterhandle."' ";
$result = $conn ->query($sql);

if (mysqli_query($conn, $sql)) {
    echo "Record deleted successfully";
} else {
    echo "Error deleting record: " . mysqli_error($conn);
}

mysqli_close($conn);
?>

这是我从数据库中删除记录的代码,它运行并表示记录已成功删除但记录实际上并未删除。任何帮助赞赏:)

0 个答案:

没有答案