Jump to content

sprintf(), post method, and associative array.


Dan06

Recommended Posts

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.

 

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]}']));

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.