JamesKoash Posted August 29, 2013 Share Posted August 29, 2013 I'm getting the following error: Array to string conversion in C:\wamp\www\survey\page_3.php on line 164 Here is my code, which is a slightly tweaked version of something given to me by a user of this forum. $marketingvalueArray = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5'); $marketingvalueOutput = ""; foreach($marketingvalueArray AS $key => $value) { //### Checks to see if 'outsource' is posted AND whether its an array AND it the value exists i n the posted array $checked = (isset($_POST['marketingvalue']) && is_array($_POST['marketingvalue']) && in_array($key, $_POST['marketingvalue'])) ? 'checked' : '' ; $marketingvalueOutput .= '<input type="radio" class="radio" name="marketingvalue[' . $key .']" value="'. $key .'" '. $checked .'>'. $value .' '; } Also: if (isset($_POST['marketingvalue'])) { $test = ($_POST['marketingvalue']); } Line 164 is where I have referenced $test. I was testing to see what data was coming back through $_POST['marketingvalue']. All I want to do is get a string from radio buttons/checkboxes, rather than an array, so that I can easily export the information into SQL. However, I don't want to totally get rid of the for loop as it has saved me a lot of time, rather than having to input the code for individual radio buttons.I've posted a few other threads about related issues (I've been struggling with this code for the past few days) but no one has been able to help. If someone could point me in the right direction I'd appreciate it greatly. Thanks Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted August 29, 2013 Share Posted August 29, 2013 Nothing about: $test = ($_POST['marketingvalue']); Would cause: Array to string conversion in C:\wamp\www\survey\page_3.php on line 164 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.