PDA

View Full Version : Is my update query stuck in a loop?


jaymo
06-02-2009, 01:21 PM
Hi all.

I have a system that works like ticket booking where it reserves users selections for say 30 seconds. However, when I reach the update query that puts the users ID in the reserved column, none of the code below executes. If I comment the query out then the submitted statment runs fine. Is it stuck in a loop? I swear this code worked yesterday.



..// Submit button post
$submit = $_POST['submit'];


// ...If there are no user Id's in the rsvd column, it is safe to continue booking
if($checkAvailability)
{
// Lock selections from other users by putting ID into rsvd_by_ID field
$lockUpdate = mysql_query("UPDATE items SET rsvd_by_userID ='$id' WHERE item_id ='$item_id_selected' ");
mysql_query($lockUpdate)or die(mysql_error());

echo"reserved";

// If user confirms, continue
if($submit)
{
echo "Booking confirmed"
....Booking code etc
}
}

...// Form code:
<form method="post" action="$_SERVER["PHP_SELF"];">

...// Submit button code:
<input type="submit" name="submit" id="submit" value="submit" />



Hope someone can help as I have been having this problem all day.

davidj
06-02-2009, 01:37 PM
can you copy and paste your code as you have it in your script again please

i removed some dubious code tags so need to know if its an error which ocurred when you posted in the forum or if its written into your code

jaymo
06-02-2009, 01:40 PM
Hi David.

I put forum PHP tags around the form action so that it would all be highlighted properly. In the script it just reads:

action="<?php $_SERVER["PHP_SELF"]; ?>


Still need the rest again or was that it?

jaymo
06-02-2009, 01:41 PM
Oops, i missed the last quote after the closing '?>' because I typed it by hand

jaymo
06-03-2009, 03:35 PM
ok so I still can't figure this out so I decided to get around it by using an ajax call instead of a form submission. Works fine, even though I would like to find out what the problem was.

Another question...

Does anyone know if its possible to call a sql query when the user closes the window? Because I want to make sure I clear their ID from the reserved column if they close the window.

Thanks