Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
05-16-2013, 05:56 PM #1
- Join Date
- Apr 2010
- Thanked 0 Times in 0 Posts
Am I going crazy or is there something else wrong?
I have this:
$qry_city = "select * from " . CITY . " where `country_id`='$row_country[id]' order by `city_name` ASC"; $rs_city = mysql_query($qry_city);
Just checking there is nothing wrong with the above code first before I start pulling apart every other piece of the page!
05-16-2013, 09:16 PM #2
How can we tell, without seeing your schema and some sample data?
But offhand I see two things about that query that worry me:
(1) You are specifying the name of the TABLE by means of ... what?
CITY isn't a PHP variable, so what is it?
And in any case, why is it dynamically specified? PLEASE don't tell us you have more than one table of ctiy_name's.
(2) You are limiting the selection to one country, good. You are using a country *apparently* obtained in another query. Probably bad. Probably you should be using *ONE* combined query, not two separate ones.
In any case: DEBUG DEBUG DEBUG!!!!
Look at the DEBUG output. Copy/paste the query, as you see it in the DEBUG output, to your favorite MySQL tool (phpmyadmin, or whatever you use). Execute it in the tool. Do you still see the same strange results?Code:$qry_city = "select * from " . CITY . " where `country_id`='$row_country[id]' order by `city_name` ASC"; echo "DEBUG SQL: " . $qry_city . "<hr/>\n";
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.