Bonjour,
J'ai fais un système de connexion pour mes membres, celui-ci fonctionner parfaitement mais maintenant, il fais des siennes.
L'erreur:
exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Key = '****'' at line 1' in /var/www/html/ucp/system/mysql.php:38 Stack trace: #0 /var/www/html/ucp/system/mysql.php(38): PDO->query('SELECT * FROM p...') #1 /var/www/html/ucp/system/loggin.php(10): mysqlfunctions->myQuery('SELECT * FROM p...') #2 {main}
Je n'ai pas toucher au fichiers mentionné et c'est bien cela le problème..
Voilà la partie de code de la page qui pose problème:
Mysql.php
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
| <?php
class mysqlfunctions {
var
$isConnected = false,
$ConnectionError = false,
$pdo = null
;
const dns = "mysql:host=localhost;dbname=serveur;charset=utf8";
const user = "root";
const pw = "*****";
public function __construct ()
{
try {
$this->PDO = new PDO( mysqlfunctions::dns , mysqlfunctions::user , mysqlfunctions::pw ,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$this->isConnected = true;
}
catch ( PDOException $ex ) {
$this->isConnected = false;
$this->ConnectionError = $ex;
die ( $ex ) ;
}
}
public function myQuery ( $query , $value = null)
{
if ( !$value )
$result = $this->PDO->query ( $query ) ;
else
$result = $this->PDO->query ( $query , $value ) ;
try {
return $result;
}
catch ( PDOException $ex ){
return $ex;
}
}
}
error_reporting ( E_ALL ) ;
ini_set ( 'display_errors', 1 ) ;
?> |
loggin.php:
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
| <?php
include ( 'mysql.php' ) ;
include ( 'config.php') ;
if ( isset ( $_POST['username'] ) AND isset ( $_POST['pw'] ) )
{
$mysql = new mysqlfunctions();
$user = addslashes ( $_POST['username'] ) ;
$pw = addslashes ( $_POST['pw'] ) ;
try {
$querys = $mysql->myQuery ( "SELECT * FROM ".$userDB." WHERE ".$nameDB." = '".$user."' AND ".$pwDB." = '".$pw."'" ) ;
}
catch ( PDOException $ex ) {
die ( $ex ) ;
}
if ( $querys )
{
if ( $querys->rowCount() != 0 )
{
foreach ( $querys as $row )
{
$_SESSION['inSystem'] = $row [ $selectBy ];
}
header ( "location:../index.php" ) ;
}
else header ( "location:../index.php?act=errorNoAccount" ) ;
}
else die ( "mySQL ERROR" ) ;
}
else header ( "location:../index.php?act=errorFields" ) ;
?> |
Que faire?
Cordialement.
Partager