Здравствуйте! Нужно исправить ошибку в php скрипте, мои знания по нему 0, но пофиксить нужно срочно!
<?php
$servername = "a136237.mysql.mchost.ru";
$username = "a136237_skk1";
$password = "Пароль";
try {
$connect = new PDO("mysql:host=$servername; dbname=a136237_skk", $username, $password);
}
catch (PDOException $e){
echo "Connect failed: " . $e->getMessage();
}
if(isset($_POST['submit'])){
$search = explode(" ", $_POST['search']);
$count = count($search);
$array = array();
$i = 0;
foreach($search as $key) {
$i++;
if($i < $count) $array[] = "CONCAT (`title`, `text`) LIKE '%".$key."%' OR "; else $array[] = "CONCAT (`title`, `text`) LIKE '%".$key."%'";
}
$sql = "SELECT * FROM `test` WHERE ".implode("", $array);
$query = mysqli_query($connect, $sql);
while($row = mysqli_fetch_assoc($query)) echo "<h1>".$row['title']."</h1><p>".$row['text']."</p></br>";
}
?>