我在需要的时候无法更新这个。这是一个optout脚本,用于更新已删除列中值为1的选定电子邮件行。我似乎无法更新它,我认为这是我的sql的问题。我们非常感谢您的帮助。
请注意:
我很抱歉…好像有问题。。。。。。。。。
这是剧本。

<?php

if (isset($_GET['e'])) {

    include_once "../storescripts/connect_to_mysql.php";

    $email = $_GET['e'];

    $sql_delete = mysql_query("UPDATE test WHERE email='$email' SET removed = '1'");

    if (!$sql_delete) {
        echo "Sorry there seems to be and issue when trying to remove your listing. Please email Admin directly using this email address: chris@.com";
    } else {
        echo "Sorry to see you go! You will not receive our newsletter ever again unless you relist. To gain access to our newsletter again simply let us know by email at chris@.com";
    }
}
?>

最佳答案

尝试:

$sql_delete = mysql_query("UPDATE test SET removed = '1' WHERE email='$email'");

问题是你的语法,看看mysqlupdate语法,其中where子句应该去哪里,而set应该去哪里http://dev.mysql.com/doc/refman/5.0/en/update.html
如果使用正确的错误处理,您可能会看到此问题,如下所示:
$sql_delete = mysql_query("UPDATE test SET removed = '1' WHERE email='$email'") or die(mysql_error());

查看mysql_real_escape_stringhttp://www.php.net/manual/en/function.mysql-real-escape-string.php,以防止SQL注入。例子:
$email = mysql_real_escape_string($email);
$sql_delete = mysql_query("UPDATE test SET removed = '1' WHERE email='$email'") or die(mysql_error());

还要注意mysql_扩展已被弃用,您需要开始使用mysqliPDO

关于php - MYSQL更新列出现问题,无法进行一项选择,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18007864/

10-16 14:55
查看更多