Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = '127.0.0.1';
- $db = 'test';
- $user = 'root';
- $pass = 'blah';
- $charset = 'utf8';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; // data source name
- $dbh = new PDO("$dsn", $user, $pass)
- function create_db() {
- try {
- $dbh->exec("CREATE DATABASE `$db`;") or die(print_r($dbh->errorInfo(), true));
- } catch (PDOException $e) {
- die("DB ERROR: " . $e->getMessage());
- }
- return 0;
- }
- create_db();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement