Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL更新出现错误_Php_Mysql - Fatal编程技术网

Php MySQL更新出现错误

Php MySQL更新出现错误,php,mysql,Php,Mysql,我已经尝试了几个小时用PHP更新MySQL表 我使用了以下代码(以及其他一些代码),但它给出了一条错误消息: $id = $_GET['id']; if(isset($_POST['descr'])){ $go = $_POST['descr']; mysql_query("UPDATE Rooms SET Desc='$go' WHERE Room_ID='$id'") or die(mysql_error()); } m

我已经尝试了几个小时用PHP更新MySQL表

我使用了以下代码(以及其他一些代码),但它给出了一条错误消息:

    $id = $_GET['id'];

    if(isset($_POST['descr'])){
    $go = $_POST['descr'];

    mysql_query("UPDATE Rooms SET Desc='$go' WHERE Room_ID='$id'") 
    or die(mysql_error());  

    }


    mysql_close($conn);
错误提示:“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以了解在'Desc='This room是主测试室。它是?'WHERE room_ID='11''第1行附近使用的正确语法”

表单名为“descr”,表名为“Rooms”,需要更新的字段为“Desc”,它应该位于相应ID所在的位置,基于动态URL

如果我写echo=$go,它会输出正确的数据,所以我认为是php


它确实正确地连接到数据库

假设ID是一个数字:

$id = $_GET['id'];

if(isset($_POST['descr'])){
$go = $_POST['descr'];

mysql_query("UPDATE Rooms SET `Desc`='".$go."' WHERE Room_ID=".$id.") 
or die(mysql_error());  
}
mysql_close($conn);

假设ID是一个数字:

$id = $_GET['id'];

if(isset($_POST['descr'])){
$go = $_POST['descr'];

mysql_query("UPDATE Rooms SET `Desc`='".$go."' WHERE Room_ID=".$id.") 
or die(mysql_error());  
}
mysql_close($conn);

Desc保留给订购者!用“`”符号将其括起来

mysql_query("UPDATE `Rooms` SET `Desc` = '".$go."' WHERE `Room_ID` = ".$id.") 
or die(mysql_error());

Desc保留给订购者!用“`”符号将其括起来

mysql_query("UPDATE `Rooms` SET `Desc` = '".$go."' WHERE `Room_ID` = ".$id.") 
or die(mysql_error());

Desc是mysql中的一个特殊单词 试试逃跑

mysql_query("UPDATE Rooms SET `Desc`='$go' WHERE Room_ID='$id'") mysql_查询(“更新房间集`Desc`='$go',其中房间ID='$ID'))
Desc是mysql中的一个特殊单词 试试逃跑

mysql_query("UPDATE Rooms SET `Desc`='$go' WHERE Room_ID='$id'") mysql_查询(“更新房间集`Desc`='$go',其中房间ID='$ID'))
如果将列Room_ID设置为数字类型,则不需要$ID周围的单引号。如果将列Room_ID设置为数字类型,则不需要$ID周围的单引号。习惯性的做法是使语法着色更容易在查询中发现变量。这是我刚开始做的,我发现它更容易阅读。习惯的力量是让语法着色更容易在查询中发现变量。这是我刚开始读的东西,我发现它更容易阅读。非常感谢:)我一直在尝试转义,但一定是一路打字。非常感谢:)我一直在尝试转义,但一定是一路打字。