Anakin Posted October 1, 2006 Share Posted October 1, 2006 HiWould someone please be able to shed some light on the following script.I am trying to achieve 2 things.(1) Correct error message.(2) Also, return results in alphabetical ORDER.Any help or suggestions would be appreciated.Thanks!_________________________________________________________<?php// Connect to the database.include_once("config.php");$country_id = $_GET[country_id];$result = mysql_query("SELECT city_id, City FROM city WHERE country_id =".$country_id);// Output XML document.echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<menu>'; echo '<menu-title label="menu">';echo '<menu-item label="Select City ..." />';[color=red]while($row=mysql_fetch_array($result)){[/color] $line = '<menu-item data="'.$row[city_id].'" label="'.$row[City].'"/>'; echo $line;}echo '</menu-title>';echo '</menu>';?>________________________________________________________[color=red]<?xml version="1.0" encoding="UTF-8" ?> - <menu>- <menu-title label="menu"> <menu-item label="Select City ..." /> <br /> <b>Warning</b> : mysql_fetch_array(): supplied argument is not a valid MySQL result resource in city.php</b> on line <b>14</b> <br /> </menu-title> </menu>[/color]_________________________________________________________ Quote Link to comment https://forums.phpfreaks.com/topic/22649-help-needed-solved/ Share on other sites More sharing options...
wwfc_barmy_army Posted October 1, 2006 Share Posted October 1, 2006 Try the following line for the sort by:[code]$result = mysql_query("SELECT city_id, City FROM city WHERE country_id = '$country_id' ORDER BY City DESC");[/code]Which is line 14?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/22649-help-needed-solved/#findComment-101730 Share on other sites More sharing options...
Daniel0 Posted October 1, 2006 Share Posted October 1, 2006 wwfc_barmy_army's code should work, but I would sort it ascendingly. Quote Link to comment https://forums.phpfreaks.com/topic/22649-help-needed-solved/#findComment-101733 Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 When calling queries, check for error messages. Also, if you specify the query in a string var then use that in the mysql_query() call you can also echo that out with the error message.My guess here is that $country_id has no value.[code]<?php// Connect to the database.include_once("config.php");$country_id = $_GET[country_id];$sql = "SELECT city_id, City FROM city WHERE country_id ='$country_id' ORDER BY City";$result = mysql_query($sql) or die (mysql_error().'<br>'.$sql);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22649-help-needed-solved/#findComment-101736 Share on other sites More sharing options...
Anakin Posted October 1, 2006 Author Share Posted October 1, 2006 Thanks very much to everyone that responded.With your guidance, I've managed to resolve the issue!!! :) Quote Link to comment https://forums.phpfreaks.com/topic/22649-help-needed-solved/#findComment-101810 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.