Jump to content

[SOLVED] Enable PHP error output


leesiulung

Recommended Posts

I'm working on a shared hosting environment where it appears error messages are not displayed. Is there a way to enable this through code?

 

I do not have access to the control panel or anything of that nature. All I got is a username, password and ftp address.

 

Help would be appreciated as this is frustrating... not knowing what is wrong.

Link to comment
Share on other sites

Actually the showing of error message is just temporarily, so I can debug it. I need to identify what line there is problem with.

 

I don't want to test it on my environment and then test it on the live server (that isn't really live)....

 

To clarify I want to see errors in my code from server i.e. missing semicolon, syntax errors or runtime errors.

Link to comment
Share on other sites

Write error_reporting(E_ALL ^ E_NOTICE); at the first line of the page.

 

That should work, but it did not. I also tried:

 

error_reporting(E_ALL | E_NOTICE);

 

Still nothing being displayed. Any ideas why or any other ideas?

 

Thanks,

Link to comment
Share on other sites

Just setting error_reporting to E_ALL it does not force PHP to display errors. In order to get PHP to display any errors you must enable the display_errors setting in the php.ini

 

When you change anything in the php.ini make sure you save it and restart your http server(Apache, IIS etc).

Link to comment
Share on other sites

You can try this going along with what Wildteen said:

 

<?php
ini_set('display_errors', 1);
?>

 

http://us2.php.net/manual/en/function.ini-set.php

 

Not sure if this would work, but it is worth a shot. Chances are the host diabled that option.

 

Another option might be to create an .htaccess that does a similiar thing to ini_set.

Link to comment
Share on other sites

You can try this going along with what Wildteen said:

 

<?php
ini_set('display_errors', 1);
?>

 

http://us2.php.net/manual/en/function.ini-set.php

 

Not sure if this would work, but it is worth a shot. Chances are the host diabled that option.

 

Another option might be to create an .htaccess that does a similiar thing to ini_set.

 

I tried setting:

 

ini_set('display_errors', 'on');

 

Did not work and so I reread your post and tried:

 

ini_set('display_errors', '1');

 

Worked, and displayed unknown function errors, but does not display syntax errors of this kind:

 

$str = 'a' 'b'; // missing concatenate operator

$str = 'c' . 'd' // missing semicolon

 

This is quite frustrating.

 

I am telling you guys, this dude is trying to hack!!

Read is other post if you don't believe me.

 

This guy is plain annoying yet amusing.... I'm not going to even respond to this....

 

I appreciate all the posts genuinely trying to aid me, instead of accusing though! That last one almost worked.

Link to comment
Share on other sites

After you set the display errors set the error level to show what you want.

 

as for this:

 

$str = 'a' 'b'; // missing concatenate operator
$str = 'c' . 'd' // missing semicolon

 

The last semicolon is assumed. Try this instead

 

$str = 'a' 'b'; // missing concatenate operator
$str = 'c' . 'd' // missing semicolon
$str = 'test me!';

 

And see what happens.

Link to comment
Share on other sites

semicolons are also assumed!!! That is terrible  >:(

 

Anyhow, here is the code I used:

 


ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
phpinfo();

$str = 'a' 'b'; 
$str = 'c' . 'd' 
$str = 'test me!';

 

I still got a blank page and the phpinfo() did not display. How do I set the error level? I can't find any info on error_level by searching other than error_reporting();

Link to comment
Share on other sites

You can use .htaccess to do a php_ini portion to set error levels.

 

http://www.evolt.org/article/Make_your_PHP_code_portable/17/28117/index.html

 

That site might help you out.

 

I'm so close to being done that I might just go on without the proper error reporting. However, I will take a look at that link and mark this thread solved. Just don't ever get hosting with SBC....  >:(

 

Frost110, I appreciate your continued help on this. Thanks!!!  :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.