View Single Post
Old 06-21-2011, 11:15 AM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,515
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by bullant View Post
I find the easiest and quickest way to check what the actual query about to be run is, is to echo it to the browser and syntax errors should then be fairly obvious.

For more complex queries a good practice imo is to first get the query working in the SQL GUI of your choice and then transfer the query to your server side script.
I agree I frequently test SQL through phpmyadmin to see if it will work as expected and I always use mysql_error() where appropriate too.

It was rather late at night when I created this tip for the noobs so it's not perfect and the SQL was taken from another topic here as it looked like a good example to demonstrate with. Obviously in hindsight I may have got that wrong but hey ho I tried!
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote