RE: [PHP-DB] Strange rawlist behaviour

From: Date: Tue, 07 Feb 2006 14:09:51 +0000
Subject: RE: [PHP-DB] Strange rawlist behaviour
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-41193@lists.php.net to get a copy of this message
$newdata = $contents[0]; for ( $i = 1; $i < count($array); $i++ ) {
      $current = $array[$i];
      $structure[$i]['name']  = substr($current, 55, strlen($current) - 0);
} Should the array loop thru start at 0 (below)? Not 1 as you have the starting value for $i (above) $newdata = $contents[0]; for ( $i = 0; $i < count($array); $i++ ) {
      $current = $array[$i];
      $structure[$i]['name']  = substr($current, 55, strlen($current) - 0);
Bastien
From: "Chris Payne" <chris@artistwd.com> To: <php-db@lists.php.net> Subject: [PHP-DB] Strange rawlist behaviour Date: Tue, 7 Feb 2006 01:52:26 -0500 Hi there everyone, Can anyone see a problem with the below code? It scans an FTP directory and adds the LAST item in that directory to the database (Being the latest item added) - however, if the directory only has 1 file in it it WON'T add anything, the system returns that the directory is empty and it's very frustrating. chris $conn_id = ftp_connect($ftp_server2); $login_result = ftp_login($conn_id, $ftp_user_name2, $ftp_user_pass2); // check connection if ((!$conn_id) || (!$login_result)) { die("FTP connection has failed !"); }; // Initiate passive mode if (ftp_pasv($conn_id, true)) { echo ""; } else { echo "Could not initiated passive mode<br><br>"; } // try to change the directory to somedir if (ftp_chdir($conn_id, "$newdir2")) { // echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; // get the file list for / $array = ftp_rawlist($conn_id, "-t"); $newdata = $contents[0]; for ( $i = 1; $i < count($array); $i++ ) {
       $current = $array[$i];
       $structure[$i]['name']  = substr($current, 55, strlen($current) - 0);
$newdatab = $structure[$i][name]; }}; // close the connection ftp_close($conn_id); };


« previous php.db (#41193) next »