Jump to content

Anakin

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Anakin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks very much to everyone that responded. With your guidance, I've managed to resolve the issue!!! :)
  2. Hi Would 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] _________________________________________________________
  3. 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>'; ?>
  4. Hi, I am trying to make the following 3 scripts of code produce output that is in alphabetical order. I understand it needs to contain the statement ORDER BY, however not sure where to place it. Can someone please assist? Much appreciated! ************************************************** $result = mysql_query("[b]SELECT[/b] city_id, City [b]FROM[/b] city [b]WHERE[/b] country_id =".$country_id); ************************************************** $result = mysql_query("[b]SELECT DISTINCT[/b] category.category_id, Category [b]FROM[/b] category [b]INNER JOIN[/b] cat_city_bus [b]ON[/b] category.category_id = cat_city_bus.category_id [b]WHERE[/b] City_id = ".$city_id,$connection); ************************************************** $query = "[b]SELECT[/b]directory.business_id as dID, category.Category, Business, Address1, Address2, Address3, city.City, city.State, Postcode, country.Country, Telephone, Website, Email, Details, Picture [b]FROM[/b] cat_city_bus [b]INNER JOIN[/b] category [b]ON[/b] cat_city_bus.category_id = category.category_id [b]INNER JOIN[/b] city [b]ON[/b] cat_city_bus.city_id = city.city_id [b]INNER JOIN[/b] directory [b]ON[/b] cat_city_bus.business_id = directory.business_id [b]INNER JOIN[/b] country [b]ON[/b] city.country_id = country.country_id [b]WHERE[/b] cat_city_bus.city_id = ".$city_id." [b]AND[/b] cat_city_bus.category_id = ".$category_id; $result = mysql_query($query, $connection); **************************************************
  5. Hi, Can someone please assist with the following code. (1) I get the following error when I run the script. (2) I also need to have the results output in alphabetical order (ORDER BY). Much appreciated for assistance!!! Regards Anakin ============================================================= <?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 on line <b>24</b>[/b] <br /> </menu-title> </menu> ============================================================= <?php // This line connects to the database. include_once("config.php"); global $connection; $country_id = $_GET[country_id]; $query = "SELECT city_id, City FROM city WHERE country_id = ".$country_id; $result = mysql_query($query,$connection); // 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>'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.