0

错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“1”附近使用正确的语法。代码如下,我收到错误,来自 http://cms2.br-de。 tk/editinfo.phphttp://cms2.br-de.tk/updateinfo.php

<?php
    mysql_connect("mysql10.000webhost.com","******_12","*******") or       die("Error:".mysql_error()); 
    mysql_select_db("******_1");//add your dbname

    //get the variables we transmitted from the form
    $Title = $_POST['Title'];
    $Author = $_POST['Author'];
    $Date = $_POST['Date'];
    $Content = $_POST['Content'];

    //replace TestTable with the name of your table
    //replace id with the ID of your user
    $sql = "UPDATE `posts` SET `Tilte` = '$Tilte',`Author` = '$Author',`Date` =   '$Date',`Content` = '$Content' WHERE `posts`.`ID` = '$ID' 1 ";

     mysql_query($sql) or die ("Error: ".mysql_error());

    echo "Database updated. <a href='editinfo.php'>Return to edit info</a>";

?>
4

3 回答 3

1

您在查询结束时添加了额外的 1。它应该是这样的:

$sql = "UPDATE `posts` SET `Tilte` = '$Title',`Author` = '$Author',`Date` =   '$Date',`Content` = '$Content' WHERE `posts`.`ID` = '$ID'";
于 2012-07-23T11:32:32.233 回答
0

1你在你的陈述结束时有一个备用的。

UPDATE `posts` SET `Tilte` = '$Title',`Author` = '$Author',`Date` =   '$Date',`Content` = '$Content' WHERE `posts`.`ID` = '$ID';"

正如 Grigore 正确发现的那样,根据列名,您的语句中可能还会出现拼写错误。

UPDATE `posts` SET `Title` = '$Title',`Author` = '$Author',`Date` =   '$Date',`Content` = '$Content' WHERE `posts`.`ID` = '$ID';"
于 2012-07-23T11:31:25.163 回答
0
`Tilte` = '$Title'

也许这是标题而不是倾斜,除了查询末尾有一个“1”

于 2012-07-23T11:33:43.297 回答