Forum Moderators: coopster

Message Too Old, No Replies

MySQL & PHP - Variables are lost in update

Variables are lost in updating and record fields are empty

         

LukeDouglas

10:49 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



This is a followup to a previous post which I was told was too long.

Basically, I have valid variables which are not updating row fields (columns) but instead the fields (columns) are emptied of all data.

Here is the diagnostic printout:

RECORD CONTENTS BEFORE UPDATING:
ID = 50
ItemNumber = item 1
Description = description 1
Details = details 1
Brand = brand 1
Category = PT
SubCategory = PT-Ladies
Price = 19.95
ShippingAmt = 0.00
Notes = Notes 1
Photo = DSCF0081.jpg

VARIABLES FROM FORM ON EDITING PAGE SENT TO THIS UPDATE PAGE (ie: ItemNumber = '$ItemNumber'):
ID = 50
ItemNumber = item 2
Description = description 2
Details = details 2
Brand = brand 2
Category = PT
SubCategory = PT-Ladies
Price = 19.95
ShippingAmt = 0.00
Notes = Notes 2
Photo = DSCF0081.jpg

QUERY STRING: [NOTE: This query works fine if executed within phpAdmin]

UPDATE Inventory SET ItemNumber = 'item 2', Description = 'description 2', Details = 'details 2', Brand = 'brand 2', Category = 'PT', SubCategory = 'PT-Ladies', Price = '19.95', ShippingAmt = '0.00', Notes = 'Notes 2', Photo = 'DSCF0081.jpg' WHERE ID=50

NO mysql error was encountered
Updated records: 1

AFTER UPDATE AND MYSQL CLOSED AND RECONNECTED QUERY STRING:
SELECT * FROM Inventory WHERE ID= 50

RECORD CONTENTS AFTER UPDATING:
ID = 50
ItemNumber = item 2
Description = description 2
Details = details 2
Brand = brand 2
Category = PT
SubCategory = PT-Ladies
Price = 19.95
ShippingAmt = 0.00
Notes = Notes 2
Photo = DSCF0081.jpg

As you can see, everything looks great except when I go back to the listing page, the record fields are empty and if I browse using phpAdmin, the record fields are empty. So it is making changes to the record but undoubtedly, the variables are empty at the time of updating the fields.

Any suggestions to determine where the problems is (ie: it's a PHP or a MySQL problem)?

Thanks.

Luke

dreamcatcher

2:13 am on Dec 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Luke,

It sounds like the problem is when the form is processed. Have you echoed the variables when you process your form to see if any data is being sent? Are you using the PHP superglobal $_POST to retrieve your data? If not, this may be your problem if you have register globals off.

Its a process of elimination.

dc