[thelist] php mysql update problem
Austin Harris
austin at dotmail.co.uk
Fri Jun 27 07:46:59 CDT 2003
Thanks Chris,
It seems to work but I'm not sure if I have done it right, as I said in
original post very new to this :)
Thanks again, Austin
// do the update before getting records.
if ($_POST['submit']=='Submit') {
// do the update
$update_sql = "UPDATE jayandmel SET Present='Car' WHERE id='1'";
$result = mysql_query($update_sql);
my_debug("SQL -- $update_sql");
}
// carry on and grab the required records as normal.
mysql_select_db("austin",$db);
$result = mysql_query($update_sql);
my_debug("result -- $result SQL -- $update_sql");
$result = mysql_query("SELECT * FROM jayandmel",$db);
on 27/6/03 1:01 pm, christopher at ideadesigners.com at
christopher at ideadesigners.com wrote:
> [resent because I'm a dope and didn't include the subject the first time. :) ]
>
> Austin Harris wrote:
>> // do the update before getting records.
>> if ($_POST['submit']=='Submit') {
>> // do the update
>> $update_sql = "UPDATE jayandmel SET Present='2' WHERE Present='House'";
>> my_debug("SQL -- $update_sql");
>> }
>>
>> // carry on and grab the required records as normal.
>
> Hi Austin,
>
> You need to run the SQL statement after you have constructed it inside
> variable $update_sql.
>
> Your debug statement outputs the SQL but you don't actually use it on
> your DB to do the update :)
>
> ADD:
>
>> $update_sql = "UPDATE jayandmel SET Present='2' WHERE
> Present='House'";
>
> $result = mysql_query($update_sql);
>
>> my_debug("SQL -- $update_sql");
>
> then debug on:
>
> my_debug("result -- $result SQL -- $update_sql");
>
> to give you the status of the result......although you should see the
> table contents change.
More information about the thelist
mailing list