1
<?php #connect.php connect to the mysql server define('DB_HOST','localhost'); define('DB_PORT', '3306'); define('DB_NAME', 'cookbook'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', ''); try{ $dns = 'mysql:host='.DB_HOST.';port='.DB_PORT.';dbname=' . DB_NAME; $pdo = new PDO($dns , DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); $pdo->exec('set session sql_mode = traditional'); $pdo->exec('set session innodb_strict_mode = on'); $stmt = $pdo->prepare('select * from firstNmae'); $stmt->execute(); $resute = $stmt->fetchAll(); echo'<pre>'; print_r($resute); echo '</pre>'; } catch(PDOException $e){ die(htmlspecialchars($e->getMessage())); } 

And when tryprint_r(PDO::getAvailableDrivers()); it returns this result Array ( [0] => sqlite )

2
  • Welcome to StackOverflow. Please can you properly format the code in your question by making sure there are 4 spaces before every line of code. and be more specific as to what your question is. You can get help with this by checking out (stackoverflow.com/help/how-to-ask) Commented Feb 7, 2016 at 3:37
  • 1
    I think omiting port='.DB_PORT.'; work for you Commented Feb 7, 2016 at 3:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.