Tracing Includes


I’ve got some errors in my php_errors.log like this:

[09-Apr-2011 09:32:33] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/ on line 30

As suggested in the path, lib.php is an include, however I don’t know where it is being included! In fact, the errors are triggered when visiting a different domain hosted on our server. I’ve tried grep’ing for various strings in files under that domain, without success so far.

What would be really handy is a debug command I could stick somewhere that would print out the path & file that lib.php is included within, either in the php_error log or maybe there’s a line I can put within the function in lib.php where the error is triggered.

Any ideas?


Welcome to SitePoint. :slight_smile:

You could probably make some use of the [fphp]get_included_files[/fphp] function. Can you install xDebug or a similar tool on the server ? I also see some rather funky use of the CLI tool strace to track down something very similar once, maybe that’s an option.

OK thanks. get_included_files didn’t help in this case and I’d rather not install xDebug as it’s on a production server, but that strace command looks rather cool - I will have a play with that.

Many thanks :slight_smile: