|
Posted by Tyno Gendo on 04/05/07 15:36
Jerim79 wrote:
> A new situation that has arised is that now the for loop, even though
> it doesn't insert anything other than 0 to the database, it seems to
> be stuck in an infinite loop. Here is the code:
>
> <?php
>
> if ($_SERVER["REQUEST_METHOD"] == "POST") {
> $Number=$_POST['Number'];
> echo $Number;
> $Age[]=$_POST['Age'];
> $Height[]=$_POST['Height'];
>
> include ("../functions/db_conn.php");
>
> for ($i=0; i <= $Number; $i++) {
> $query="INSERT INTO Age(Age,Height)
> VALUES('$Age[$i]','$Height[$i]')";
> echo $Age[i], $Height[i];
> $result = mysql_query($query) or die('Query failed: ' .
> mysql_error());
> }
>
> There are two echo $Number commands, one is not pictured here as it is
> at the bottom of the page. Both of these confirm that $Number equals
> 2. I might try a while loop, to just see if that fixes anything. I
> don't know why this infinite loop just appeared.
>
Is the code cut and paste? its missing the $ off the i<= $Number
[Back to original message]
|