PDA

View Full Version : mysql errors will NOT display



Alx
07 May 2009, 12:13 PM
my PHP pages are NOT displaying any mysql errors, making it very hard to debug.

i am not connected to a local db. i am connected to an external db through an IP. im sure this has something to do with it.

i put this code in to get PHP to show up, but still no mysql errors.


ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);

any ideas?

Alan
07 May 2009, 06:44 PM
Are you using the mysql/mysqli extension to connect to the database?

If so you can simply output mysql errors using the mysql_error() / mysqli_error() functions. Depending on the extension you are using. I am not familiar with the way you are doing it (it appears somewhat correct according to the php.net website), but I rather report errors when they happen mid-script.




// Procedural Style
if(!$connection = mysqli_connect($host,$user,$pass,$name))
echo mysqli_error($connection);

// Object Oriented Style
if(!$database = new mysqli($host,$user,$pass,$name))
echo $database->error();