在第86行的C:\ wamp64 \ www \ includes \ functions.php中调用成员函数prepare()

This is my function that is giving errors do not know why it is not executing at all and this if statement is line 86

if($stmt = $mysqli->prepare("SELECT time FROM login_attempts WHERE user_id=? AND time > '$valid_attempts'"))
{
    $stmt->bind_param('i', $user_id);
    $stmt->execute();
    $stmt->store_result();

    if($stmt->num_rows > 3)
    {
        return true;
    }
    else
    {
        return false;
    }
} 

I have this file to define details of db

<?php

define("HOST", "localhost:3311");     // The host you want to connect to.
define("USER", "root");    // The database username. 
define("PASSWORD", "root");    // The database password. 
define("DATABASE", "compared");    // The database name.

define("CAN_REGISTER", "any");
define("DEFAULT_ROLE", "member");

define("SECURE", FALSE);   
?>

And to create connection here this is the file

<?php 
include_once "C:/wamp64/www/includes/psl-config.php";

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);       


?>

But it keeps giving error

Change '$valid_attempts' to ? and use bind params like you used with i