Page 1 of 1

How can you update a record with a prepared statement?

Posted: Fri Dec 26, 2008 9:24 am
by Topkat
I've looked at the PHP.net manual, searched Google and I can't find any examples of updating records with prepared statements. Everything is on select and insert...

How is it done?

I tried the following, but it says I have a syntax error from the first line of code...

Code: Select all

$q = "UPDATE table1 SET title=?, description=?, price=?, location=?, email=?, date=? WHERE id=$id"; 
$stmt = mysqli_prepare($dbc, $q); 
mysqli_stmt_bind_param($stmt, 'ssisss', $title, $descrip, $pri, $loc, $e, $date1); 
mysqli_stmt_execute($stmt); 
 
Does anyone have any examples of using UPDATE with prepared statements?

Re: How can you update a record with a prepared statement?

Posted: Sat Dec 27, 2008 2:16 pm
by cptnwinky
Could I see the exact error and all the code (rather than just the snippet). Other than that, you could look at this tutorial I found.

http://andrejserafim.wordpress.com/2007 ... tatements/