Bonjour,
Je dois importer une bdd en php mais quand j'exécute mon code ça ne marche pas. Pouvez m'indiquer ce qui ne va pas ?
merci d'avance,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 <!Doctype html> <html lang="fr" dir="ltr"> <head> <meta charset="utf-8"> <title>The Voice - Votez !</title> </head> <body> <p> <IMG src="TheVoiceLogo.png"/> </p> <h1><strong>Votez pour votre candidat.e préféré.é</strong></b> <p> <?php $dsn = 'mysql:dbname = thevoice_bdd; host=localhost'; $user = 'root'; $password = ''; try{ $connexion = new PDO("mysql:host=localhost; dbname = thevoice_bdd"); } catch (PDOException $e) { echo $e->getMessage(); } $sth = $dbh->prepare('SELECT * FROM candidat'); $sth->execute(); $rows_of_candidat = $sth->fetchAll(); foreach ($rows_of_candidat as $row){ echo "<p>"; echo $row[1]; echo "</p>"; } ?> </p> </body> </html>
VIVI
Partager