Page 1 of 1

Use of variables in a MySQL Update Query

Posted: Mon Jun 30, 2008 5:47 am
by Taxon
This works:

$sql = 'UPDATE Requests SET requested_date=\'2007-01-01\' WHERE request_number=\'0\'';

However, I am have not been able to come up with the proper syntax for replacing the constants in the query with variables.

The variables are $requested_date and $request_number.

What is the correct syntax for using those variables in the Update query?

Thanks,

Roger

Re: Use of variables in a MySQL Update Query

Posted: Mon Jun 30, 2008 7:13 am
by jaoudestudios
You need to read up on basic php! Otherwise you will not get very far.

However, the solution is...

$sql = "UPDATE Requests SET requested_date='".$requested_date."' WHERE request_number='".$request_number."'";

Eddie

Re: Use of variables in a MySQL Update Query

Posted: Mon Jun 30, 2008 10:24 am
by Taxon
Thanks, Eddie. :oops: