Je voudrais savoir pourquoi est-ce que j'ai toujours une erreur lorsque je veux tester ce code.
Ceci est la ligne d'erreur
(
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''veneto'' at line 1 in C:\xampp\htdocs\PHP\index.php:35 Stack trace: #0 C:\xampp\htdocs\PHP\index.php(35): PDO->query('SELECT * FROM '...') #1 {main} thrown in C:\xampp\htdocs\PHP\index.php on line 35
)
Ceci est la ligne d'erreur
(
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''veneto'' at line 1 in C:\xampp\htdocs\PHP\index.php:35 Stack trace: #0 C:\xampp\htdocs\PHP\index.php(35): PDO->query('SELECT * FROM '...') #1 {main} thrown in C:\xampp\htdocs\PHP\index.php on line 35
)
<?php
define("DBHOST", "localhost");
define("DBUSER", "root");
define("DBPASS", "");
define("DBNAME", "concours");
$dsn = "mysql:dbname=".DBNAME. ";host=" .DBHOST;
try
{
$db = new PDO($dsn, DBUSER, DBPASS);
$db->exec("SET NAMES utf8");
}
catch(PDOException $e)
{
die($e->getMessage());
}
$sql = "SELECT * FROM 'veneto'";
$requete = $db->query($sql); [#red] ( Ligne 35)[/#]
$user = $requete->fetch();
echo "<pre>";
var_dump($sql);
echo "</pre>";
?>