title: Ampersands in database
body: <p>I am trying to write a php function that goes to my database and pulls a list of URLS and arranges them into an xml structure and creates an xml file. </p>
  
  <p>Problem is, Some of these urls will contain an ampersand that ARE HTML encoded. So, the database is good, but currently, when my function tries to grab these URLS, the script will stop at the ampersands and not finish.   </p>
  
  <p>One example link from database: </p>
  
  <pre><code>http://www.mysite.com/myfile.php?select=on&amp;amp;league_id=8&amp;amp;sport=15
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>function buildXML($con) {
  //build xml file
  $sql = "SELECT * FROM url_links";
  $res = mysql_query($sql,$con);
  
  $gameArray = array ();
  
  while ($row = mysql_fetch_array($res))
      {
      array_push($row['form_link']);
      }
  
  $xml = '&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;channel&gt;';
  
  foreach ($gameArray as $link)
      {   
          $xml .= "&lt;item&gt;&lt;link&gt;".$link."&lt;/link&gt;&lt;/item&gt;";  
      }
  
  $xml .= '&lt;/channel&gt;';   
  file_put_contents('../xml/full_rankings.xml',$xml);
  }
  
  mysql_close($con);
  session_write_close();
  </code></pre>
  
  <p>If i need to alter the links in the database, that can be done. </p>