I'm having a problem with this search, the error is Call to a member function query() on a non-object in /data/web/virtuals/81877/virtual/www/subdom/hdb/page_search.php on line 8
**
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>
";
}
}
?>**
Make sure you have a PDO connection before your query:
$pdo = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
Or if it is in external file then you have to include that file and have to use global $pdo
to access the object like:
// Hold the connection
include `db_config.php`
global $pdo;