How can you update a record with a prepared statement?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Topkat
Forum Newbie
Posts: 1
Joined: Fri Dec 26, 2008 9:18 am

How can you update a record with a prepared statement?

Post 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?
cptnwinky
Forum Commoner
Posts: 84
Joined: Sat Dec 27, 2008 10:58 am
Location: Williamstown, MA

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

Post 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/
Post Reply