[Nelug] php & mysql

James Barton jb002c4581 at blueyonder.co.uk
Wed Nov 6 00:06:01 UTC 2002

Evening all,
I'm having a spot of bother with getting an update to work on a row in a 
MySQL table, accessed with PHP.
I have one table for properties, which contains only text and number fields, 
and then another table for propert images, since there are zero to three 
images for each property. Having got the data from the html form, including 
any uploaded pictures, I INSERT a row into the property table. Then I look at 
any uploaded files, and try to insert them into the property_images table. 
This all works fine.
But then, depending on the return codes from the routine that stores the 
images, I want to set the value '1' (the number, not the character) in a 
column if the image was stored correctly, and '0' if an image was not stored.
Now,  property_image rows have references to property rows, so this step 
isn't strictly neccessary, but I want to use it for safety. I generate a 
query that looks like:

UPDATE property SET large_pic=1, small_pic=0, paper_pic=0 WHERE reference = 

I hope you'll agree that this is syntactically correct. The result set 
returned by mysql says that 1 row has been affected by the query, but no 
matter what values are in the query, the values in the row in question do not 
change. The key used in the WHERE clause is the same one used to insert the 
row initially, and is the primary key for the property table.
What's most confusing is that if I echo the query to the html page, then cut 
and paste it in to phpMyAdmin, it works the way it should, and changes one 
The fields I'm trying to change are all defined as TINYINT(2) UNSIGNED NOT 
NULL, and default to '0'. Changing the default has no effect, as you would 

I'm at a loss - can anyone think what may be going on?
All suggestions gratefully accepted,

More information about the Nelug mailing list