Home >Backend Development >PHP Tutorial >php-网页中PHP代码向sqlite数据库写数据时,“000...0”这样的字符串会被存储为0,求解原因?

php-网页中PHP代码向sqlite数据库写数据时,“000...0”这样的字符串会被存储为0,求解原因?

WBOY
WBOYOriginal
2016-06-02 11:27:431015browse

phpsqlite

如题,我用PHP向sqlite的一个表中写数据,包含用户名和密码两个字段,但是当字段值(用户名或密码)是类似“000...0”这样的值时,数据库中保存的字段值就只剩下一位0了。
PHP代码如下

<code><?php $name=$_POST["username"];$password=$_POST['password'];echo gettype($password);   //这句用来测试password是何种数据类型,经验证是string,可既然是字符串为何会遗失数据呢?class MyDB extends SQLite3{    function __construct()    {        $this->open('survey.db');    }}$db = new MyDB();if(!$db){    echo $db->lastErrorMsg();} else {    echo "Opened database successfully\n";}$sql =exec($sql);if(!$ret){    echo $db->lastErrorMsg();} else {    echo "Records created successfully";}$db->close();?> </code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn