1

ERROR:

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 'Desc='Legenday Films' WHERE ID='3'' at line 1

AT:

$mysqli->query("UPDATE conf_src SET Name='$CSRC', Desc='$CSRCD' WHERE ID='$ssID'")

$CSRC is the name of the source "LEGEND"

$CSRCD is the description of the source "Legendary Films"

Alan Daniel
  • 69
  • 2
  • 10
  • 1
    `DESC` is a [reserved word](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) in mysql. Use backticks to escape field names. – showdev Oct 14 '14 at 22:20

3 Answers3

4

desc is a MySQL reserved word

which needs to be wrapped in backticks

`Desc`='$CSRCD'

Either do that or rename it to something else, such as Description

For the complete list, consult the MySQL.com website:

in order to avoid using another reserved word later on.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
3

desc is a keyword in SQL for descending or describe, you must use backticks to quote those.

 UPDATE conf_src SET Name='$CSRC', `Desc`='$CSRCD' WHERE ID='$ssID'
Justin Kiang
  • 1,270
  • 6
  • 13
2

Desc is a reserve word and so need escaping using backtique like

`Desc`

When not sure, consider escaping all the column(s) in your select list along with table name (consider referring MySQL spec first)

UPDATE `conf_src` SET `Name`='$CSRC', `Desc`='$CSRCD' WHERE `ID`='$ssID'
Rahul
  • 76,197
  • 13
  • 71
  • 125