Discussion:
ftp_chdir notice error
Ron Piggott
2014-02-15 19:46:09 UTC
Permalink
I am using the result of “ ftp_chdir “ to know if the directory exists or not. If the result is “false” then I make the directory:

===
<?php

if ( ftp_chdir( $this->getFtpConnection() , $new_directory ) == FALSE ) {

if ( ftp_mkdir( $this->getFtpConnection() , $new_directory ) ) {
return TRUE;
} else {
return FALSE;
}

} else {
return TRUE;
}

?>
===

However when the result is ‘false’ a PHP warning is created: “ PHP Warning: ftp_chdir(): Failed to change directory “ How can I avoid this warning?

Ron

Ron Piggott



www.TheVerseOfTheDay.info
Stephen
2014-02-15 19:50:42 UTC
Permalink
However when the result is ‘false’ a PHP warning is created: “ PHP Warning: ftp_chdir(): Failed to change directory “ How can I avoid this warning?
Use the function file_exists.
--
Stephen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jigar Dhulla
2014-02-16 05:58:11 UTC
Permalink
"@" in the beginning of the function like *@ftp_chdir();* should suppress
the warning. Or you can use error_reporting();

error_reporting(E_ERROR | E_PARSE); should suppress the warning too.
I am using the result of " ftp_chdir " to know if the directory exists or
===
<?php
if ( ftp_chdir( $this->getFtpConnection() , $new_directory ) == FALSE ) {
if ( ftp_mkdir( $this->getFtpConnection() , $new_directory ) ) {
return TRUE;
} else {
return FALSE;
}
} else {
return TRUE;
}
?>
===
However when the result is 'false' a PHP warning is created: " PHP
Warning: ftp_chdir(): Failed to change directory " How can I avoid this
warning?
Ron
Ron Piggott
www.TheVerseOfTheDay.info
--
Regards,
Jigar Dhulla
Ron Piggott
2014-02-16 06:01:30 UTC
Permalink
I know about using “@” to suppress errors.

I want to know if it is possible to avoid causing the error altogether.

Ron Piggott


www.TheVerseOfTheDay.info


From: Jigar Dhulla
Sent: Sunday, February 16, 2014 12:58 AM
To: Ron Piggott
Cc: php-***@lists.php.net
Subject: Re: [PHP] ftp_chdir notice error

"@" in the beginning of the function like @ftp_chdir(); should suppress the warning. Or you can use error_reporting();

error_reporting(E_ERROR | E_PARSE); should suppress the warning too.



On Sun, Feb 16, 2014 at 1:16 AM, Ron Piggott <***@actsministries.org> wrote:


I am using the result of “ ftp_chdir “ to know if the directory exists or not. If the result is “false” then I make the directory:

===
<?php

if ( ftp_chdir( $this->getFtpConnection() , $new_directory ) == FALSE ) {

if ( ftp_mkdir( $this->getFtpConnection() , $new_directory ) ) {
return TRUE;
} else {
return FALSE;
}

} else {
return TRUE;
}

?>
===

However when the result is ‘false’ a PHP warning is created: “ PHP Warning: ftp_chdir(): Failed to change directory “ How can I avoid this warning?

Ron

Ron Piggott



www.TheVerseOfTheDay.info
--
Regards,
Jigar Dhulla
Jigar Dhulla
2014-02-16 06:10:28 UTC
Permalink
Okay. According to ftp_chdr(); that is an error. So i don't think you can
avoid that.

Other option is that you can use FTP Wrapper (
http://www.php.net/manual/en/wrappers.ftp.php ) is_dir();

like:
is_dir('ftp://user:***@example.com/some/dir/path');


On Sun, Feb 16, 2014 at 11:31 AM, Ron Piggott <
Post by Ron Piggott
I want to know if it is possible to avoid causing the error altogether.
Ron Piggott
<http://www.TheVerseOfTheDay.info>www.TheVerseOfTheDay.info<http://www.theverseoftheday.info>
*Sent:* Sunday, February 16, 2014 12:58 AM
*Subject:* Re: [PHP] ftp_chdir notice error
suppress the warning. Or you can use error_reporting();
error_reporting(E_ERROR | E_PARSE); should suppress the warning too.
On Sun, Feb 16, 2014 at 1:16 AM, Ron Piggott <
I am using the result of " ftp_chdir " to know if the directory exists or
===
<?php
if ( ftp_chdir( $this->getFtpConnection() , $new_directory ) == FALSE ) {
if ( ftp_mkdir( $this->getFtpConnection() , $new_directory ) ) {
return TRUE;
} else {
return FALSE;
}
} else {
return TRUE;
}
?>
===
However when the result is 'false' a PHP warning is created: " PHP
Warning: ftp_chdir(): Failed to change directory " How can I avoid this
warning?
Ron
Ron Piggott
www.TheVerseOfTheDay.info
--
Regards,
Jigar Dhulla
--
Regards,
Jigar Dhulla
Stuart Dallas
2014-02-16 07:08:04 UTC
Permalink
There is no equivalent to file_exists in the FTP function set, so you'll need to implement it yourself by listing the directory and checking for it yourself.


-Stuart



—
Sent from my leaf blower

On Sun, Feb 16, 2014 at 6:01 AM, Ron Piggott
Post by Ron Piggott
I want to know if it is possible to avoid causing the error altogether.
Ron Piggott
www.TheVerseOfTheDay.info
From: Jigar Dhulla
Sent: Sunday, February 16, 2014 12:58 AM
To: Ron Piggott
Subject: Re: [PHP] ftp_chdir notice error
error_reporting(E_ERROR | E_PARSE); should suppress the warning too.
===
<?php
if ( ftp_chdir( $this->getFtpConnection() , $new_directory ) == FALSE ) {
if ( ftp_mkdir( $this->getFtpConnection() , $new_directory ) ) {
return TRUE;
} else {
return FALSE;
}
} else {
return TRUE;
}
?>
===
However when the result is ‘false’ a PHP warning is created: “ PHP Warning: ftp_chdir(): Failed to change directory “ How can I avoid this warning?
Ron
Ron Piggott
www.TheVerseOfTheDay.info
--
Regards,
Jigar Dhulla
Maciek Sokolewicz
2014-02-16 10:58:33 UTC
Permalink
Post by Jigar Dhulla
the warning. Or you can use error_reporting();
error_reporting(E_ERROR | E_PARSE); should suppress the warning too.
This is a really *BAD IDEA* (tm), you should always try to resolve an
error rather than just ignoring it. Good code almost never contains the
error-suppression operator (@).

On a sidenote, your error_reporting line is faulty. It's impossible to
stop E_PARSE errors from being displayed by adding an error_reporting
line inside a PHP script. This is simply because PHP first parses the
script (and immediately throws an E_PARSE error); and only if it has no
errors will it execute it and run your error_reporting line. In other
words: by the time it runs the error_reporting line, it's already to
late (although in practice with an E_PARSE error it will never even
reach that point).

- Tul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Search results for 'ftp_chdir notice error' (Questions and Answers)
6
replies
Urgent!! Help me copy some text from webpage?
started 2006-05-23 11:51:40 UTC
internet
Loading...