title: php javascript getting data from mysql makes 500 error in server side
body: <p>I have a mysql database and php+js+jquery pages in my webpage.</p>
  
  <p>In this example browser loads a php page with this content:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function MuestraNoticia(str)
      {
      if (str=="")
        {
        document.getElementById("rss_rcpt").innerHTML="";
        return;
        }
      if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        }
      else
        {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      xmlhttp.onreadystatechange=function()
        {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
          {
          document.getElementById("rss_rcpt").innerHTML=xmlhttp.responseText;
          }
        }
      xmlhttp.open("GET","auth/peticion_noticia.php?page="+str,true);
      xmlhttp.send();
      }
      MuestraNoticia(1);
  &lt;/script&gt;
  &lt;div id="rss_rcpt"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>peticion_noticia.php</p>
  
  <pre><code>&lt;?php
      $event=$_GET["page"];
      if($page == 1){
  
      //allow sessions to be passed so we can see if the user is logged in
      session_start();
      //connect to the database so we can check, edit, or insert data to our users table
      $con = mysql_connect('localhost', 'user', 'pwd') or die(mysql_error());
      $db = mysql_select_db('dbname', $con) or die(mysql_error());
      $SQL = "SELECT * FROM tablename";
      $result = mysql_query($SQL);
      echo "&lt;table class='PaperPage'&gt;";
      echo "&lt;tr&gt;";
      $GLOBALS['normalizeChars'] = array(
          'Á'=&gt;'&amp;Aacute;', 'É'=&gt;'&amp;Eacute;', 'Í'=&gt;'&amp;Iacute;', 'Ó'=&gt;'&amp;Oacute;', 'Ú'=&gt;'&amp;Uacute;', 'Ñ'=&gt;'&amp;Ntilde;',
          'á'=&gt;'&amp;aacute;', 'é'=&gt;'&amp;eacute;', 'í'=&gt;'&amp;iacute;', 'ó'=&gt;'&amp;oacute;', 'ú'=&gt;'&amp;uacute;', 'ñ'=&gt;'&amp;ntilde;'
      );
      function arregla($toClean){
          return strtr($toClean, $GLOBALS['normalizeChars']);
      }
  
      while ($row = mysql_fetch_array($result)) {
          arregla($row['contenido']);
          echo "&lt;td class='PaperFechaData' style='width:100px'&gt;" .$row['fecha']. "&lt;/td&gt;";
          echo "&lt;td class='PaperTitData' style='width:820px'&gt;" .$row['titulo']. "&lt;/td&gt;";
          echo "&lt;/tr&gt;&lt;tr&gt;";
          echo "&lt;td colspan='2' class='PaperCabData' style='width:920px'&gt;". .$row['cabecera']. "&lt;/td&gt;";
          echo "&lt;/tr&gt;&lt;tr&gt;";
          echo "&lt;td class='PaperImgData'&gt;&lt;img src='".$row['img']."' width='400px' height='400px'&gt;&lt;/td&gt;";
          echo "&lt;td class='PaperTxtData' style='width:520px'&gt;" .$row['contenido']. "&lt;/td&gt;";
          echo "&lt;/tr&gt;";
          echo "&lt;tr&gt;&lt;td colspan='2'&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
      mysql_close($con);
      } else {
          die();
      }   
  ?&gt;
  </code></pre>
  
  <p>I have the same code structure for another part of my webpage without any problem, nut in this case browser return HTTP/1.0 500 Internal Server Error.</p>