mysql - Order by After Where clause not working in MySQLi PHP

one text

Order By After Where is not returning results below is the code and screenshot of not running code.

SELECT * from `SalesMessages` where `ThreadId`= ? ORDER BY `id` desc Limit 25;

However if I remove bind params it works fine.

SELECT * from `SalesMessages` where `ThreadId`=63 ORDER BY `id` desc Limit 25;

Below is screen shot from mySql

mysql query and results

HERE IS HOW I WROTE MYSQLI Code


    global $conn;
    $arr = array();
    mysqli_set_charset( $conn, 'utf8'); // ALREADY TRIED COMMENTING THIS LINE
    $stmt = $conn->prepare($query);
    $stmt->bind_param('i', $ThreadId);
    try {
        if ($stmt->execute()) {
            $result = $stmt->get_result();
            while ($row = $result->fetch_assoc()) {
                ..SOME CODE..
            }
            if (count($arr) > 0)
                return $arr;
        } else {
            throw "QueryError";
        }
    } catch (Throwable $e) {
        print_r($e);
    }
}

Here is the structure of Table

DATA BASE STRUCTURE

I am expecting results from mysql in PHP code as array.

Source