我对此搜索有问题,错误是在/ data / web / virtuals / 81877 / virtual / www / subdom / hdb / page_search中的非对象上调用成员函数query()第8行的.php
**
if(!empty($_GET["search"]) AND isset($_GET["search"]))
{
$search = $_GET["search"];
$query= "SELECT * FROM tblSKUPINA WHERE CONCAT_WS(' ',NAZEV,ZANR) LIKE '%$search%'";
$user = $pdo->query($query);
while($user_final = $user->fetch())
{
echo "
<DIV class='text_search'>
<A href='profil?profile=".$user_final["ID_OSOBA"]."'>"
.$user_final["JMENO"]." ".$user_final["PRIJMENI"].
"</A>
";
}
}
?>**
答案 0 :(得分:0)
确保在查询之前有PDO连接:
$pdo = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
或者如果它在外部文件中,那么您必须包含该文件,并且必须使用global $pdo
来访问对象,如:
// Hold the connection
include `db_config.php`
global $pdo;