1

I have a "query was empty" problem on an update.

my query is :

$infnav = mysql_query(utf8_decode("UPDATE `Opérations n°1` SET nomnav='$nomnav', typenav='$typenav', callsign='$callsign', imo='$imo', mmsi='$mmsi', immat='$immat', proprio='$proprio', portbase='$portbase', flag='$flag', long='$long'"));

my query working perfectly when i remove long='$long'. When i put data in long, an echo $long; return the correct value and return the query was empty error.

please help

  • [Please, don't use mysql_* functions in new code.](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-function-in-php) They are no longer maintained and the [deprecation process](http://news.php.net/php.internals/53799) has begun on it. See the [red box](http://uk.php.net/manual/en/function.mysql-connect.php)? Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://uk3.php.net/pdo) or [MySQLi](http://uk1.php.net/mysqli) - this [article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which. – ajtrichards Nov 29 '12 at 09:21
  • Your `utf8_decode()` call is returning nothing or a blank string. Debug that before trying to do a query with it. – MrCode Nov 29 '12 at 09:21
  • Because of Reserved word [`LONG`]. – som Nov 29 '12 at 09:22

1 Answers1

1

it's because you have a syntax error on your query, LONG is a RESERVED Word so you should escape it using backtick

UPDATE ...... portbase='$portbase', flag='$flag', `long`='$long'

and your query is vulnerable with SQL injection, please read the article below to protect from it,

Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • @MrCode I know, maybe because the OP doesn't have an error handler. And additional to that, why do you think the query works if `LONG` is not included? – John Woo Nov 29 '12 at 09:21
  • thank's Kuya john your answer help me and i'm learning the reserved word now – user1825668 Nov 29 '12 at 09:29