Welcome to WebmasterWorld Guest from 54.226.67.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php/mysql

Trying to UPDATE with variables from form

     

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



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

Thanks

shanz

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

10+ Year Member



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

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



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.

ukgimp

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

WebmasterWorld Senior Member 10+ Year Member



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.

cheers

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



Maybe this line would help :o

mysql_query($query);

Now I feel like a total moron!

Thanks for jumping in to help me;)

ukgimp

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

WebmasterWorld Senior Member 10+ Year Member



LOL I have done that exact thing myself :)

I learnt fast to look for my home grown moronic mistakes

Glad you got it sorted

 

Featured Threads

Hot Threads This Week

Hot Threads This Month