cURL, PHP - loop in loop
I want something like this:

    $i = 1;
    $y = 1;
    
    while($i <= 10 and $y <= 5)
    {
    if($i==10)
    {
    echo 'I = '.$i.', Y = '.$y.'<br>';
    $i = 1;
    $y = $y+1;
    }
    else
    {
    echo 'I = '.$i.', Y = '.$y.'<br>';
    $i = $i + 1;
    }
    }

Which returns 

    I = 1, Y = 1
    I = 2, Y = 1
    ....
    I = 1, Y = 2
    I = 2, Y = 2
    ....
    I = 1, Y = 3
    I = 2, Y = 3

etc, etc, to use with cURL. But it doesnt work. What am I doing wrong?

    $i = 1;
    $y = 1;
    
    while($y <= 9)
    {
    while($i==499)
    {
    if($connection = db_connect()) 
    {
    $post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
    $str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
    
    $str2 = mysql_real_escape_string($str);
    $sql = "INSERT INTO abc (txt) VALUES ('$str2')";
    
    $i = 1;
    $y = $y+1;
    }
    else
    {
    echo 'Database connection error!';
    }
    }
    while($i != 499)
    {
    if($connection = db_connect()) 
    {
    $post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
    $str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
    
    $str2 = mysql_real_escape_string($str);
    $sql = "INSERT INTO abc (txt) VALUES ('$str2')";
    
    $i = $i + 1;
    }
    else
    {
    echo 'Database connection error!';
    }
    }
    }

But the page keeps loading and nothing happens. I have to use "if($connection = db_connect()){" but I think this is what keeps messing up my code. Can you look at it, please? Thank you.
cURL, PHP - loop in loop
===

I want something like this:

    $i = 1;
    $y = 1;
    
    while($i <= 10 and $y <= 5)
    {
    if($i==10)
    {
    echo 'I = '.$i.', Y = '.$y.'<br>';
    $i = 1;
    $y = $y+1;
    }
    else
    {
    echo 'I = '.$i.', Y = '.$y.'<br>';
    $i = $i + 1;
    }
    }

Which returns 

    I = 1, Y = 1
    I = 2, Y = 1
    ....
    I = 1, Y = 2
    I = 2, Y = 2
    ....
    I = 1, Y = 3
    I = 2, Y = 3

etc, etc, to use with cURL. But it doesnt work. What am I doing wrong?

    $i = 1;
    $y = 1;
    
    while($y <= 9)
    {
    while($i==499)
    {
    if($connection = db_connect()) 
    {
    $post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
    $str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
    
    $str2 = mysql_real_escape_string($str);
    $sql = "INSERT INTO abc (txt) VALUES ('$str2')";
    
    $i = 1;
    $y = $y+1;
    }
    else
    {
    echo 'Database connection error!';
    }
    }
    while($i != 499)
    {
    if($connection = db_connect()) 
    {
    $post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
    $str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
    
    $str2 = mysql_real_escape_string($str);
    $sql = "INSERT INTO abc (txt) VALUES ('$str2')";
    
    $i = $i + 1;
    }
    else
    {
    echo 'Database connection error!';
    }
    }
    }

But the page keeps loading and nothing happens. I have to use "if($connection = db_connect()){" but I think this is what keeps messing up my code. Can you look at it, please? Thank you.