sql query problems

A place for users and developers of the Xataface to discuss and receive support.

sql query problems

Postby entr04y » Mon Oct 12, 2009 3:34 pm

Hi all,

Having a problem with a sql query in an action:

This works:

$sql = "select mayor_name,city_name from cityinfo where county_name = 'some-county'";

This doesn't:

$sql = "select mayor_name,city_name,(round(sqrt((pow(( $x_pos - x_pos ),2) + (pow(( $y_pos - y_pos),2))))) as Distance from cityinfo where county_name = 'some-county'";

The error I get is:

[12-Oct-2009 18:37:25] PHP Fatal error: Call to a member function db() on a non-object in /ebs01/html/Salient/actions/neighbors.php on line 15


Any idea what is wrong with the above query? It executes as expected when cut and pasted directly into a mysql prompt (the only difference being $x_pos and $y_pos are changed to actual values in the mysql prompt.)

Thanks!
entr04y
 
Posts: 10
Joined: Thu Oct 08, 2009 6:44 am

Postby shannah » Wed Oct 14, 2009 12:03 pm

Before passing $sql into your query, echo the $sql and see what it says. Then you can put this sql directly into phpmyadmin and find out where the problem is (although it will probably be obvious by eyeballing it).

You might also try doing some error reporting because mysql will tell you want the problem is .

e.g.
$res = mysql_query($sql, df_db());
if ( !$res ) throw new Exception(mysql_error(df_db()));
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 29 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved