21,891
社区成员
发帖
与我相关
我的任务
分享
<?php
include ("conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>title</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
<form action="" method="post" enctype="text/plain">
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql = "select * from 'message'";
$query = mysql_query($sql);
$rrr = mysql_fetch_array($query);
while($row=mysql_fetch_array($query)) {
?>
<tr bgcolor="#eff3ff">
<td>标题: 用户:</td>
</tr>
<tr bgColor="#ffffff">
<td>内容:</td>
</tr>
<?php
}
?>
</table>
</form>
</body>
</html>
select * from 'message' 错误--表或字段名称不用单引号
select * from ·message· 正确--而是要用1左边~下面的那个符号
[Quote=引用 19 楼 siramizu 的回复:]
PHP code<?phpinclude ("conn.php");ini_set('display_errors',1);error_reporting(E_ALL);$sql="select * from message";$query=mysql_query($sql);echo'Query error'.mysql_errno().':'.mysql_error()."<br />\n";while($row=mysql_fetch_array($query)){echo'Fetch error'.mysql_errno().':'.mysql_error()."<br />\n";
}?>
执行这段看显示什么
[/Quote]
<? $sql = "select * from message"; $query = mysql_query($sql); echo 'Query error '.mysql_errno().': '.mysql_error()."
\n"; while($row=mysql_fetch_array($query)){ ?>
$sql = "select * from 'message'";$sql = "select * from message";$sql = "select * from `message`";$rrr = mysql_fetch_array($query);
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql = "select * from 'message'";//这个SQL语句, select * from message ,表名加单引号在我本机测试不通过。
$query = mysql_query($sql);
//$rrr = mysql_fetch_array($query);//这个不要
while($row=mysql_fetch_array($query)) {
?>
<tr bgcolor="#eff3ff">
<td>标题:<? echo $row['title']?> 用户:<? echo $row['username']?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<? echo $row['content'] ?></td>
</tr>
<?php
}
?>
</table>
<?php
include ("conn.php");
ini_set('display_errors', 1);
error_reporting(E_ALL);
$sql = "select * from message";
$query = mysql_query($sql);
echo 'Query error '.mysql_errno().': '.mysql_error()."<br />\n";
while($row=mysql_fetch_array($query)){
echo 'Fetch error '.mysql_errno().': '.mysql_error()."<br />\n";
}
?>
<?php
include ("conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en" />
<meta name="GENERATOR" content="PHPEclipse 1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>显示数据</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
<form method="post">
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?
$sql = "select * from message";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>标题: <?=$row[title]?>用户:<?=$row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?=$row[content]?></td>
</tr>
<?
}
?>
</table>
</form>
</body>
</html>