svgmx5 Posted February 5, 2011 Share Posted February 5, 2011 Hey everyone, im having problems querying the results from the database using this query.... $get_points = mysql_query("SELECT * FROM points WHERE ACOS( (SIN(PI() * '41.896301269531' / '180') * SIN(PI() * latitude / '180')) + (COS(PI() * '41.896301269531' /'180') * COS(PI() * latitude / '180') * COS(PI() * longitude / '180' - PI() * '-88.744201660156' / '180')) )* '180' / PI() * '60' * '1.1515' <= '80'") or die(mysql_error()); Basically what it does it checks the for location with in 80 miles of the lat and long coordinates. The problem is no result are showing up. I know there are locations because i tested this as an sql code in my database and it ran perfectly, but i can't get it to work using php.. I get no errors, nothing. can anyone help me out? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Where's the rest of it? There's nothing there that would show any results. Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 5, 2011 Author Share Posted February 5, 2011 Heres't the table that should hold the results, along with the rest of the code <table width="604" cellspacing="0" cellpadding="5" border="0" id="home-listing"> <tr class="tb-heading"> <td width="171"><strong>Building Name</strong></td> <td width="147"><strong>Architecht</strong></td> <td width="66"><strong>Date</strong></td> <td width="97"><strong>Building Type</strong></td> <td width="73"><strong>Style</strong></td> </tr> <?php $get_points = mysql_query("SELECT * FROM points WHERE ACOS( (SIN(PI() * '41.896301269531' / '180') * SIN(PI() * latitude / '180')) + (COS(PI() * '41.896301269531' /'180') * COS(PI() * latitude / '180') * COS(PI() * longitude / '180' - PI() * '-88.744201660156' / '180')) )* '180' / PI() * '60' * '1.1515' <= '$radius'") or die(mysql_error()); $num_of_records = mysql_num_rows($get_points); if($num_of_points!=0){ while($points = mysql_fetch_assoc($get_points)){ ?> <tr> <td><?php echo $points['name'] ?></td> <td></td> <td><?php echo $points['date'] ?></td> <td>Residential Multi- Family</td> <td>Modern-Expresionist</td> </tr> <?php } }else{ ?> <tr> <td colspan="5">NO results found</td> </tr> <?php } ?> </table> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 That's a different query string. The one you posted first had no variables in it. How do you expect to get help if you don't post the actual code that's producing the problem? Remove the query string from the query execution, form it in a variable and echo it to make sure the variable holds the value that you'd expect it to hold. $query = "query string"; echo $query; $get_points = mysql_query($query) or die( mysql_error() ); Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 5, 2011 Author Share Posted February 5, 2011 well i'm sorry about my small mistake..... anyways even with or with out the variables there is nothing..and just to clear it up i had left a variable in there but then removed it to test it.. My point is i tested it with out variables so the '$radius' variable is not there its '80' an actual number Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 So you're saying the actual query string is the original one you posted, and it executes and returns results in phpMyAdmin, but not when executed in a php script? Do you have error_reporting = -1 and display_errors = On in your php.ini file? Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 5, 2011 Author Share Posted February 5, 2011 i figured it out..it was the smallest of mistakes and i can't believei missed it... $num_of_records = mysql_num_rows($get_points); if($num_of_points!=0){ } Those 2 lines where way different..... I'm sorry for t his ppl and thank you for your help Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 5, 2011 Author Share Posted February 5, 2011 and yes the actual query was the first one, i was testing it with variables and thats the on i posted secondly..with out removing the variable Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.