页面代码:
<head align="center">
<div align="center">查询结果并显示到table里面
</head>
</div>
<hr><hr><?php
error_reporting(E_ALL); //禁止自动错误输出
$con=mysql_connect("127.0.0.1","root","mysql"); //建立连接
if (!$con)
{
die('建立连接失败'.mysql_error());
}
mysql_select_db("test",$con); //选择使用的数据库
$sql="select * from t_stage_xx";
$result = mysql_query("select * from t_stage_xx");
echo "<table border='1' ><tr><th>id</th><th>data</th><th>uv</th><th>updatetime</th></tr>"; //构造表头
while ($row = mysql_fetch_array($result)) //循环查询结果集
{
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['data']."</td>";
echo "<td>".$row['uv']."</td>";
echo "<td>".$row['updatetime']."</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
出现了这个错误
<head align="center">
<div align="center">查询结果并显示到table里面
</head>
</div>
<hr><hr><?php
error_reporting(E_ALL); //禁止自动错误输出
$con=mysql_connect("127.0.0.1","root","mysql"); //建立连接
if (!$con)
{
die('建立连接失败'.mysql_error());
}
mysql_select_db("test",$con); //选择使用的数据库
$sql="select * from t_stage_xx";
$result = mysql_query("select * from t_stage_xx");
echo "<table border='1' ><tr><th>id</th><th>data</th><th>uv</th><th>updatetime</th></tr>"; //构造表头
while ($row = mysql_fetch_array($result)) //循环查询结果集
{
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['data']."</td>";
echo "<td>".$row['uv']."</td>";
echo "<td>".$row['updatetime']."</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
出现了这个错误
解决方案 »
- php新旧版本使用之策略[极为难度]
- 基础问题,php分页
- match against匹配的问题
- php readdir
- 如何用sql实现两个表字段的值?
- 自定义函数为什么输入不了呢?
- form提交不能获得参数,这是怎么回事?php4.x没问题
- POST方式传数据从$_POST[***]只能读到第一个变量?为什么?
- php4.04与mysql的问题。
- include的怪问题,请各位高手帮忙!谢谢!!!!非常奇怪的问题!!!
- linux下nginx php mysql 在页面中显示了连接mysql成功,为什么显示不了数据
- linux下nginx php mysql已编译部署好,怎么在页面中显示mysql数据,求代码,最好给个例子,谢谢!
var_dump($db);
$sql="select * from t_stage_xx";
var_dump($result);
测试下,应该有一个是fboolean false
看看错误提示第一天mysql_query()第二个参数必须是%&¥¥%……很显然,你只有sql少了第二个