1

When we want to display error from mysqli we use this example:

$result = $this->mysqli->prepare($query) or die ("Mysqli Error: " . $this->mysqli->error);  

Which in case of error might say something like:

Mysqli Error: Unknown column 'bla' in 'where clause'

Is there a way to show from which source file this error is coming from?

Toniq
  • 4,492
  • 12
  • 50
  • 109

1 Answers1

-1

You could use the __FILE__ constant. If you want to be even more precise you could also add the line with __LINE__.

__FILE__

The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.

php manual

So your code-example would look like this:

$result = $this->mysqli->prepare($query) or die ("Mysqli Error: " . $this->mysqli->error 
        . "\n File:". __FILE__ . ", Line:" . __LINE__);
kyeiti
  • 376
  • 2
  • 6