I am having problems inserting data into a database using the following code
for ($z=0; $z < $total; $z++)
{
$testsql = "INSERT INTO news (country, date, body, href, source, distype) VALUES ('$country_select[$z]', '$date_array[$z]', '$body_array[$z]', '$href_array[$z]', '$news_array[$z]', '$distype')";
echo "result $z successful<br>";
$result = mysql_query($testsql) or die ('error message goes here');
}
the problem is it usually craps up and c omes up with the "error message goes here" after it loops once or twice. I have checked the array's and they all have the correct data and match up (ie, date_array[1] matches with body_array[1] and so on). Any idea what is going on? It seems totally random..sometimes it will loop 1 time..sometimes 3 times. Is there something wrong with looping the way I am?