Błąd w MySQL o treści:
Fatal error: Call to a member function fetch_assoc() on boolean in --- on line 12
Ten skrypt obsługuję wysyłanie do bazy danych wiadomości, które są potem wyświetlane.
A o to kod:
<?php
$polaczenie = @new mysqli($host,$user,$password, $database);
if($polaczenie->connect_errno!=0)
{
echo "Error: ".$polaczenie->connect_errno;
exit();
}
$data = $_COOKIE['login'];
$query = "SELECT * FROM users WHERE login='$data'";
$results= $polaczenie->query($query);
$data = $results->fetch_assoc();
if(isset($_POST['send']))
{
$send = htmlentities($_POST['send'], ENT_QUOTES);
$lsend = strlen($send);
if($lsend>400)
{
header("Location:chat.php");
exit();
}
else
{
$id = $data['id'];
$time = date('H:i:s');
$polaczenie->query("INSERT INTO messages SET idu='$id', content = '$send', time = '$time'");
header("Location:chat.php");
exit();
}
}
?>