gpt4 book ai didi

php - MYSQL PHP 删除 'Couldn' t 执行查询 :'

转载 作者:行者123 更新时间:2023-11-30 22:49:56 24 4
gpt4 key购买 nike

尝试从数据库中删除包含 adbreak 作为值的行,但它只是抛出一个错误。它应该进入数据库并删除条目。不确定为什么它不起作用

 php
// Checks to see if the key value is set
//if (isset($_GET['key'])) {
// $key = $_GET['key'];
//}
// If the key value isnt set give it a value of nothing
//else
//{$key = '';}
$key='1';
// Checks to see if the key value is valid to authenticate the user
if ($key == '1'){
// If the key value is correct the user is granted access
$con = mysql_connect("localhost","admin_radio","PASSWORDHERE");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$title='adbreak';
// Select mysql db
mysql_select_db("admin_radio", $con);
mysql_query($con, "DELETE FROM playlists WHERE song_title LIKE %adbreak%")or die ("Couldn't execute query: ".mysql_error());

echo 'Spam Purged !';
}
else {
// Denies the user access if the key value isnt correct
echo '<h1>Access Denied !</h1>';}

最佳答案

您在 LIKE 表达式周围缺少 ':'%adbreak%'

还有一些事情:

  • 不要使用 mysql_* 它已被弃用!

  • 不要在DELETE 查询中使用LIKE。重新考虑您的设计。

关于php - MYSQL PHP 删除 'Couldn' t 执行查询 :',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28475395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com