RE: Strange rawlist behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$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@xxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Subject:  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);

};

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux