1

我的网页中有一个 mysql 数据库和 php+js+jquery 页面。

在此示例中,浏览器会加载一个包含以下内容的 php 页面:

<script type="text/javascript">
    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 && xmlhttp.status==200)
        {
        document.getElementById("rss_rcpt").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","auth/peticion_noticia.php?page="+str,true);
    xmlhttp.send();
    }
    MuestraNoticia(1);
</script>
<div id="rss_rcpt">
</div>

peticion_noticia.php

<?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 "<table class='PaperPage'>";
    echo "<tr>";
    $GLOBALS['normalizeChars'] = array(
        'Á'=>'&Aacute;', 'É'=>'&Eacute;', 'Í'=>'&Iacute;', 'Ó'=>'&Oacute;', 'Ú'=>'&Uacute;', 'Ñ'=>'&Ntilde;',
        'á'=>'&aacute;', 'é'=>'&eacute;', 'í'=>'&iacute;', 'ó'=>'&oacute;', 'ú'=>'&uacute;', 'ñ'=>'&ntilde;'
    );
    function arregla($toClean){
        return strtr($toClean, $GLOBALS['normalizeChars']);
    }

    while ($row = mysql_fetch_array($result)) {
        arregla($row['contenido']);
        echo "<td class='PaperFechaData' style='width:100px'>" .$row['fecha']. "</td>";
        echo "<td class='PaperTitData' style='width:820px'>" .$row['titulo']. "</td>";
        echo "</tr><tr>";
        echo "<td colspan='2' class='PaperCabData' style='width:920px'>". .$row['cabecera']. "</td>";
        echo "</tr><tr>";
        echo "<td class='PaperImgData'><img src='".$row['img']."' width='400px' height='400px'></td>";
        echo "<td class='PaperTxtData' style='width:520px'>" .$row['contenido']. "</td>";
        echo "</tr>";
        echo "<tr><td colspan='2'></td></tr>";
    }
    echo "</table>";
    mysql_close($con);
    } else {
        die();
    }   
?>

我的网页的另一部分具有相同的代码结构,没有任何问题,在这种情况下浏览器返回 HTTP/1.0 500 内部服务器错误。

4

1 回答 1

1
 echo "<td colspan='2' class='PaperCabData' style='width:920px'>". .$row['cabecera']. "</td>";

你有两个相邻的点。

于 2012-04-22T19:31:23.790 回答