PDA

View Full Version : help with php troubleshooting



natronp
June 29th, 2009, 08:42 PM
i'm getting a timeout error in a php script that saves a .csv file to the server and then loops through it to populate a database table:


PHP Warning: file(http://www.mydomain.com/myfile.csv): failed to open stream: Connection timed out in myphpfile.php on line 10

line 10 looks like this:


$lines = file($url_path.'/admin/lists/'.$new_file_name);

the following line (11) throws an error as well (because of the timeout) and this code is unable to execute:


foreach($lines as $key=>$val) {
//echo "$key -> $val ++<BR><BR>";
$accountArray = explode(",", $val);
$arraySize = sizeof($accountArray);
//echo "$key -> $val -> $arraySize +++<BR>";
$accountNumber = $accountArray[0];
if ($arraySize == 2) $accountName = $accountArray[1];
else {
array_shift($accountArray);
$accountName = join(",", $accountArray);
}
$accountInsert = "INSERT INTO accounts SET accountNumber = '$accountNumber', accountCompany = '".addslashes($accountName)."'";
//echo "$accountInsert ++<BR><BR>";
$accountResult = mysql_query($accountInsert);
}

If i check the server the file is being uploaded correctly and has permissions set to 777. what could be causing the timeout? what should i check next?

thanks for any help!

bassmansg
June 30th, 2009, 09:35 AM
Could possibly be the servers timeout variable is set too low.

http://www.php.net/set_time_limit

Nevo
July 9th, 2009, 07:24 AM
Why not answer it here?
Then if people in the future have the same issues they can use your advice/solution.