• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

PHP Errors or Warranings

Is there any way to control how PHP handles errors?

im getting "Warning: ftp_get() [function.ftp-get]: IDX_2/pics-residential-20090415.tar: No such file or directory in /php/databasePopulate.php on line 73
File does not exist"

When i get the warring the script dies.
I need the script to complete even if the the file is not on the server.

Thanks!
0
Cybervanes
Asked:
Cybervanes
  • 3
  • 2
  • 2
2 Solutions
 
LordOfPortsCommented:
Consider changing the code to use the file_exists http://us2.php.net/file_exists function so you first check if the file exists then if it does call the ftp_get function and if it does not you simply proceed with the remainder of the script without calling ftp_get.

You can use the error_reporting http://us.php.net/manual/en/function.error-reporting.php function to fine tune what you would like PHP to display on the screen but the first approach I mentioned above is the proper technique.
0
 
aldanchCommented:
That function returns true or false. I have never used it but could you just do something like this?
if(ftp_get(...)) {
     echo "Got it.";
} else {
     echo "Failed.";
}

Open in new window

0
 
CybervanesAuthor Commented:
aldanch:
what you suggested is exactly what I'm using, and it kills the script with out executing the else{} statement.

LordOfPorts:
im still unclear on how to query a different server via ftp using if(file_exists()){}.

any other ideas?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
aldanchCommented:
What happens when you suppress the error using this?


@ftp_get(...)

Open in new window

0
 
CybervanesAuthor Commented:
aldanch:
worked perfectly!!

what dose the @ symbol do or what dose it stand for?

I'm still a bit green with php
0
 
aldanchCommented:
The @ symbol is an error/warning suppressor :)

Glad I could help!
0
 
LordOfPortsCommented:
You can also suppress warnings through the error_reporting http://us.php.net/manual/en/function.error-reporting.php function, e.g. at the top of your page place:

// This way no warnings would be shows, this could be used for production
error_reporting(E_ERROR | E_PARSE);

// - OR

// Disable all errors/warnings/etc.
error_reporting(0);

// In development you do want to see all issues
error_reporting(E_ALL);

If you add @ in front of functions it does silence the warnings but presents an issue when you develop as you might not see problems beforehand.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now