Dan06 Posted September 29, 2008 Share Posted September 29, 2008 I have a form which is dynamically created from data in a table and uses the post method. The form is made of checkboxs and each checkbox is apart of an associative array. When the user selects a checkbox I would like the selected checkbox to update a target table. To do this I'm using the following code: if ((isset($_POST["SubmitList"])) && ($_POST["SubmitList"] == "TypeSpecForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductListing=%s, ServiceType=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($_POST['{$row_ProdType['TypeName']}'], "text"), GetSQLValueString($_POST['{$row_ServType['TypeName']}'])); But unfortunately, I'm getting the following error: Parse error: syntax error, unexpected T_STRING, expecting ']' in D:\Apache\htdocs\listingregister.php The problem seems to be in the GetSQLValueString($_POST[...]) parts of the code. And the GetSQLValueString function adds ' ' around the $_POST value. Any ideas on how to solve this? Thanks. Link to comment https://forums.phpfreaks.com/topic/126287-sprintf-post-method-and-associative-array/ Share on other sites More sharing options...
timmah1 Posted September 29, 2008 Share Posted September 29, 2008 Try this if ((isset($_POST["SubmitList"])) && ($_POST["SubmitList"] == "TypeSpecForm")) { $updateSQL = sprintf("UPDATE businessprofile SET ProductListing=%s, ServiceType=%s WHERE Id=" . "'" . $_SESSION['Reg'] . "'", GetSQLValueString($_POST['{$row_ProdType[TypeName]}'], "text"), GetSQLValueString($_POST['{$row_ServType[TypeName]}'])); Link to comment https://forums.phpfreaks.com/topic/126287-sprintf-post-method-and-associative-array/#findComment-652994 Share on other sites More sharing options...
Dan06 Posted September 29, 2008 Author Share Posted September 29, 2008 I tried the new code, but it doesn't work. There are no error messages, but it also does not update the target table. Any other thoughts or suggestions? Link to comment https://forums.phpfreaks.com/topic/126287-sprintf-post-method-and-associative-array/#findComment-653146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.