homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Trying to UPDATE with variables from form

 11:29 am on Oct 29, 2002 (gmt 0)

Hello all.

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";




 11:39 am on Oct 29, 2002 (gmt 0)

Try changing the query to

$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' ....


 12:01 pm on Oct 29, 2002 (gmt 0)

Thanks shanz. Unfortunately, it still won't work:(

I'm sure my connect statements are right and the variables are passed. This is driving me crazy.


 12:27 pm on Oct 29, 2002 (gmt 0)

Just a few comments that might make a difference.

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.



 12:35 pm on Oct 29, 2002 (gmt 0)

Maybe this line would help :o


Now I feel like a total moron!

Thanks for jumping in to help me;)


 12:47 pm on Oct 29, 2002 (gmt 0)

LOL I have done that exact thing myself :)

I learnt fast to look for my home grown moronic mistakes

Glad you got it sorted

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved