我是新來的php。我正在嘗試使用MATCH AGAINST而不是使用LIKE來搜索mysql dayabase。使用該腳本,在php中使用MATCH()AGAINST()時發生錯誤mysql mysql
<?php
if (isset($_GET['q'])){
error_reporting(-1);
$query = $_GET['q'];
$dbh = new mysqli($host, $user, $password, $database);
if ($dbh->connect_error) {
echo 'Unable to connect to database '. $dbh->connect_error;
} else {
if ($stmt = $dbh->prepare("SELECT index, sura, aya, text FROM bn_bengali WHERE MATCH(sura,text) AGAINST(?) "))
{
$stmt->bind_param("s", $query);
$stmt->execute();
$stmt->bind_result($index, $sura, $aya, $text);
$stmt->store_result();
printf("Number of rows: %d.\n", $stmt->num_rows);
while ($stmt->fetch()) {
echo $sura.'-'.$aya;
echo $text;
echo '<hr />';
}
} else {
echo "Prepare failed: (" . $dbh->errno . ") " . $dbh->error;
}
}
} // end isset get q
else
{
echo '<form action="" ><input type="text" name="q"><button>Search</button></form>';
}
?>
,但它給這個錯誤,
Prepare failed: (1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index, sura, aya, text FROM bn_bengali WHERE MATCH(sura,text) AGAINST(?)' at line 1
哪裏是在這個腳本的問題?
我想用匹配搜索數據庫表。
但相同的腳本工作的罰款與
SELECT蘇拉,綾,本文從bn_bengali WHERE文本是怎樣的?
爲什麼不匹配正在工作? 這個腳本中的問題在哪裏?
指數變化SELECT'index','sura',之後保留在MySQL –