gpt4 book ai didi

PHP 搜索 MySQL 数据库 fatal error

转载 作者:行者123 更新时间:2023-11-30 21:40:17 25 4
gpt4 key购买 nike

<分区>

我用android studio和PHP编写了查询系统。

我的PHP代码如下,用浏览器打开但是出错,错误信息如下

注意:未定义索引:第5行C:\xampp\htdocs\client\beetle_search.php中的searchQuery

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'table 1 where MATCH(name,scientific_name) AGAINST(NULL)' at line 1' in C:\xampp\htdocs\client\beetle_search.php:9 Stack trace: #0 C:\xampp\htdocs\client\beetle_search.php(9): PDOStatement->execute() 1 {main} thrown in C:\xampp\htdocs\client\beetle_search.php on line 9

   require_once('config.inc.php');
$search_query=$_POST['searchQuery'];
$sql = 'SELECT * from table 1 where MATCH(name,scientific_name) AGAINST(:search_query)';
$statement = $connection->prepare($sql);
$statement->bindParam(':search_query', $search_query, PDO::PARAM_STR);
$statement->execute();
if($statement->rowCount())
{
$row_all = $statement->fetchall(PDO::FETCH_ASSOC);
header('Content-type: application/json');
echo json_encode($row_all);
}
elseif(!$statement->rowCount())
{
echo "no rows";
}

你哪里写错了?谢谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com