Debug MySQL Queries
do_query() is a replacement for mysql_query in PHP, providing help with debugging of MySQL queries, and notification from your site when something goes wrong.

To call it, you replace the “mysql_query” function call with “do_query” function call, and add “__LINE__” towards the end. The addition of the “__LINE__” variable at the end of the call means that rather than needing to hunt through an entire script once the system has informed you of an error, you can see exactly where it is called from.

$result = mysql_query(”SELECT * FROM table”);

$result = do_query(”SELECT * FROM table”, __LINE__);

The other purpose of do_query is to aid in debugging of script that isn’t behaving itself, specifically by actually showing any queries on the page itself. Simply add “debug=1″ to your querystring, and any query executed on the page using do_query will be displayed, along with the number of results returned.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.