dsvd407787736 2014-02-23 20:37
浏览 29
已采纳

PHP短标签未按预期工作[关闭]

I'm trying to make my php page working, by having html code combined with it. Here is a source code:

<?

$username="username";
$password="password";
$db_name="db_name";

mysql_connect('localhost',$username,$password) or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$userstable='profile';
$query = "SELECT * FROM $userstable order by id";
$result = mysql_query($query) or die(mysql_error());

?>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>DayZSC | Showlist</title>
    <meta charset="utf-8" />
    <link type="text/css" rel="stylesheet" href="styles.css" />
    <link rel="shortcut icon" href="favicon.ico" />
</head>
<body>

    <div class="container">

    <div id="logo">
    <img src="img/logo.png" />
    </div>

    <?
    while ($row=mysql_fetch_array($result)) {
    ?>

    <div class='p_content'>
    <h3>
    <?
    echo ".$row['name'].";
    ?>
    </h3>
    <p style="text-align: justify;">
    <table align="center"><tbody><tr>
    <td>Copies Sold (Week)</td>
    <td>11152</td>
    </tr>
    <tr>
    <td>Copies pirated (Week)</td>
    <td>124214</td>
    </tr>
    </tbody></table>
    </p>
    <h2><a href="#">Comments</a></h2><br /><br />
    </div>

    <?
    }
    ?>

    <div id="footer">All rights reserved &copy 2014 | Designed by <a href="http://berdyevcreations.com" target="_blank" style="color: #000;">BerdyevCreations</a></div>

    </div>

</body>
</html>

So whenever I try to run this page, it gives me just a blank. Cannot find error log either. Please help?

  • 写回答

3条回答 默认 最新

  • dongmijgnnq0118 2014-02-23 20:53
    关注

    I think you are using the PHP short tags wring, try and use this:

    <?= $row['name'] ?>
    

    Instead of your

    <?
    echo ".$row['name'].";
    ?
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用