Forum Moderators: coopster
I'm trying to set up a page where my client can enter info about new items that I add to the db.
I'm passing the variables through a form to the edit_item.php page. For some reason, the db will not update. I checked to see if the vars were passed ok by using echo statements with them after the db query and they go through fine. Can someone look at this and see what I have wrong, please?
$query = "UPDATE `prod` SET
`item_no` = $item_no,
`name` = $name,
`desc1` = $desc,
`desc2` = NULL ,
`width` = NULL ,
`height` = NULL ,
`included` = $included,
`weight` = NULL ,
`stock` = NULL ,
`price` = $price
WHERE `prod_id` = $old_no LIMIT 1";
Thanks
$query = "UPDATE prod SET
item_no = '$item_no',
name = '$name',
desc1 = '$desc',
desc2 = 'NULL' ,
width = 'NULL' ,
height = 'NULL' ,
included = '$included',
weight = 'NULL' ,
stock = 'NULL' ,
price = '$price'
WHERE prod_id = '$old_no' LIMIT 1";
The quote should go around the data and not the field names and table names. Based on what you typed above your query probably looked like
UPDATE 'prod' SET 'item_no' = 35 ....
it should look like
UPDATE prod SET item_no = '35' ....
I would guess that "name" is restricted SQL keyword
Do your fields allow NULL
I have had problems of this sort with the quotes etc. Numbers dont require them and text does. I have spent some time before finding these things out by trial and error.
Hope you get it sorted.
cheers