mysql查询无法更新

Mysqli query not updating table with custid
    // Create connection
            $db = mysqli_connect($servername, $username, $password, $dbname);
            // Check connection
            if (!$db) {
                die("Connection failed: " . mysqli_connect_error());
            }

    //$query = "Select expiry from AcctSession where id ='$id' ";
     echo $custid.$id; //works fine here

     $query = "update sessions SET custid = '$custid' where id = '$id' ";

            if (mysqli_query($db, $query)) {
                echo "Record updated successfully";
            } else {
                echo "Error updating record: " . mysqli_error($db);
            }

I've tried echoing $query Query works fine on command line but it doesn't write any result when firing from php script(Plus, no error msg as well)