View Full Version : Tracing fatal error in php
letom
04-06-2013, 12:48 PM
Is there any way to find the cause of FATAL ERROR in php in which File/Line ?
Beverleyh
04-06-2013, 01:38 PM
You can usually refer to the error log on your web host control panel.
jscheuer1
04-06-2013, 01:42 PM
Look at the error message, it will usually give you that information. Example (I've removed part of the path for security reasons):
Fatal error: Call to undefined function preg() in \demos\pdf\html2fpdf.php on line 463
Beverleyh
04-06-2013, 01:53 PM
John is correct although you might get a blank screen - I think it depends on the server config.
On both my web host's Apache servers I can edit the php.ini file so I get the on-screen errors as John advises. That makes for very convenient troubleshooting, but I also have an error log system that I can access if I log into my Control Panel. It's a pain that way but at least I can get to it the long way round if I need it.
However, on the Windows/IIS servers that I access at work, I get zilch - a blank screen with a generic 500 Internal Error message, and at that point I have to check the error log file - sometimes via a Control Panel, if I'm using a 3rd party service, but on the in-house servers I can just browse the mapped-drive folder structure to the actual error log file.
letom
04-06-2013, 05:37 PM
Hi John
Thanks for your message,
Yes i got that, but it is a function ( create_admin() ) and that function is written in some other file
Any idea to get the full details of that error interact with all pages (in which page this function is coded)..
letom
04-06-2013, 05:42 PM
On both my web host's Apache servers I can edit the php.ini file so I get the on-screen errors as John advises. That makes for very convenient troubleshooting, but I also have an error log system that I can access if I log into my Control Panel. It's a pain that way but at least I can get to it the long way round if I need it.
Thanks but iam using Wamp :)
I think fatal errors are hard to trace out
Beverleyh
04-06-2013, 06:03 PM
Im not sure what you mean by "trace out" but you can check the php.ini file in wamp and see where it is outputting the php_error.log file
jscheuer1
04-06-2013, 07:30 PM
Yes and you can set it (your php.ini) to report errors on screen. But from what you say, it looks like it already is. The php.ini file and PHP error log are both accessible from the Wamp server menu. Click on the Wamp server icon in your system tray or Win 7 hidden icons area. With Win XP, if you don't see the Wamp server icon, make sure that all tray icons are being shown, not just 'active' ones (it's a setting in XP accessible by right clicking on the system tray or menu bar). Once you click on the Wamp server icon and see its menu, hover over PHP, another menu will appear, from it click on the php.ini item or on the PHP error log item.
Getting back to the error itself, the error should have some explanation, a filename and a line number. Open that file and go to that line number. Something there should pop on a light bulb for you. It might not seem obvious, but if you search Google for the error explanation, something should click.
Now sometimes that won't work. Then you post about the specific error in the PHP forum here or in some other forum dedicated to the PHP script you're trying to run. Be prepared to provide a link to the live page and full source code of the server side files. If you cannot put it up live, make up a .zip file that has everything in it that someone would need to duplicate the error on their Wamp, or whatever server they're running it on. Make sure to include which PHP version you're using and exactly what you have to do to see the error. If it only happens sometimes, note that as well.
letom
04-07-2013, 04:36 AM
John
Thanks for your message.
My php error log file is displaying nothing, a blank one..
can u explain how to point errors to that file..(php error log )
My Apach Error log is displaying, same error what iam getting in browser...
Rgds
jscheuer1
04-07-2013, 05:17 AM
It doesn't matter which log it appears in, you aren't going to get any more information from Wamp about that particular error than was displayed in the browser.
You have to go to that line in that file that the error points to and see if you can figure it out.
If you want more help, we would need to see the exact error you are getting, copy and paste it here, as well as the file it points to. If the file is short you can paste its contents into a code block here. Otherwise, zip it up and attach it to a post. Since you said that the function that is mentioned in the error is defined in another file, we may need that too. We may even need other files, all the files required for us to run the code.
letom
04-07-2013, 07:04 AM
Thanks i don't think i can upload that contents and trace out the error by you, because it have 35 more files with 1000 of lines it's time wasting for you.
Any software avail to get detailed information about it
jscheuer1
04-07-2013, 09:47 AM
I haven't used any but Google:
https://www.google.com/search?client=opera&q=debugging+php+code
lists several.
letom
04-07-2013, 04:53 PM
Thanks dear..
I haven't used any but Google:
That means you cannot give assurance over that ?
jscheuer1
04-07-2013, 05:35 PM
That's right. You can click on some of the links. The one for Stack Overflow is a discussion. Folks in there seemed to prefer NetBeans. But I downloaded it once and didn't find it all that useful, or maybe it required something I didn't want to install, I'm not sure. But I never used it. There was another one in that discussion that was seen as favorable, I think it was PHPed or something like that. I'd never heard of it before.
There's also an add on for Chrome which looks promising. I may try that at some point as I like Chrome.
I rarely have an error in PHP that I can't figure out from the on screen error in the browser. If I do, I will use some of the more basic techniques mentioned in the Stack Overflow thread, like temporarily adding an echo or print_r to get the value of something at that point in the code that might be the problem. I might even have the PHP script write to a file at key points for diagnostics, so as to not disturb the script too much.
But usually just the error itself and its location in the code, perhaps with a little research on the error description, is enough for me to figure it out. Most often I see deprecated functions that are relatively easy to update (or in some cases just drop), that and syntax/spelling errors.
I think that using a PHP debug program requires that it be integrated into the server, and for most things seems to require an understanding of break points. Something I haven't gotten around to yet. I'm sure once I do I will find them useful. They're available for javascript debugging as well in some browser's developer tools. Generally I find that my knowledge of javascript allows me to spot things, often without even using the error/web console(s). It's like a sixth sense.
letom
04-07-2013, 05:48 PM
Yes Jon
I know it is a spelling error or may be a syntax.
There's also an add on for Chrome which looks promising. I may try that at some point as I like Chrome.
Can u tell me the name of that plugin?
letom,
I think we're at the point where no one will be able to help you further if you don't share the error message.
jscheuer1
04-08-2013, 04:06 AM
Yes Jon
I know it is a spelling error or may be a syntax.
Can u tell me the name of that plugin?
I was just saying what I usually find, and that (spelling/syntax) as well as the other things I mentioned, of course require no elaborate debugging program.
The Chrome plugin is called, PHP Console, and is located:
https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
It's like others though in that it needs to be configured to the server, and involves the use and understanding of break points for at least a part of its functionality.
letom
04-08-2013, 02:33 PM
Jon & Adrian
this is the error iam getting. can u explain these non-object / error?
Call to a member function makeAdmin() on a non-object
if u go to goog with this error you will only get a drupal result
Jon & Adrian
this is the error iam getting. can u explain these non-object / error?
Call to a member function makeAdmin() on a non-object
if u go to goog with this error you will only get a drupal result
That means that makeAdmin() is a method of a class, but the class isn't instantiated. For example:
<?php
# create a new object from myClass
$myObject = new myClass();
# use the myClass::someMethod()
$myObject->someMethod();
...but what if there was a problem creating the object? or you accidentally overwrite the variable? If something lie that goes wrong, then you're trying to use a method on an object (or not-an-object) that doesn't have that method:
<?php
# say you had a typo
$meObject->someMethod();
# Fatal error: call to member function someMethod() on a non-object
# or assigned the variable to something else
$myObject = "hello, world!";
$myObject->someMethod();
# Fatal error: call to member function someMethod() on a non-object
that's the kind of thing you need to be looking for.
letom
04-08-2013, 07:28 PM
Absolutely Mr Adrain :)... You gave a right support.
The fact is i overwrite a variable in all parts of my program ($entity) to ($myprojectname).. i missed one $entity in some where else in code.
Is changing the name of variable to a complicated name will provide any additional security to the application directly/indirectly ?
suppose $event is a common name , changing it to $eventyutr or something else...
Is changing the name of variable to a complicated name will provide any additional security to the application directly/indirectly ?
suppose $event is a common name , changing it to $eventyutr or something else...
yes and no... it makes conflicts less likely, but you still have to be careful.
glad that solved it for you!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.