포럼의 내용을 보는 데 사용하는 간단한 PHP 코드입니다. 문제는 내 노트북 중 하나에서 정상적으로 작동하지만 초에 출력이 표시되지 않는다는 것입니다.이 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 '이 정의 된 곳이 보이지 않습니다. 랩톱에서이 코드를 실행하고 있습니까 아니면 다른 곳에 호스팅되어 있습니까? –
짧은 태그가 비활성화되었을 수도 있습니다. 변경 echo $ rows [ 'id']; ?> php echo $ rows [ 'id']; ?>로 시작하고 to php – smottt