I'm not understand why the query is not working, if i try using localhost is work fine but using "mysql" and i try to use PDO in my website and not give a result. and i try to look the error_log i a get error like this
PHP Fatal error: Call to a member function fetch() on a non-object in fungsi/f_record.php on line 9
This my source f_record.php
<?php
include "../config/c_config.php";
$db = dbConn::getConnection();
$uq = strtolower($_GET["term"]);
$return = array();
$sqlac= "SELECT * FROM str_user WHERE name LIKE '$uq'";
$resac = $db->query($sqlac);
while($resac = $sqlac->fetch(PDO::FETCH_ASSOC)){
array_push($return,array('label'=>$resac['name'],'value'=>$resac['name']));
}
echo(json_encode($return));
?>
and index.php
<script>
$(function() {
$( "#txtname" ).autocomplete({
source: "f_record.php",
minLength: 1
});
});
</script>
</head>
<body>
<div>
<label for="Name">Name: </label>
<input id="txtname" class="txtname"/>
</div>
how to fix this..