Here is my code:

<?php class DB { private static function connect() { $pdo = new PDO('mysql:host=127.0.0.1;dbname=social;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); if (explode(' ', $query)[0] == 'SELECT') { $data = $statement->fetchAll(); return $data; } } } DB::query('INSERT INTO users VALUES (\'\', :username, :password, :email, \'0\', \'\')', array(':username'=>$username, ':password'=>password_hash($password, PASSWORD_BCRYPT), ':email'=>$email)); ?> 

error code:

 Fatal error: Uncaught PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 in C:\xampp\htdocs\sn2\classes\DB.php:12 Stack trace: #0 C:\xampp\htdocs\sn2\classes\DB.php(12): PDOStatement->execute(Array) #1 C:\xampp\htdocs\sn2\create-account.php(22): DB::query('INSERT INTO use...', Array) #2 {main} thrown in C:\xampp\htdocs\sn2\classes\DB.php on line 12 

Base Danih 100% connected ...


  • did you try to translate the error message? it seems that the number of inserted values ​​does not match their number of columns in the table. - teran
  • but in my opinion it’s more interesting that the error contains the query insert into use.. , which is not in the question code. - teran
  • corrected for that request what is needed - Ostap34PHP
  • Thank! indeed, the number of inserted values ​​does not match their number of columns in the table - Ostap34PHP

0