Forum Moderators: coopster

Message Too Old, No Replies

How do you debug your MySQL query

could we gather a few tips

         

henry0

11:47 am on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Echoing a query:
I like echoing the query and run it for example in phpMyAdmin

Spell-check:
Don’t think "big deal!..."
Yesterday I spent one hour rebuilding, changing, simplifying a query, going to the manual, books etc. to finally figure that update was spelled “UDATE” :)

[edited by: henry0 at 11:52 am (utc) on Aug. 28, 2007]

benevolent001

11:50 am on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does using professional Php editor like zend help out in debugging and releasing your work pressure

Habtom

1:25 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just like you mentioned, I do echo the sql query and test run it on phpMyAdmin.

jatar_k

1:57 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



construct your query into a variable and then use that variable in your mysql_query call, this allows you to echo your query

use an or die statement on your mysql_query call so that the real error is returned from mysql

add a die right after your query to not have all the other processing confusing the issue, isolate the problem

you can also add a simple while to show you whether your query is returning the proper data, though if you just build your query at the command line or some other tool this is unnecessary

RonPK

8:39 pm on Aug 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah,
mysql_error()
is usually spot-on about syntax errors.