gpt4 book ai didi

PHP错误问题(搜索)

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:18 27 4
gpt4 key购买 nike

您好,我在我的网站上进行搜索时遇到此错误。

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/u321547826/public_html/search.php:14 Stack trace: #0 {main} thrown in /home/u321547826/public_html/search.php on line 14

我正在使用这段代码,有人可以帮忙吗?

<?php

$button = $_GET['submit'];
$search = $_GET['search'];

if (!$button)
echo "you didn't submit a keyword";
else {
if (strlen($search) <= 1)
echo "Search term too short";
else {
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("", "", "");
mysql_select_db("");

$search_exploded = explode(" ", $search);

foreach ($search_exploded as $search_each) {
$x++;
if ($x == 1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= "AND keywords LIKE '%$search_each%'";

}

$construct = "SELECT * FROM SEARCH_ENGINE WHERE $construct";
$run = mysql_query($construct);

$foundnum = mysql_num_rows($run);

if ($foundnum == 0)
echo "Sorry, there are no matching result for <b>$search</b>.</br></br>1.
Try more general words. for example: If you want to search 'how to create a website'
then use general keyword like 'create' 'website'</br>2. Try different words with similar
meaning</br>3. Please check your spelling";
else {
echo "$foundnum results found !<p>";

while ($runrows = mysql_fetch_assoc($run)) {
$title = $runrows['title'];
$desc = $runrows['description'];
$url = $runrows['url'];

echo "
<a href='$url'><b>$title</b></a><br>
$desc<br>
<a href='$url'>$url</a><p>
";

}
}

}
}

?>

最佳答案

您可能正在使用 PHP>=7,其中 mysql_函数不再被弃用并已被删除,请尝试使用 mysqli_PDO相反。

关于PHP错误问题(搜索),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38082005/

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