This piece of code gives me a syntax error, but I can't figure out why.
Parse error: syntax error, unexpected T_STRING in C:\Users\user\school\infPOPHP2\USBWebserver v8.5\8.5oot\create_db.php on line 7
line 7 is
$db = new PDO("mysql:host=$hostname;dbname=$dbname",$username,$password);
This is the full code
<?php
$hostname = "localhost";
$username = "root";
$password = "usbw";
$dbname = "competitie";
try {
$db = new PDO("mysql:host=$hostname;dbname=$dbname",$username,$password);
$sql = "CREATE DATABASE IF NOT EXISTS competitie" ;
$resultaat = $db>exec($sql);
$db = NULL;
}
catch(PDOException $e) {
echo $e>getMessage();
}
?>