and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i have a database which is taking bookings for courses. when i abooking has been made i am trying to get the places available field to decrease by 1. when it does this it goes from 15 to 0. please can anyone shed any light on this. my code etc is below
$sql = "SELECT * FROM rsu WHERE CourseID LIKE '$courseid'";
$resultID1 = mysql_query($sql, $linkID)or die(mysql_error());
if(mysql_num_rows($resultID1) < 1)
{
print "There has been an internal error. We apologise for this please try again later";
}
else
{
$places =$row['placesavailable'];
$places --;
$result = mysql_query("UPDATE rsu SET placesavailable = '$places' where CourseID = '$courseid'", $linkID)or die(mysql_error());
}
I am using mysql and my datatype for the placesavailable field is integer (11)
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
No idea. But you shouldn't use SELECT + php code + UPDATE anway since it's prone to race conditions (unless you lock the table for the duration of the whole process)