フォーラムの内容を表示するために使用しているシンプルなPHPコードです。問題は、ノートパソコンでうまくいきますが、2番目には出力が表示されません。このPHPコードの問題点は何ですか?
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<tr>
<td bgcolor="#E6E6E6"><? echo $rows['id']; ?></td>
<td bgcolor="#E6E6E6"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#E6E6E6"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#E6E6E6"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#E6E6E6"><? echo $rows['datetime']; ?></td>
</tr>
私は他のものをすべてチェックしても問題ないと思います。データはデータベースに存在しますが、フォーラムには表示されません。誰でもこのことで私を助けることができますか? オペレーティングシステム:win7
すべてのコードとデータベース構造を掲載してください。 –
'$ tbl_name'がどこに定義されているのかわかりません。あなたのラップトップでこのコードを実行しているのですか、それとも他の場所でホストされていますか? –
短いタグが無効になっている可能性があります。変更<?エコー$行['id']; ?><?php echo $ rows ['id']; ?>で始まり、<? 〜<?php – smottt