alwoodman Posted March 10, 2009 Share Posted March 10, 2009 Im trying to change permissions on files on multiple ftp connections I have a database of file names that i want to change and a list of domains to step through with the corresponding connection details (their all on the same server). Its processing the first connections files perfectly but when it comes to the next step in the loop (and the rest) its saying Warning: ftp_chmod() [function.ftp-chmod]: User myusername logged in in /var/www... above where it says User myusername logged in, it is the right username but is it somehow referencing the previous session somewhere? here's the code do { $ftp_server = "1.1.1.1"; $ftp_user = $row_get['ftp_username']; $ftp_pass = $row_get['ftp_password']; // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); // try to login if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected as $ftp_user@$ftp_server\n"; do { $newch = '0'.$row_getFiles['file_chmod']; if (ftp_chmod($conn_id, eval("return({$newch});"), $row_getFiles['file_name']) !== false) { echo "CHMOD successfull on ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>"; } else { echo "Could not CHMOD ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>"; } }while ($row_getFiles = mysql_fetch_assoc($getFiles)); } else { echo "Couldn't connect as $ftp_user\n"; } ftp_close($conn_id); echo "<b>- - - - - - - - - - - - -</b><br/>"; }while ($row_get= mysql_fetch_assoc($get)); } ?> Link to comment https://forums.phpfreaks.com/topic/148851-looping-ftp_connect-works-on-1st-connection-not-the-rest/ Share on other sites More sharing options...
WolfRage Posted March 11, 2009 Share Posted March 11, 2009 Probably not enough time to close the connection you might have to use sleep() to give it some extra time. Link to comment https://forums.phpfreaks.com/topic/148851-looping-ftp_connect-works-on-1st-connection-not-the-rest/#findComment-781846 Share on other sites More sharing options...
alwoodman Posted March 11, 2009 Author Share Posted March 11, 2009 Thanks Wolfrage, i added sleep(15); after the ftp_close but its still having the same problem... // try to login if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected as $ftp_user@$ftp_server\n"; do { $newch = '0'.$row_getFiles['file_chmod']; if (ftp_chmod($conn_id, eval("return({$newch});"), $row_getFiles['file_name']) !== false) { echo "CHMOD successfull on ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>"; } else { echo "Could not CHMOD ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>"; } }while ($row_getFiles = mysql_fetch_assoc($getFiles)); ftp_close($conn_id); sleep(15); regards Lee Link to comment https://forums.phpfreaks.com/topic/148851-looping-ftp_connect-works-on-1st-connection-not-the-rest/#findComment-781888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.