note 48698 added to function.mysql-error

From: Date: Wed, 05 Jan 2005 08:53:45 +0000
Subject: note 48698 added to function.mysql-error
Groups: php.notes 
Request: Send a blank email to php-notes+get-82733@lists.php.net to get a copy of this message
My suggested implementation of mysql_error(): $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); This will print out something like... <b>A fatal MySQL error occured</b>. Query: SELECT * FROM table Error: (err_no) Bla bla bla, you did everything wrong It's very useful to see your query in order to detect problems with syntax. Most often, the output message from MySQL doesn't let you see enough of the query in the error message to let you see where your query went bad- it a missing quote, comma, or ( or ) could have occured well before the error was detected. I do -not- recomend using this procedure, however, for queries which execute on your site that are not user-specific as it has the potential to leak sensative data. Recomended use is just for debugging/building a script, and for general user-specific queries which would at the worst, leak the users own information to themself. Good luck, -Scott ---- Manual Page -- http://www.php.net/manual/en/function.mysql-error.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48698 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48698&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48698&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82733) next »