I seem to have a little trouble with some basic mysql commands. This is the table called item that I created:
mysql> describe item;
+------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+----------------+
| item_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| item_name | varchar(255) | NO | | NULL | |
| item_price | int(10) unsigned | NO | | NULL | |
+------------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
and this is the line of code i'm using to update this table:
$db = mysql_connect('127.0.0.1', 'root', 'mac');
mysql_select_db('spending') or die(mysql_error($db));
$query = 'UPDATE item SET item_name = "' . $_POST['item_name'] . '",
item_price = ' . $_POST['item_price'] . '
WHERE item_id = ' . $_GET['id'] . '';
$result = mysql_query($query, $db) or die(mysql_error($db));
but every time I run it, it always complains like this:
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 'WHERE item_id = 1' at line 4
Can anybody tell me what is wrong with this thing? Thanks in advance!