nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c.0404221505.f72a83d@posting.google.c om>...[color=blue]
>
kinskai@aol.com (none) wrote in message
> news:<863d38a1.0404220935.34598ce8@posting.google. com>...[color=green]
> >
> > when i use the following code;
> >
> > $current_available = mysql_query("SELECT availableplaces FROM
> > tblCourses WHERE course_id='$_POST[selectedcourse]'");
> > $current_available -= 1;
> >
> > The variable $current_available is initially 32, after running the
> > above it is changed to 2.
> >
> > I'm really lost and would appreciate some direction.[/color]
>
> OK, here is your code again, slightly reformatted:
>
> $current_available = mysql_query("SELECT availableplaces
> FROM tblCourses WHERE course_id='$_POST[selectedcourse]'");
>
> This makes $current_available a resource.
>
> $current_available -= 1;
>
> Now all of a sudden you decide to treat $current_available as if
> it were an integer. Needless to say, the results are not what
> you expect them to be...
>
> Cheers,
> NC[/color]
Thanks for the input,
I'm quite new to php but i suspected it may be something I was doing
with the variables.
The query;
mysql_query("UPDATE `tblCourses` SET
`availableplaces`=`availableplaces`-1 WHERE
`course_id`='$_POST[selectedcourse]' LIMIT 1");
worked a treat, but the first one (long way) threw an error as not
been valid syntax.
Cheers anyway :o)