Jump to content


Spot the Bug

  • Please log in to reply
1 reply to this topic

#1 Anakin

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 April 2006 - 12:41 AM

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 />
: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

on line
<br />



// This line connects to the database.

//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 ..." />';

$line = '<menu-item data="'.$row[city_id].'" label="'.$row[City].'"/>';
echo $line;
echo '</menu-title>';
echo '</menu>';


#2 bbaker

  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 25 April 2006 - 01:24 AM

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--]$result = mysql_query("SELECT city_id, City FROM city WHERE country_id =[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--].$country_id);
try this instead, separate your query from your execution & make sure your query is executed:
$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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users