Hi,
I'm creating an FTP script for uploading files... but now, when I pull out
the network plug of the server (so the connection is lost), my program
doesn't stop running... any ideas of how to check if a connection is still
alive?
Edward
// partial code:
for ($i=0; $i<mysql_numrows($query); $i++) {
$ip = mysql_result($query, 0, 'locatie.ip');
$titel = mysql_result($query, 0, 'locatie.titel');
$gebruiker = mysql_result($query, 0, 'locatie.gebruiker');
$wachtwoord = mysql_result($query, 0, 'locatie.wachtwoord');
$connid = ftp_connect($ip);
$login_result = ftp_login($connid, $gebruiker, $wachtwoord);
if (!$connid || ! $login_result) {
$error[] = array("con", "FTP connection failed at $titel ($ip) for
$gebruiker");
} else {
$query_ftp = mysql_query("SELECT * FROM bestanden WHERE
locatienummer='$locatienummer' && code != 'N'");
for ($j=0; $j<mysql_numrows($query_ftp); $j++) {
$id = mysql_result($query_ftp, $j, 'id');
$bestand = mysql_result($query_ftp, $j, 'path');
$code = mysql_result($query_ftp, $j, 'code');
$doel = eregi_replace("^$path/", "", $bestand);
ftp_chdir($connid, "~");
if (strtolower(substr($bestand, -3))=='txt' ||
strtolower(substr($bestand, -3))=='sca') {
$upload = @ftp_put($connid, $doel, $bestand,
FTP_ASCII);
} else {
$upload = @ftp_put($connid, $doel, $bestand,
FTP_BINARY);
}
if (!$upload) {
$error[] = array("upl", "Upload failed: $bestand, at:
$titel ($ip) for $gebruiker");
} else {
mysql_query("UPDATE bestanden SET code='N' WHERE
id='$id'");
}
}
if (!ftp_exec($connid, "NOOP")) {
/// ********* HERE I WANNA CHECK OF THERE IS A CONNECTION
/// ********* BUT IT LOOKS LIKE IT KEEPS TRYING TO SEND THE
FILES
/// ********* AND GETS STUCK IN THE ftp_put()'s ABOVE...
$error[] = array("lost", "Connection lost to $titel ($ip) for
$gebruiker");
break;
}
}
}
ftp_quit($connid);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php