Php 错误:将数据表单数据库显示到网页
我想在表格中的网页中显示我的数据库。但它不能,我很确定我的数据库名称是相同的。如果我运行,.$no,.$row['nama'],.$row['email']。和.$row['message']。将显示在网页上。不是来自数据库的数据。请帮忙 这是我的密码:Php 错误:将数据表单数据库显示到网页,php,html,Php,Html,我想在表格中的网页中显示我的数据库。但它不能,我很确定我的数据库名称是相同的。如果我运行,.$no,.$row['nama'],.$row['email']。和.$row['message']。将显示在网页上。不是来自数据库的数据。请帮忙 这是我的密码: <table class="table"> <thead> <tr> <th>#</th> <th>Nama</th>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Nama</th>
<th>E-mail</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
</tbody>
<?php
include "conection.php";
$no = 1;
$query = mysql_query("SELECT * FROM comment");
if ($query) {
while ($row = mysql_fetch_array($query)) {
echo "
<tr>
<td>".$no."</td>
<td>".$row['nama']."</td>
<td>".$row['email']."</td>
<td>".$row['message']."</td>
</tr>
";
$no++;
}
}
?>
</table>
错误如下所示:
这是我的conconnect.php
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "toefl";
$koneksi = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if(mysqli_connect_error()){
echo 'database error : '.mysqli_connect_error();
}
?>
你忘了一个i。将mysql\u查询更改为mysqli\u查询,将mysql\u fetch\u数组更改为mysqli\u fetch\u数组 你忘了一个i。将mysql\u查询更改为mysqli\u查询,将mysql\u fetch\u数组更改为mysqli\u fetch\u数组 您正在将mysql_*与mysqli_*混合使用。请不要那样做。检查是否注释了以下代码更改:-
注意:-此代码文件扩展名必须为.php。您将mysql_*与mysqli_*混合使用。请不要那样做。检查是否注释了以下代码更改:-
注意:-此代码文件扩展名必须为.php。Chnage conconnect.php。将所有mysqli方法更改为mysql
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "toefl";
$koneksi = mysql_connect($db_host, $db_user, $db_pass);
if (!$koneksi) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully'
mysql_select_db($db_name, $koneksi) or die('Could not select database.');;
?>
Chnage conconnect.php。将所有mysqli方法更改为mysql
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "";
$db_name = "toefl";
$koneksi = mysql_connect($db_host, $db_user, $db_pass);
if (!$koneksi) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully'
mysql_select_db($db_name, $koneksi) or die('Could not select database.');;
?>
请写错误消息你确定你的php代码被执行了吗?只要测试这段代码它就会显示1i确定,因为如果我在其他程序中尝试这段php代码,它就会工作你正在将mysql与MySQLI混合请写错误消息你确定你的php代码被执行了吗?只要测试这段代码它就会显示1i确定,因为如果我在其他程序中尝试该php代码,那么如果您将mysql与mysqli混合使用,它将起作用