Php &引用;警告:mysqli_fetch_array()要求参数1为mysqli_结果,布尔值在“";在搜索之后,我更正了我的代码如下
显示PHP: 我无法获取输出。查询未获取结果Php &引用;警告:mysqli_fetch_array()要求参数1为mysqli_结果,布尔值在“";在搜索之后,我更正了我的代码如下,php,mysql,Php,Mysql,显示PHP: 我无法获取输出。查询未获取结果 <?php include("dbconfig.php"); ?> <?php $query = "SELECT * FROM rmuruge4_landlord"; $result = mysqli_query(mysqli_connect(),$query); if ($result === false) {die(mysqli_error(mysqli_connect()));
<?php include("dbconfig.php"); ?>
<?php
$query = "SELECT * FROM rmuruge4_landlord";
$result = mysqli_query(mysqli_connect(),$query);
if ($result === false)
{die(mysqli_error(mysqli_connect())); }
echo "<div class='bs-example'>";
echo "<table class='table table-striped'>";
echo "<tr><th>LLID</th><th>LName</th><th>Phone</th><th>Address</th></td>";
while($row = mysqli_fetch_array($result)){
echo "<tr><td>" . $row['LLID'] . "</td><td >" . $row['LName'] . "</td><td >". $row['Phone'] . "</td><td >" . $row['Address'] . "</td></tr>"; }
echo "</table>";
echo "</div>";
mysqli_close(mysqli_connect());
?>
dbconfig.php:
Connection is successful
dbconfig.php:
连接成功
有点“疯狂猜测模式”,但是
<?php
require 'dbconfig.php';
// let's assume dbconfig.php provides DB_HOST, DB_USER, ...
// there's something to be said about defining DB_PASS ...but anyway, that's worth another question
// establish the connection/create connection instance
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DBNAME);
if ($mysqli->connect_errno) {
trigger_error( sprintf('mysqli connect error (%d) %s', $mysqli->connect_errno, $mysqli->connect_error), E_USER_ERROR);
die;
}
$query = 'SELECT * FROM rmuruge4_landlord';
// use _that_ connection resource to send/retrieve data to/from the MySQL server
$result = mysqli_query($mysqli ,$query);
if ($result === false) {
// by default you shouldn't send the exact, detailed error message to the client
// see https://www.owasp.org/index.php/Information_Leakage
// die(mysqli_error(mysqli_connect()));
someErrorHandler( mysqli_error($mysql) );
}
else {
// php supports multi-line string literals
echo '
<div class="bs-example">
<table class="table table-striped">
<tr><th>LLID</th><th>LName</th><th>Phone</th><th>Address</th></tr>
';
while( $row=mysqli_fetch_array($result) ) {
// echo can take more than one parameter, no need to use string-concatenation here.
echo
'<tr><td>',
// just like you have to ensure the proper encoding when putting literal string values into sql statements
// you have to use something like htmlspecialchars() here to prevent, e.g. the value in Address to break your html structure
htmlspecialchars($row['LLID']),
'</td><td >',
htmlspecialchars($row['LName']),
'</td><td >',
htmlspecialchars($row['Phone']),
'</td><td >',
htmlspecialchars($row['Address'])
'</td></tr>'
;
}
echo '
</table>
</div>';
你有什么问题吗,还是你只是在报告你的成功?;-)我认为问题在于您的mysqli\u connect()
dbconfig.php
fileum的Post代码。。。为什么在$result=mysqli\u查询(mysqli\u connect(),$query)中没有参数代码>?如果查询失败,您不能声明您希望它做什么!