problem with insert (with a for loop)<

liunx

Guest
<?php
ob_start();
include "common/connexion.inc.php";
?>
<?

$num = $_POST["id"];
echo '<br>';

$sql="select * from tblanswer where ID_Enquete ='".$num."' ";
$result = mysql_query($sql);
$num = mysql_numrows($result);
echo $num;
echo'<br>';
echo'<br>';


for ($i = 1; $i<= $num;$i++)
{
$answer[$i] = $_POST["$i"];
echo '<br>';
echo $answer[$i];
echo $i;

$sql ="INSERT INTO tblanswer(Antwoord,ID_Vraag,ID_Enquete) VALUES('$answer[$i]','$i','$num')";
$resultaat2= @mysql_db_query($databasename,$sql,$connection) ;

}



?>
<?
ob_end_flush();
?>

Problem:

he only inserts the first information.
when i do an echo he displays them correctly

for example:
hey 1
hoi 2
test 3

but when i want to insert them he only inserts the first one "hey" 1

and if i change this:
$resultaat2= @mysql_db_query($databasename,$sql,$connection) ;

to this:
$resultaat2= @mysql_db_query($sql) ;
he doesn't insert a thing!

please help me, how come that he shows the right things but he only inserts 1??

very bizarr :si have searched hours for the fault
and it was a "fault" in my database,
there was a fault in my referential integrity (i use mysql4.0 with mysqlfront2.5) innodb database ;)Well done on finding the problem, darktown.

Sorry I couldn't offer any help - just not something I know about too well.
 
Back
Top