我有這兩個錯誤我找不到任何辦法來解決這些問題mysqli_query預計至少2個參數
警告:mysqli_query預計至少2個參數,1只給予在
錯誤查詢:SELECT ID
,TITLE
, CONTENT
,AUTHOR
,DATE
FROM NEWS
ORDER BY ID
DESC。
<?php
include("site.inc.php");
db_login();
//Generate the query so we can retrieve all titles in the DB in descending ID order
$query = 'SELECT `id`, `title`, `content`, `author`, `date` FROM `news` ORDER BY `id` DESC';
$result = mysqli_query($query)
or die ("Error in query: $query. " . mysqli_connect_error());
// if records are present
if (mysql_num_rows($result) > 0) {
while($send = mysql_fetch_object($result)) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<?php
echo"$send->content";
?>
</td>
</tr>
<tr>
<?Php
echo "$send->author";
}
}
?>
</tr>
<br>
</table>
功能db_login
<?php
$confg['db_uname'] = "root";
$confg['db_paswd'] = "";
$confg['db_host'] = "localhost";
$confg['db_dbase'] = "dbname";
function db_login() {
global $confg;
$link = @mysqli_connect($confg['db_host'], $confg['db_uname'], $confg['db_paswd']) or die("Error connecting: " . mysql_error());
@mysqli_select_db($confg['db_dbase'], $link);
mysqli_query($link,"set names 'utf8';");
}
function db_logout() {
@mysqli_close($link);
}
?>
'mysqli_query($查詢)'=>'mysqli_query($連接,$查詢)' – Qirel
正如錯誤狀態。所以,RTM http://php.net/manual/en/mysqli.query.php - 你真的應該有谷歌的錯誤,並在發佈之前閱讀手冊。 –
我google'd錯誤,我沒有找到解決方案 – Bacha