* @var mixed
*/
private $nom;
/**
* @var mixed
*/
private $prenom;
/**
* @var mixed
*/
private $pseudo;
/**
* @var mixed
*/
private $password;
/**
* @var mixed
*/
private $type;
/**
* @param $nom
* @param $prenom
* @param $password
* @param $pseudo
* @param $type
*/
public function __construct($nom, $prenom, $password, $pseudo, $type)
{
$this->nom = $nom;
$this->prenom = $prenom;
$this->pseudo = $pseudo;
$this->password = $password;
$this->type = $type;
}
public function Insertion()
{
$nom = $this->nom;
$prenom = $this->prenom;
$password = $this->password;
$pseudo = $this->pseudo;
$type = $this->type;
$id = 1;
if (extension_loaded('PDO'))
{
echo 'PDO OK<br>';
}
else
{
echo 'PDO KO<br>';
}
try {
$bdd = new PDO('mysql:host=localhost;bdname=mlr18', 'root', '');
}
catch (Exception $e)
{
die('Error' . $e->getMessage());
}
$queryArray = [
'id' => $id,
'CMT_PSEUDO' => $pseudo,
'CMT_NOM' => $nom,
'CMT_PRENOM' => $prenom,
'CMT_PASSWORD' => $prenom,
'CMT_TYPE' => $type,
];
$rec = $bdd->prepare('INSERT INTO compte (id, CMT_PSEUDO, CMT_NOM, CMT_PRENOM, CMT_PASSWORD, CMT_TYPE) VALUES (:CMT_PSEUDO, :CMT_NOM, :CMT_PRENOM, :CMT_PASSWORD, :CMT_TYPE) ');
if ($rec->execute($queryArray))
{
$count = $rec->rowCount();
echo count . 'row updated';
}
else
{
print_r($rec->errorInfo());
}
}
}
there is the same typo with bdname in it
Обсуждают сегодня