Jump to content


Photo

PHP Error Messages


  • Please log in to reply
5 replies to this topic

#1 AmbroseChapel

AmbroseChapel
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 August 2006 - 02:36 AM

Hi, I'm very much out of practice with PHP (more used to Perl) and I need some help on error messages and functions.

I'm used to doing something like

open(FILE,'>something.txt') || die "$!";

in Perl and having my code die with something useful in the output. I also use CGI::Carp's 'fatalsToBrowser' a lot to get output to the browser when something goes wrong.

When I'm coding now in PHP and something's wrong, I get blank output in the browser and no hint of where to start. I can get the line number from __LINE__ but not the error message from the function.

What do I have to do to see warnings and errors, as in for instance the above example -- I was doing imagejpeg() output to a file and it didn't get written but I couldn't figure out why not. (Safe mode problems, it turns out, see the Manual, http://au.php.net/ma...ejpeg.php#58391)

Apologies if this question has a very obvious answer. I have done some searching, honestly!

#2 dsartain

dsartain
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 10 August 2006 - 02:44 AM

Check to see if you have an '@ ' before your statements and such...PHP uses that to hide the output so designers can place custom errors there.  Hope this helps...if not, email me at dsartain18@yahoo.com and I'll see if I can figure anything out...

#3 AmbroseChapel

AmbroseChapel
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 August 2006 - 03:55 AM

No there definitely isn't an at-symbol before the function.

Take this as an example:

imagejpeg($object,'img/image.jpg');

if I can't write to "img" because there's a permissions problem. How will I know it's a permissions problem?

Doesn't the imagejpeg() function return "insufficient permissions" or "Error writing file" or just zero?

And how can I grab that error message?

#4 DillyDong

DillyDong
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 10 August 2006 - 03:58 AM

Hopefully this will remedy the problem:

http://us3.php.net/error-reporting

#5 AmbroseChapel

AmbroseChapel
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 August 2006 - 12:56 AM

OK I figured out that my hosting provider has got their "display_errors" set to "Off" in the shared php.ini, and what I did was use this to turn errors back on:

  error_reporting ( 4096 );
  ini_set ( display_errors, 1 );

which seems to be what I wanted.

Here's another question -- when I try to print out to the browser any variable from $_POST or $_GET my script silently dies, even with the error setting above. I'm guessing this is a security measure? It's very confusing. How can I get around that?


#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 11 August 2006 - 01:01 AM

Here's another question -- when I try to print out to the browser any variable from $_POST or $_GET my script silently dies, even with the error setting above. I'm guessing this is a security measure? It's very confusing. How can I get around that?


That sounds like either a script problem or time to dump your host.  Post some of your 'non-working' code that declines to echo $_POST variables.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users