echo($sql);
Moderator: General Moderators
echo($sql);
I see some php page, on some page I can use echo($sql) to see what is wrong in my php, but sometimes the echo($sql) did not get display , why? and how to temp to let the echo work??
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: echo($sql);
It depends what value is inside $sql. Another option is to use die() along with the mysql_error() function. On failure, the sql error (if any) that caused the problem will be displayed. Error reporting can take on many forms but whatever the chosen method, it is a must when developing an application / script.
Code: Select all
<?php
// look for a field that doesn't exist in the table
$qry = "SELECT unknownFld FROM table";
$sql = mysql_query($qry) or die(mysql_error());
// returns 'Unknown column 'unknownFld' in 'field list'
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: echo($sql);
thank you for the reply, ther is one of the possible reason. but I still don't understand ,if not error , I still be able to print out the who sql syntax out is that right , I still don't get why something I don't get the print out , when I use echo, is header("Location: somefile) or require cause the problem??
Re: echo($sql);
Can you show us an example of where it isn't working?