SQLite3无法识别的令牌警告

时间:2013-12-01 19:34:21

标签: php sqlite

当我尝试在PHP中执行我的SQLite3语句时,我得到以下内容:

Warning: SQLite3::exec(): unrecognized token: "38360f81b43f97437a01ce7294ce41f9" in /path/to/register.php on line of error

所以我去看一下执行:

$user = $_POST['username'];
$pass = $_POST['password'];

$encrypted_pass = md5($pass);

class DB extends SQLite3{
    function __construct(){
            $this->open('/path/to/db/userpass.db')
    }
}

$db = new DB();

$stmt = 'INSERT INTO userpass VALUES(' . $user . ', ' . $encrypted_pass . ');';

if($db->exec($stmt)){ //line of error
    header('Location: http://192.168.1.147/registered.html');
} else {
    die(1);
}

如您所见,$pass经过哈希处理并存储为$encrypted_pass,用于插入我的表格。

2 个答案:

答案 0 :(得分:0)

错了

$stmt = 'INSERT INTO userpass VALUES(' . $user . ', ' . $encrypted_pass . ');';

这没关系!

$stmt = "INSERT INTO userpass VALUES(' . $user . ', ' . $encrypted_pass . ');";

$stmt = 'INSERT INTO userpass VALUES(" . $user . ", " . $encrypted_pass . ");';

答案 1 :(得分:-1)

在这一行上缺少分号

$this->open('/path/to/db/userpass.db');

并从此处删除分号

$stmt = 'INSERT INTO userpass VALUES(' . '$user' . ', ' . '$encrypted_pass' . ')';