0

I am new to coding, trying to create a simple registration form using php and mysql ..but this error I dont know Why it says the table is read only can somebody help me fix it

This is the error

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1036 Table 'tablename' is read only in C:\xampp\htdocs\Laravel\Project\public\classes\DB.php:15 Stack trace: #0 C:\xampp\htdocs\Laravel\Project\public\classes\DB.php(15): PDOStatement->execute(Array) #1 C:\xampp\htdocs\Laravel\Project\public\create-account.php(14): DB::query('INSERT INTO sig...', Array) #2 {main} thrown in C:\xampp\htdocs\Laravel\Boss\public\classes\DB.php on line 15

and this the DB.php file

class DB{
    private static function connect(){
        $pdo=new pdo('mysql:host=127.0.0.1;dbname=boss;charset=utf8','root','');
        $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        return $pdo;
    }

    public static function query($query,$params=array()){

        $statement=self::connect()->prepare($query);
        $statement->execute($params);
        //$data = $statement->fetchAll();
        //return data;
    }
}
A.A Noman
  • 5,244
  • 9
  • 24
  • 46
jthinks
  • 1
  • 1
  • 1
    so check what permissions have been granted – Funk Forty Niner Feb 10 '18 at 13:56
  • Maybe see https://stackoverflow.com/questions/9575914/table-is-read-only – Syscall Feb 10 '18 at 14:03
  • I just googled some solutions for this and most where insisting the primary key is must in the table so just thought that it is necessary to mention that I do have two different columns as primary key and one among that is autoincremented – jthinks Feb 10 '18 at 14:21
  • Change your new table Storage Engine. You can do it on Operation menu on your phpmyadmin or other mysql visual administrator. Compare it with your old tables Storage Engine. In my case, my new tables Storage Engine is default set to MRG_MYISAM. My old tables is InnoDB. So I change my new table Storage Engine to InnoDB, then it worked, writable. – jthinks Feb 17 '18 at 13:24

0 Answers0