本文介紹了在非對象上調(diào)用成員函數(shù) query()的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我收到此錯誤:
在非對象上調(diào)用成員函數(shù) query().
Call to a member function query() on a non-object.
此外,當(dāng)我使用其他 MySQLi 函數(shù)時,它也會給我同樣的錯誤,但對于該函數(shù).
Also when I use other MySQLi functions it gives me the same error but for that function.
我的connection.php
:
<?php
$mysqli = new mysqli("localhost","user","pass","db");
if(mysqli_connect_errno()){
trigger_error('Connection failed: '.$mysqli->error);
}
?>
我的功能:
function form_year($find, $value, $from, $vehicletype){
//Query setup
$autoquery = "SELECT
Year,
Vehicle,
Brand,
Model,
Type,
FROM
vehicle_tbl
WHERE
Vehicle = '".$vehicletype."'
GROUP BY
Year";
$autoresult = $mysqli->query($autoquery);
$search = array("%value%", "%options%");
$rows = file_get_contents("tpl/options.html");
while($row = $autoresult->fetch_assoc()){
$replace = array($row[$value], $row[$value]);
$tr .= str_replace($search, $replace, $rows);
}
return str_replace($find, $tr, $from);
}
函數(shù)和連接包含在調(diào)用函數(shù)的地方
Function and connection is included where the function is called
推薦答案
快速/臟修復(fù):
function form_year($find, $value, $from, $vehicletype){
//Query setup
global $mysqli;
$autoquery = "SELECT [...]
這篇關(guān)于在非對象上調(diào)用成員函數(shù) query()的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!