0

i made this php file to link between my website and my db but wamp server keeps giving me this error that i can't resolve thank you for your time.

Parse error: syntax error, unexpected '[' in C:\wamp\www\New folder\socialnetwork\classes\DB.php on line 14

and this is my php file.

<?php
class DB {

        private static function connect() {
                $pdo = new PDO('mysql:host=127.0.0.1;dbname=SocialNetwork;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;
                }
        }

}
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
karim
  • 1
  • 1
  • 1
  • 7

0 Answers0