【发布时间】:2015-04-22 22:08:40
【问题描述】:
我不明白为什么查询不起作用,如果我尝试使用 localhost 可以正常工作但使用“mysql”并且我尝试在我的网站中使用 PDO 并且没有给出结果。我尝试查看 error_log 我得到这样的错误
PHP Fatal error: Call to a member function fetch() on a non-object in fungsi/f_record.php on line 9
这是我的来源 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));
?>
和 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>
如何解决这个问题..
【问题讨论】:
-
发布您的
f_autocomplete_cust.php -
在服务器支持 PDO 上添加你的 PHP 版本?
-
@SO-user : 对不起,我编辑了.. 写错了
-
@jQuery:是的,支持..