Jump to content

[SOLVED] What's wrong with my query?


iPixel

Recommended Posts

It's a simple POST from a dynamic form to a page that collects them.

type sent as <input... name="type[]" id="type[]">

 

All the data goes through and is collected no problem, but my bloody sql query craps out and i do not see a reason why.

 

Here's the query.

<?php
$query = "UPDATE tablename SET type = '$type[$x]', price = '$price[$x]', desc = '$desc[$x]', link = '$link[$x]' WHERE id = '$id[$x]'";
?>

 

 

Here is the 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 = 'descriptions for the purchase item' at line 1

 

Thanks

For the help!

Link to comment
https://forums.phpfreaks.com/topic/173651-solved-whats-wrong-with-my-query/
Share on other sites

Hi iPixel,

 

'desc' is a MySQL reserved word.  You can use it but you will need to escape it with backticks `.  See http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html for more information.

 

So your code needs to read:

 

<?php
$query = "UPDATE tablename SET type = '$type[$x]', price = '$price[$x]', `desc` = '$desc[$x]', link = '$link[$x]' WHERE id = '$id[$x]'";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.