Anakin Posted April 25, 2006 Share Posted April 25, 2006 Can anyone spot the bug in the code below. The script actually works! However, if I try to display the php generated xml file, I get the following;**************************************************<?xml version="1.0" encoding="UTF-8" ?> - <menu>- <menu-title label="menu"> <menu-item label="Select City ..." /> <br /> [b]<b>Warning</b> : mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>city.php</b>[/b] on line <b>23</b> <br /> </menu-title> </menu>**************************************************<?php// This line connects to the database.include_once("config.php");//global $connection;$country_id = $_GET[country_id];$result = mysql_query("SELECT city_id, City FROM city WHERE country_id =".$country_id);// And now we need to output an XML document.// We use the names of columns as <row> properties.echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<menu>'; echo '<menu-title label="menu">';echo '<menu-item label="Select City ..." />';while($row=mysql_fetch_array($result)){ $line = '<menu-item data="'.$row[city_id].'" label="'.$row[City].'"/>'; echo $line;}echo '</menu-title>';echo '</menu>';?> Quote Link to comment Share on other sites More sharing options...
bbaker Posted April 25, 2006 Share Posted April 25, 2006 I didn't look too hard at your code, but you're looks like your 2nd " is in the wrong place in your query string.[!--coloro:#999999--][span style=\"color:#999999\"][!--/coloro--][i]$result = mysql_query("SELECT city_id, City FROM city WHERE country_id =[b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--][/b].$country_id);[/i][!--colorc--][/span][!--/colorc--]try this instead, separate your query from your execution & make sure your query is executed:[code]$query = "SELECT city_id, City FROM city WHERE country_id ='$country_id' "; //query code$result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query"); //execute!, if there is something wrong with your query, this will let you know where it is.[/code] 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.