webdev007
Programmer
- Sep 9, 2005
- 168
I am working on a dynamic quiz manager system
This is called by AJAX and build as many for rows as the php/ajax calls for
$counter =1;
while( $counter <= $num)
{
echo"<tr>
<td align='left' width='80%'>
Question: {$counter}<input type='text' name='quest[]' value='$quest' size='50'></td>
<td align='left' width='10%'>True: <input type='checkbox' name='a[]' value='y'></td>
<td align='left' width='10%'>False: <input type='checkbox' name='a[]' value='n'></td></tr>";
$counter++;
}
This is where the results go
$db = new MySQL_Db;
$db->connect($host, $un, $pw);
$db->query($db_db);
$subject=CleanDb($subject);
//$quest=CleanDb($quest);
//$answer=CleanDb($a);
$quiz_url=CleanDb($quiz_url);
/*
$result = $db->query("
INSERT INTO quiz
(subject, quest, answer, quiz_url)
VALUES('$subject', '".CleanDb($quest[$counter])."', '".CleanDb($a[$counter])."', '$quiz_url')
");
*/
$result = $db->query("
INSERT INTO quiz
(quest)
VALUES('".CleanDb($quest[$counter])."')
");
as you see I even shortened the INSERT for test purpose
if I do: print'<pre>'; print_r($quest); exit('</pre>');
the array resulting is what is expected
but the insert always result in:
Notice: Undefined offset: 1 in ... which is the insert value
what am I overlooking at?
thanks
regards
This is called by AJAX and build as many for rows as the php/ajax calls for
$counter =1;
while( $counter <= $num)
{
echo"<tr>
<td align='left' width='80%'>
Question: {$counter}<input type='text' name='quest[]' value='$quest' size='50'></td>
<td align='left' width='10%'>True: <input type='checkbox' name='a[]' value='y'></td>
<td align='left' width='10%'>False: <input type='checkbox' name='a[]' value='n'></td></tr>";
$counter++;
}
This is where the results go
$db = new MySQL_Db;
$db->connect($host, $un, $pw);
$db->query($db_db);
$subject=CleanDb($subject);
//$quest=CleanDb($quest);
//$answer=CleanDb($a);
$quiz_url=CleanDb($quiz_url);
/*
$result = $db->query("
INSERT INTO quiz
(subject, quest, answer, quiz_url)
VALUES('$subject', '".CleanDb($quest[$counter])."', '".CleanDb($a[$counter])."', '$quiz_url')
");
*/
$result = $db->query("
INSERT INTO quiz
(quest)
VALUES('".CleanDb($quest[$counter])."')
");
as you see I even shortened the INSERT for test purpose
if I do: print'<pre>'; print_r($quest); exit('</pre>');
the array resulting is what is expected
but the insert always result in:
Notice: Undefined offset: 1 in ... which is the insert value
what am I overlooking at?
thanks
regards