Re: Mysqli issue
| From: | Stut | Date: | Thu, 11 Sep 2008 16:21:20 +0000 |
| Subject: | Re: Mysqli issue | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279906@lists.php.net to get a copy of this message | ||
On 11 Sep 2008, at 17:08, Jason Pruim wrote:
On Sep 11, 2008, at 11:23 AM, Stut wrote:Your problem has nothing to do with your use of prepared statements. Your problem is to do with the syntax of the update statement you're trying to use. Insert statements can look like... insert intoOn 11 Sep 2008, at 16:15, Jason Pruim wrote:Hmmm... I looked at it, but didn't see anything that would help with a prepared statement :) Am I that dense or can't we do updates with prepared statements?Attempting to setup a prepared statement in php that will update a record in a mysql database using mysqli Here is the relevant code: $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "UPDATE purl.schreur (FName, LName, email, phone, record, subscribed, date, IPAddress, Business, Address1, City, State, Zip, Coffee, Meeting, areaPlans) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt, 'ssssssssssssssssss', $_POST['txtFName'], $_POST['txtLName'], $_POST['txtEmail'], $_POST['txtPhone'], $_POST['txturl'], $_POST['record'], $_POST['subscribed'],$date, $_SERVER['REMOTE_ADDR'], $_POST['txtBusiness'], $_POST['txtAddress1'], $_POST['txtCity'], $_POST['txtState'], $_POST['txtZip'], $_POST['rdoCoffee'], $_POST['rdoTime'], $_POST['areaPlans']) ;//or die(mysqli_error($link)); echo "<BR>Dump of stmt:<BR>"; mysqli_stmt_execute($stmt) or die(mysqli_error($link)); Here is my error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(FName, LName, email, phone, record, subscribed, date, IPAddress, Business, Addr' at line 1 Now I may just be being dense but I can't figure out the problem... Migraines are not helping right now though.... Can anyone see my stupid mistake? :)That's the syntax for an insert statement. Suggest you read this: http://dev.mysql.com/doc/refman/5.0/en/update.html
table (field1, field2) values (value1, value2);
but update statements can only be in the form...
update table set field1=value1, field2=value2 where field3=value3;
Clear now?
-Stut
--
http://stut.net/