Message d'erreur PDO
Posté : 12 avr. 2010, 19:49
Bonsoir,
Ca yier je me met à PDO. Donc je convertie mes petits scripts tant bien que mal
Mais je garde le sourire
Fatal error: Non-static method PDO::lastInsertId() cannot be called statically in C:\wamp\www\Php\2Jean Engels\mysql_pdo\index2.php on line 53
ça change tellement de l'ordinaire que je ne vois pas trop
Merci
Ca yier je me met à PDO. Donc je convertie mes petits scripts tant bien que mal
<?php
include("mysqlconnex.inc.php");
if(!empty($_POST["nom"]) && !empty($_POST["prenom"]) )
{
$id="\N";
$nom=$_POST["nom"];
$prenom=$_POST["prenom"];
$mail=$_POST["mail"];
//requêtes
if(!empty($mail))
{$mail="'".$mail."'";}
else{$mail="DEFAULT";}
$id_con=connPDO();
$requete="INSERT INTO personne VALUES('$id','$nom','$prenom',$mail)";
$result=$id_con->exec($requete);
if(!$result)
{
$erreur=$id_con->errorInfo();
echo'Erreur d\'insersion code: '.$id_con->errorCode().' : '.$erreur[2];
}
else
{ $id=PDO::lastInsertId(); X
echo'Enregistrement reussie ! votre Id:'.$id.'<br/>';
echo "<script type=\"text/javascript\">setTimeout(\"window.location='".$url."affichage.php'\",3000)</script>";
//echo'<meta http-equiv="refresh" content="3; URL=http://'.$host.$url.'affichage.php"/>';
}
$id_con=null;
}
elseif(empty($result)) {echo'<h1>Merci de remplir</h1>';}
?>
J'ai un petit soucis sur le X . J'ai remplacé mysql_insert_id() par PDO::lastInsertId(); mais j'ai ce message d'erreur :Fatal error: Non-static method PDO::lastInsertId() cannot be called statically in C:\wamp\www\Php\2Jean Engels\mysql_pdo\index2.php on line 53
ça change tellement de l'ordinaire que je ne vois pas trop
Merci