我想从我的数据库中获取数据。上传文件时页面不会更改。我哪里错了?
verifycheck.php
<?php
$con=mysql_connect ("###", "###", "###");
mysql_select_db ("db_name", $con);
$result = mysql_query($con,"SELECT * FROM db_tablename");
echo "<table border='1'>
<tr>
<th>username</th>
<th>email</th>
<th>password</th>
<th>confirm_password</th>
</tr>";
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['confirm_password'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
答案 0 :(得分:1)
连接对象应该是第二个参数,查询字符串应该是第一个参数。
试试这个
$result = mysql_query("SELECT * FROM db_tablename",$con);
而不是
$result = mysql_query($con,"SELECT * FROM db_tablename");
不推荐使用Mysql函数,将来会删除 Mysqli 或 PDO 以防止sql注入
答案 1 :(得分:0)
从$con,
mysql_query
由于mysql_query()
期望第一个参数是SQL查询,而不是SQL连接。
$result = mysql_query("SELECT * FROM db_tablename");
答案 2 :(得分:0)
请使用您的连接参数检查为localhost,用户名密码,数据库以及更改
$result = mysql_query($con,"SELECT * FROM db_tablename");
as
$result = mysql_query("SELECT * FROM db_tablename",$con);