简体   繁体   中英

SQL syntax error while update sql with php

I have a problem, i try to update a mysql database with my php script but i become the message:

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 'mod = 3, drehtage = 4, schnitttage = 5, dreh = 0, schnitt = 0, off = 0, leiter =' at line 1

i hope you can help me, here is my code to update the database (i just edit the user + pass ;) )

$con = mysql_connect('localhost', 'user', 'pass');
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("kup_projekte", $con);

    $aendern = "UPDATE drehs SET name = '".$t1."', drehdatum = '".$t2."', schnittdatum = '".$t3."', kamera = '".$t4."', assi = '".$t5."', mod = '".$t6."', drehtage = '".$t7."', schnitttage = '".$t8."', dreh = '".$t9."', schnitt = '".$t10."', off = '".$t11."', leiter = '".$t12."' Where id = '".$id."'";

    $update=mysql_query($aendern);
    mysql_close($con);

// EDIT //

the variables $t1 - $t12 are filled and comes correctly.

mod is a mysql reserved word . If you want to use it as a column name, you must enclose it in backticks (`) in your SQL queries

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM