Uninitialized string offset notice I am recieving
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2433727/submitting-a-multidimensional-array-via-post-with-php">Submitting a multidimensional array via POST with php</a><br>
  <a href="http://stackoverflow.com/questions/5345859/php-access-all-post-variables-into-an-array">PHP access all $_POST[] variables into an array?</a>  </p>
</blockquote>



<p>I want to insert some values into the database. What I want to do is post "numberAnswer" values for from each row into the database, one value per row. The problem is that I am getting this notice:</p>

<p>Notice: Uninitialized string offset: 1 in /web/stud/xxx/Mobile_app/insertQuestion.php on line 174</p>

<p>So all it is doing is posting the value from the last row into the database as first row and then not inserting all of the other values.</p>

<p>So my question is that what am I doing wrong to get this notice and how can it be fixed?</p>

<p>Below is the code:</p>

<pre><code>&lt;?php

session_start();

//connect to db

$i = 0;
$c = count($_POST['gridValues']);

$insertquestion = array();

for($i = 0;  $i &lt; $c; $i++ ){


    $insertquestion[] = "'". 
                mysql_real_escape_string( $_POST['numQuestion'][$i] ) ."','".  
                    mysql_real_escape_string( $_POST['numberAnswer'][$i] ) ."'";

}


 $questionsql = "INSERT INTO Question (NoofAnswers) 
    VALUES (" . implode('), (', $insertquestion) . ")";

echo($questionsql);


mysql_close();


?&gt;
</code></pre>

<p>Below is the form code:</p>

<pre><code>&lt;form id="QandA" action="insertQuestion.php" method="post"&gt;
&lt;div id="detailsBlock"&gt;
&lt;table id="question"&gt;
&lt;tr&gt;
    &lt;th colspan="2"&gt;
        Question Number &lt;span class="questionNum"&gt;1&lt;/span&gt;
        &lt;input type="hidden" class="num_questions" name="numQuestion" value="1"&gt;
    &lt;/th&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;table id="optionAndAnswer" class="optionAndAnswer"&gt;
&lt;tr class="numberAnswer"&gt;
&lt;td&gt;Number of Answers:&lt;/td&gt;
&lt;td&gt;
&lt;span class="na string" &gt;Only 1 Answer&lt;/span&gt;
&lt;input type="text" name="numberAnswer" class="numberAnswerTxt answertxt" onkeyup="numberKeyUp(this)" onkeypress="return isNumberKey(event)" onChange="getButtons()" &gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/div&gt;
&lt;/form&gt;
</code></pre>
