无法更新数据:您的SQL语法有错误;

用户名

我有这个问题

错误

Could not update data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ..... line 1.

这是代码

<html>
<head>
<title>Update a Record in MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['update']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db     = 'catalog';
$conn = mysql_connect($dbhost, $dbuser, $dbpass,$db);
if(! $conn )
{
 die('Could not connect: ' . mysql_error());
}

$adresa_e = $_POST['ADRESAE'];
$nr_matricol = $_POST['NR_MATRICOL'];

$sql = "UPDATE elevi ".
      "SET ADRESAE = $adresa_e ".
      "WHERE NR_MATRICOL = $nr_matricol" ;

mysql_select_db('catalog');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
 die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
  <table width="400" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td width="100">ADRESA ELEV</td>
      <td><input name="ADRESAE" type="text" id="ADRESAE"></td>
    </tr>
    <tr>
      <td width="100">NR MATRICOL</td>
      <td><input name="NR_MATRICOL" type="text" id="NR_MATRICOL"></td>
    </tr>
    <tr>
      <td width="100"></td>
      <td></td>
    </tr>
    <tr>
      <td width="100"></td>
      <td><input name="update" type="submit" id="update" value="Update"></td>
    </tr>
  </table>
</form>
<?php
}
?>
</body>
</html>
大坝螺母

变量在您的请求中被视为简单文本:

试试这个

$sql = "UPDATE elevi SET ADRESAE = '".$adresa_e."' WHERE NR_MATRICOL = '".$nr_matricol."'" ;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误更新记录 您的 SQL 语法有错误

MYSQL:您的 SQL 语法有错误

将数据插入数据库但收到 MySQLSyntaxErrorException 错误:您的 SQL 语法有错误

Codeigniter更新-错误代码:1064您的SQL语法有错误;

SQL 错误 :1064 您的 SQL 语法有错误

MySQL数据库错误返回#1064-您的SQL语法有错误;

WordPress 数据库错误:您的 SQL 语法有错误

MySQL错误1064:您的SQL语法有错误

奇怪的错误您的SQL语法有错误

Hibernate:错误:您的 SQL 语法有错误

您的 SQL 语法错误中有错误吗?

ProgrammingError:1064(42000):您的SQL语法有错误;无法使用外键创建表

Mysql 错误 (#1064) 您的 SQL 语法有错误,无法在第 20 行的 '' 附近使用正确的语法

mysql console> mysqlbinlog您的SQL语法有错误

Hibernate和MYSQL:您的SQL语法有错误吗?

Hibernate和MYSQL:您的SQL语法有错误吗?

#1064-您的SQL语法有错误... FROM附近

您的SQL语法中有错误-休眠和mysql

您的SQL语法EXTRACT中有错误

您的 SQL 语法有错误;靠近 'SET `points` = `points` + ?'

显示#1064的mysql查询-您的SQL语法有错误;

您的SQL语法有错误(连接正常)

mysql error您的SQL语法有错误

1064“您的SQL语法有错误; ...” Python MySQL

您的SQL语法有错误(CREATE PROCEDURE)

您的SQL语法C#.net上有错误

#1064-您的SQL语法有错误

MySQL说:文档(#1064)-您的SQL语法有错误;

Netbeans Java - 您的 sql 语法有错误