Forum Moderators: coopster

Message Too Old, No Replies

how to show mysql error message

         

topr8

11:03 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



situation: local test server
problem: mysql error messages are not being written to the page.

am banging my head over this, previously they were showing, however now they are not, if there is a mysql error the page is returned blank by the browser!
php error messages are shown in the browser no problem

perhaps i've inadvertantly changed a setting but i cannot think what!

any ideas?

thanks

vincevincevince

11:17 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your PHP has been upgraded, you may have more current settings. It is now advised that all errors are only viewable in the error log, due to the amount of information they might make available to hackers.

Try checking your error_log, and make a habit of using this instead of looking for on-page errors if you can.

topr8

11:42 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yes i hear what you're saying but this is a test server locally based and it is much more convenient to check errors in the browser, and i would like to continue doing so!

of course on a live site all error messages should be switched off from being sent to the browser.

Frank_Rizzo

11:54 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds like you have a syntax error which is throwing php rather than a mysql error.

e.g. something like

$result = @mysql_query("SELECT date, id')

Check your php / httpd error log as blank pages are usually due to php not being able to complete.

Another gotcha to watch out for is the @mysql... The @ symbol will suppress on screen error reporting. Try

$result = mysql_query("SELECT date

jatar_k

12:40 pm on Jun 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



take a look at the 'display_error' setting in your php.ini, it should be set to on

eelixduppy

1:06 pm on Jun 20, 2007 (gmt 0)



To show the errors from mysql you are going to have to use mysql_error [php.net]. So something like this is generally used:

$result = mysql_query($query) or die(mysql_error());

Obviously you should not leave this in there for a production site.