gpt4 book ai didi

mysql - 为什么我的更新查询不起作用?

转载 作者:行者123 更新时间:2023-11-30 00:21:40 25 4
gpt4 key购买 nike

我有以下更新查询,但由于某种原因它不起作用。我认为这与“id = '”.$id.”有关,但我尝试了三种不同的方法,但似乎无法让它工作。我之前编写过更新查询,没有任何问题,但对于出于某种原因,这很痛苦。提前致谢。

$id = $_GET['id'];
$speaker = mysql_real_escape_string($_POST['speaker']);
$message = $_POST['message'];
$title = mysql_real_escape_string($_POST['title']);
$date = $_POST['date'];
$day = $_POST['day'];
$password = mysql_real_escape_string($_POST['password']);
$complete = $_POST['complete'];

$title = ucwords(strtolower($title));

if ($complete && ($password == "*****"))
{

$db = mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($dbname,$db) or die(mysql_error());

mysql_query("UPDATE sermons SET speaker = '$speaker', message = '$message', title = '$title', date = '$date', day = '$day' WHERE id = '$id'");

$num_rows = mysql_num_rows(mysql_query("SELECT speaker, message, title, date, day FROM sermons WHERE speaker = '$speaker' AND message = '$message' AND title = '$title' AND date = '$date' AND day = '$day'", $db));

if ($num_rows == 1)
echo "<script type='text/javascript'> alert('Sermon Information Entered Successfully!'); </script>";

else
echo "<script type='text/javascript'> alert('Error! Please Try Again.'); </script>";
}

else if ($complete && ($password != "*****"))
{
echo "<script type='text/javascript'> alert('Incorrect Password! Please Try Again.'); </script>";
}

最佳答案

因为 id 是整数,所以这是正确的代码,请尝试:

mysql_query("更新布道集演讲者 = '$speaker', 消息 = '$message', 标题 = '$title', 日期 = '$date', day = '$day' WHERE id =".$id );

我预计它会起作用。

关于mysql - 为什么我的更新查询不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23177846/

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