Jump to content

Array to string conversion error


JamesKoash

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.