Jump to content
MakeWebGames

Error Messages


newttster

Recommended Posts

Hey folks.

I've tried repeatedly to get error messages to show on a game that I'm working on. You know those messages that say something like "unexpected { or ;". Those kinds of messages. For that matter, I'm not getting any of the error messages to popup.

When there is an error in the code, I'm just getting a blank white screen. Now, if it's a minimum number of lines of code, it's usually easy enough to find, right. But when you have a lot of lines of code, you can spend hours by blocking certain code, trying it, then unblocking the next and so on to find the error.

Any ideas on what I can do to get this to work? Any help/suggestions would be greatly appreciated. Thanks a bunch.

Link to comment
Share on other sites

At the top of globals.php and globals_nonauth.php, add
 

ini_set('display_errors','On');
error_reporting(E_ALL & ~E_NOTICE);

If that doesn't work, and you have SSH access, I'd recommend installing the Composer package filp/whoops. 3 lines later, and you've got all the information you need.
I'd also recommend caution when using this as the default setup will expose raw code (perhaps lock the handler registration to your own ID/staff rank?)

If you don't have SSH access, or composer isn't an option, then check the Error Log. If the server on which the site is hosted is using cPanel, the Error Log can be easily accessed directly from within.
If that's not an option, then a logfile should be available within your system. Without knowing more about your setup, I can't really advise further

  • Like 2
Link to comment
Share on other sites

unexpected { or ; are pretty much game over as far as PHP is concerned and while logs help, packages have limited use here as syntax errors often prevent them from operating. I would suggest that any changes where you may be unsure you test locally. Assuming your local system works ... (you are testing aren't you?) ... then there should not be a problem - negating minor version differences in OS/PHP version etc. Next is to run your files through php -l:

find . -iname "*php" -exec php -l {} \;

this will point any any syntax errors in your code along with a handy line number that suggests where the problem is. You can also run this on a file-by-file basis with

php -l <filename>.php

If you are using git, it is possible to add this as a pre-commit hook which can save a few headaches.

  • Like 1
Link to comment
Share on other sites

13 hours ago, newttster said:

Hey folks.

I've tried repeatedly to get error messages to show on a game that I'm working on. You know those messages that say something like "unexpected { or ;". Those kinds of messages. For that matter, I'm not getting any of the error messages to popup.

When there is an error in the code, I'm just getting a blank white screen. Now, if it's a minimum number of lines of code, it's usually easy enough to find, right. But when you have a lot of lines of code, you can spend hours by blocking certain code, trying it, then unblocking the next and so on to find the error.

Any ideas on what I can do to get this to work? Any help/suggestions would be greatly appreciated. Thanks a bunch.

Use PHPStorm and you'll have less as it highlights them magically!

  • Like 1
Link to comment
Share on other sites

My learned friend above is quite right; using PHP Storm can be a lifesaver in reducing the number of bugs reaching production; although I'd still point out that testing is ultimately key as many errors have been seen that escape Storm's otherwise beady eye.

Test, test and test again. Use PHPUnit for writing tests; use Xdebug for profiling your application; between the two you can produce test coverage in excess of 100% which makes future modifications, upgrades, additions etc a lot safer.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

I'm still having the same problem with white pages when there's an error.  And yeah ... I'd like to get PHPStorm but I'm not paying $199 USD for it. I'd rather throw $20 or $30 or some agreed upon price to someone here who is trustworthy to set it up for me. Annnddd ... I really like Notepad++. 

So ... Anyone interested? Message me. Thanks. 🙂

 

Edited by newttster
Link to comment
Share on other sites

On 5/14/2021 at 11:23 AM, AdamHull said:

Check your apache2 or nginx error logs this will tell you why you have a white page 

I've looked everywhere for those error logs and I can't find them. Where do I find them?

 

On 5/14/2021 at 1:17 PM, Sim said:

I use notepad++ myself.

It doesn't let me down. Except for those pesky white page errors.

 

So ... is anyone interested in setting things up so that the error messages display instead of me getting a blank white page? I'd be willing to pay you for your time. Let me know it private message. Thanks all.

 

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...