Well player.php is a script that generates some random numbers & other similar work & also calls the skill_brkdwn.php script.
At the end of all of the processing in player.php & the included skill_brkdwn.php it then inserts a row into the database. It works fine when calling player.php directly because it is only processing one time, but when I run it in the loop in doesn't work.
One thing more that I found out because I had the mysql_errno commented out is that it is trying to insert the first row 9 more times & the database gives a '1062: Duplicate entry' error because I have a unique index on three of the columns in the table.
Below is the code to all of the scripts invloved in this routine:
[B]load_players.php[/B]
<?
include 'db_vars.php';
for($a=0; $a<10; $a++)
{
include 'player.php';
}
?>
[B]db_vars.php[/B]
<?
$dbuser = 'xxxxxxxx';
$dbhost = 'localhost';
$dbpass = 'xxxxxxxx';
$dbname = 'hawghats_football';
$mysql_link = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
?>
[B]player.php[/B]
<?
srand(time());
for ($i = 0; $i < 6; $i++)
{
$rnum[$i] = (rand(10,99)%100)+1;
$tmpvar = $rnum[$i];
for ($count = 0; $count < $i; $count ++)
{
if ($tmpvar == $rnum[$count])
{
$rnum[$count] = (rand()%100)+1;
$count = 0;
}
}
}
$first_name_id = (rand(1,1219));
$last_name_id = (rand(1,32767));
$month = (rand(1,12));
if ($month == 2) {
$day = (rand(1,28));
}
elseif (($month == 4) || ($month == 6) || ($month == 9) || ($month == 11)) {
$day = (rand(1,30));
}
else {
$day = (rand(1,31));
}
$pos = (rand(1,10000));
$age = (rand(1,10000));
$query = "SELECT first_name FROM first_name where id=$first_name_id";
$query_result_handle = mysql_query ($query) or die($query."<br>Error:".mysql_error());
$query2 = "SELECT last_name FROM last_name where id=$last_name_id";
$query_result_handle2 = mysql_query ($query2) or die($query2."<br>Error:".mysql_error());
$query3 = "SELECT position FROM position where id=$pos";
$query_result_handle3 = mysql_query ($query3) or die($query3."<br>Error:".mysql_error());
$query4 = "SELECT age FROM age where id=$age";
$query_result_handle4 = mysql_query ($query4) or die($query4."<br>Error:".mysql_error());
while ($row = mysql_fetch_row ($query_result_handle))
{
$final_first=$row[0];
}
while ($row2 = mysql_fetch_row ($query_result_handle2))
{
$final_last=$row2[0];
}
while ($row3 = mysql_fetch_row ($query_result_handle3))
{
$final_pos=$row3[0];
include ('skill_brkdwn.php');
}
while ($row4 = mysql_fetch_row ($query_result_handle4))
{
$final_age=$row4[0];
$year_final=(2002 - $final_age);
$dob = $year_final."-".$month."-".$day;
}
$result=MYSQL_QUERY("INSERT INTO players VALUES ('','$final_first','$final_last','$dob','','$final_pos',$final_sp,$final_ac,$final_ag,$final_st,$final_ha,$final_en,$final_in,$final_di)");
echo mysql_errno().": ".mysql_error()."<BR>";
?>
I couldn't include the skill_brkdwn.php because of the message length limit. I will reply to this reply immediately with the code in it.