Skip to content

Instantly share code, notes, and snippets.

@Blueblazer172
Created June 19, 2016 20:54
Show Gist options
  • Save Blueblazer172/b727e6180c91b27ed4931d339f212db0 to your computer and use it in GitHub Desktop.
Save Blueblazer172/b727e6180c91b27ed4931d339f212db0 to your computer and use it in GitHub Desktop.
Connect to mysql-database by PDO
<?php
try {
$db = new PDO("mysql:dbname=gaestebuch;host=localhost",
"root",
"Bananafone+5106");
$sql = "CREATE TABLE gaestebuch (
id INTEGER PRIMARY KEY,
ueberschrift VARCHAR(1000),
eintrag VARCHAR(5000),
autor VARCHAR(50),
email VARCHAR(100),
datum TIMESTAMP
)";
$db->exec($sql);
echo "Tabelle angelegt.";
} catch (PDOException $e) {
echo 'Fehler: ' . htmlspecialchars($e->getMessage());
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment