Created
June 19, 2016 20:54
-
-
Save Blueblazer172/b727e6180c91b27ed4931d339f212db0 to your computer and use it in GitHub Desktop.
Connect to mysql-database by PDO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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