Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'civ2' in 'field list' ) 1
Bonjour,
Je suis entrain de faire une migration vers PDO en php mais je suis debutant actuellement.
J'avais l'habitude d'utiliser l'ancienne manière de travailler avec mysql (mysql_connect...) mais je veux maintenant effectuer une migration de mes pages web vers PDO où je ne me retrouve pas pour l'instant. Besoin de votre aide pour acherver la migration. Merci d'avance. Voici ci-dessous le code de la page...
Le code suivant m'affiche une erreur de ce genre:
Citation:
Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'civ2' in 'field list' ) 1
Code:
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>voeux des clients</title>
<link rel="stylesheet" href="sogim.css" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
</head>
<body>
<div id="bloc_page">
<?php
include("entete.php");
/* include("fonctions.php"); */
?>
<section class="row">
<div align="center" class="col-md-12 col-sm-12 col-xm-12">
<?php
if(isset($_POST['valider']))
{
//On récupère les valeurs entrées par l'utilisateur :
$civ=$_POST['civ'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$contact=$_POST['contact'];
$email=$_POST['email'];
$message=$_POST['message'];
//On construit la date d'aujourd'hui strictement comme sql la construit
$today = date("y-m-d");
echo '<h2>Vos informations saisies sont les suivantes<br></h2>';
echo $civ.' '. htmlspecialchars($_POST['nom']).' '.htmlspecialchars($_POST['prenom']).'<br><u>Vos contacts:</u>'.htmlspecialchars($_POST['contact']).'<br> <u>Adresse E-mail:</u> '.htmlspecialchars($_POST['email']).'</br> Ensuite <u>votre message:</u> '.nl2br (htmlspecialchars ($_POST['message'])).'<br>
<form method="POST" action="result_voeux.php" >
<input type="hidden" name="civ2" value="'.$civ.'">
<input type="hidden" name="nom2" value="'.$nom.'">
<input type="hidden" name="prenom2" value="'.$prenom.'">
<input type="hidden" name="contact2" value="'.$contact.'">
<input type="hidden" name="email2" value="'.$email.'">
<input type="hidden" name="message2" value="'.$message.'"> </br>
'.'date : '. date("y-m-d").'<br>
<input type="submit" name="annuler" value="Annuler">  
<input type="submit" name="confirmer" value="Confirmer">
</form>';
}
?>
<?php
if(isset($_POST['confirmer']))
{
//récupération des variables issues de la confirmation
$civ2=isset($_POST['civ2']) ? $_POST['civ2'] : '' ;
$nom2 = isset($_POST['nom2']) ? $_POST['nom2'] : '' ;
$prenom2 = isset($_POST['prenom2']) ? $_POST['prenom2'] : '' ;
$contact2= isset($_POST['contact2']) ? $_POST['contact2'] : '';
$email2= isset($_POST['email2']) ? $_POST['email2'] : '';
$message2= isset($_POST['message2']) ? $_POST['message2'] : '';
$today2 = date('y-m-d');
try
{
//On se connecte à mysql
$bdd = new PDO ('mysql:host=localhost;dbname=bdsogim', 'root', '');
}
catch(Exception $e)
{
//En cas d'erreur, on affiche un message et on arrète tout
die('Erreur:'.$e->get_Message());
}
$req = $bdd->prepare('INSERT INTO voeux_clients(civ2, nom2, prenom2, contact2, email2, message2, today2)
VALUES(:civ2, :nom2, :prenom2, :contact2, :email2, :message2, :today2)');
$req->execute(array(
'civ2'=>$_POST['civ2'], 'nom2'=>$nom2, 'prenom2'=>$prenom2, 'contact2'=>$contact2, 'email2'=>$email2, 'message2'=>$message2,
'today2'=>$today2)) or die (print_r($req->errorInfo()));
$req->closeCursor();
echo ' <h4>Votre demande a bien été enregistré!</h4>';
echo ' <h4>Merci de nous avoir écrit!</h4>';
}
else
{
location:header('voeux.php');
}
?>
</div>
<?php
include('new_footer.php');
?>
</section>
</div>
</body>
<script src="js/jquery.js"> </script>
<script src="js/bootstrap.min.js"></script>
</html> |
Ce code m'ffiche une erreur de ce genre:
Citation:
Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'civ2' in 'field list' ) 1
dont je ne comprends pas. Merci d'avance pour votre aide.