我的搜索查詢出現問題,輸入搜索多次後該網站崩潰,我不確定是否由於缺乏我在GoDaddy支付的RAM或如果我的搜索查詢引發錯誤或需要太多資源。MYSQLI搜索查詢崩潰GoDaddy網站服務器
請您可以測試這裏的搜索:http://cameras.specced.co.uk
請輸入幾個不同的相機型號,並做幾次,搜索查詢便會停止工作,該網站將不再工作。
下面是搜索查詢:
$model_search_query = $cameras_pdo->prepare("SELECT * FROM models WHERE concat_ws(' ',brand_name,model) LIKE :search LIMIT 5");
$model_search_query->execute(array(':search' => "%" . $_POST['search'] . "%"));
while ($model_search = $model_search_query->fetch(PDO::FETCH_ASSOC)) {
$brand_search_query = "SELECT brand FROM brands WHERE id =" . $model_search['brand'];
$brand_search = mysqli_fetch_assoc(mysqli_query($cameras, $brand_search_query)); ?>
<a href="compare.php?compare_1=<?php echo $model_search['id'];?>">
<div class="search_result">
<div class="search_result_image">
<!-- IMAGE REMOVED TO TEST IF THIS WAS CAUSING THE ISSUE -->
</div>
<div class="search_result_text">
<?php echo $brand_search['brand'] . " " . $model_search['model']; ?>
</div>
</div>
</a>
<?php } ?>
我已經從搜索結果只是櫃面它是太大,太多的被裝載在下拉式搜尋的同時去除圖像造成的問題,但是網站在搜索幾次後仍然崩潰。
這是我收到Safari中的錯誤,
Safari不能打開....因爲服務器意外下降的任何幫助
編輯連接...
三江源:
這裏是我的fetch.php的所有內容,包含在AJAX中,當用戶搜索標題右上角的搜索欄時,http://cameras.specced.co.uk
<?php ini_set('display_errors', 'On'); ?>
<!-- REQUIRE DB -->
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
?>
<?php
$cameras = mysqli_connect($servername, $username, $password, $dbname);
$cameras_pdo = new PDO('mysql:host=xxx;dbname=xxx', 'xxx', 'xxx');
?>
<?php
$model_search_query = $cameras_pdo->prepare("SELECT * FROM models WHERE concat_ws(' ',brand_name,model) LIKE :search LIMIT 5");
$model_search_query->execute(array(':search' => "%" . $_POST['search'] . "%"));
while ($model_search = $model_search_query->fetch(PDO::FETCH_ASSOC)) {
$brand_search_query = "SELECT brand FROM brands WHERE id =" . $model_search['brand'];
$brand_search = mysqli_fetch_assoc(mysqli_query($cameras, $brand_search_query));
p?1=' . $_POST['current'] . "&2=" . $model_search['id'] . '">';
echo '<a href="compare.php?compare_1=' . $model_search['id'] . '">'.
'<div class="search_result">' .
'<div class="search_result_image">' .
'<img src="http://www.specced.co.uk/images/cameras/[' . $model_search['id'] . ']_front.png">' .
'</div>' .
'<div class="search_result_text">' .
$brand_search['brand'] . " " . $model_search['model'] .
'</div>' .
'</div>' .
'</a>';
}
?>
任何人,我很想得到這個排序 – cousbrad