无法在SQLite表中插入字符串,但可以编号

Can naybody tell me what this means

INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES('s',1,1,1,1,1);

but when I try

INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES(1,1,1,1,1,1);

it works. I cannot insert string ? What is wrong ? My SQLite table looks like

CREATE TABLE users (
  id          integer PRIMARY KEY AUTOINCREMENT NOT NULL,
  first_name  varchar(50),
  last_name   varchar(50),
  email       varchar(50),
  username    varchar(50),
  password    varchar(50),
  privilege   varchar(50)
);

and my PHP function looks like

public function insert_user($first_name, $last_name, $email, $username, $password, $privilege) {
    try {
        $db = new SQLite3($this->db_path);

        $db->query("INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES($first_name,$last_name,$email,$username,$password,$privilege);");

        $last_id = $db->lastInsertRowID();
        $db->close();
        return $last_id;
    } catch (Exception $e) {
        echo 'Exception caught: ', $e->getMessage(), "
";
    }
}
$db->query("INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES('$first_name','$last_name','$email','$username','$password','$privilege');")

Missing a ' around the variables. Might want to escape values first. Debugging tip: Put your query into a variable, echo that variable and try it.

You have to use '..' with strings in VALUES

 $db->query("INSERT INTO users(first_name,last_name,email,username,password,privilege) VALUES('$first_name','$last_name','$email','$username','$password','$privilege');");

Don't you need to turn

     VALUES($first_name,$last_name,$email,$username,$password,$privilege

into

     VALUES('$first_name','$last_name','$email','$username','$password','$privilege' )

MySQL/PHP accept numbers without the ''s, but not strings. Also, you might want to escape your input using a default PHP function.

Did you try to insert data using SqliteManager? I mean do you know that problem was caused from php script or database. If you try to run your query on sqlitemanager. Also try to use "s" with ( " )not ( ' )