Assuming i am connected to mysql and my variables are loaded appropriately, can anyone see why this doens't work?
(It does NOT error, it just keeps on going to the next part of the script and does not update the database).
$Update = mysql_db_query ($dbname, "UPDATE user_info SET photo='$photos_remaining' WHERE id='$id'") or die('Subtracting 1 from photos remaining failed: ' . mysql_error());
Any advice appreciated,
Rob
Last edited by robster on Wed Sep 28, 2005 3:07 am, edited 3 times in total.
Basically, field 'photo' is currently set to 28. When I run the script, it sets $photos_remaining to (photo - 1). I've tested this with an echo "$photos_remaining"; and it shows 27 just before that line is run. The line then runs and it stays at 28
turns out the problem was the $id, it was the id of the image, not the user... I fixed it and it worked. Strange though, I would have thought it would error.
Image id was 80, user id was 1. There is no user with an id of 80 on this test machine, so I would have expected a bail... strange indeed.
Updating primary photo failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary = '1' WHERE id = '86'' at line 1
It's probably because primary is a reserved word in mysql for setting the primary key of the table. I guess if you change the fieldname to myprimary it will work.
I think everyone has had something like this in the past. I once had something like this with javascript. I had a form and a textbox with the name action, and then try to change form.action.value. This didn't work off course because action is a property of form so it didn't refer to my textbox, but before I noticed that I had wasted a lot of time
Hmm, maybe a nice idea for a new topic, your most idiot mistake or something like that