please, could someone help me what is my mistake? Creating a database works well but when I create a table it makes this SQLSTATE error[3D000]: Invalid catalog name: 1046 No database selected Here are the codes:
<? php
$server = 'localhost';
$login = 'root';
$password = '';
try{
$connexion = new PDO('mysql:host = $server; dbname=test', $login, $password);
$connexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connexion->exec("CREATE TABLE utilisateur(nom varchar(50))");
echo 'Réussi';
}
catch(PDOException $e){
echo 'Echec de la connexion : '.$e->getMessage();
}
?>