如何将SQLite连接到php ERROR

this is my code. I am using xampp version 7.when i run this code output for like this (Fatal error: Class 'SQLite3' not found in C:\xampp\htdocs\sqlite\index.php) .Default included sqlite3 dll file in /php/ directory and php.ini file included extension=php_sqlite3.dll

<?php
  class MyDB extends SQLite3
   {
     function __construct()
     {
       $this->open('company.db');
     }
    }
   $db = new MyDB();
   if(!$db){
      echo $db->lastErrorMsg();
   } else {
     echo "Opened database successfully
";
   }
?>

how run sqlite in xampp version 7

php
dousonghs58612
dousonghs58612 是啊JYoThI它安装了SQLiteLibrary3.8.10.2
接近 4 年之前 回复
douyong1285
douyong1285 检查phpinfo()并查看sqlite的驱动程序是否安装正确?
接近 4 年之前 回复
doskmc7870
doskmc7870 您是否在php.ini中取消注释/激活extension=php_sqlite3.dll?
接近 4 年之前 回复

1个回答

I tried the code below and it worked for me

<?php
  class MyDB extends SQLite3
   {
     function __construct()
     {
       $this->open('mydb.sq3');
     }
    }
   $db = new MyDB();
   if(!$db){
      echo $db->lastErrorMsg();
   } else {
     echo "Opened database successfully
";
   }
?>

The extension of the sqlite3 database should be .sq3 and not .db

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐