J'ai recherché des solutions mais je n'en trouve pas donc je viens vous demander votre aide.Warning: PDO::query(): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bagabaga' in 'where clause' in C:\wamp\www\recherche+profil\profil_ext.php on line 20
La première page de recherche marche parfaitement:
<head>
<style>
table{
border:1px solid black;
border-radius:5px;
}
a{
text-decoration:none;
color:black;
}
a:hover{
color:blue;
}
td{
border:1px solid black;
}
</style>
</head>
<body>
<?php
try {
$cnx = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$cnx-> setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
}
catch (PDOException $e) {
echo '<code>'.$e->getMessage().'<br />'.$e->getTraceAsString(),'</code>';
}
if (isset($_POST['recherche'])) {
$post=$_POST["recherche"];
$sql = $cnx->query("SELECT * FROM phpmembre WHERE prenom LIKE '%$post%'");
echo '<table>';
while($donnees = $sql->fetch()){
echo '<tr><td><a href="profil_ext.php?profil=' . $donnees['prenom'] . '">'.ucfirst(stripslashes($donnees['prenom'])).'</a></td></tr>';
}
echo '</table>';
}
else{ ?>
<form action='recherche.php' method='post'>
<input type="text" name="recherche" requiered/>
</form>
<?php } ?>
</body>
Mais la deuxième page m'affiche l'erreur si dessus :
<html>
<head>
</head>
<body>
<?php
// recherche : form + SQL qui cherche en fonction de la chaine de caractère entrée
// passer par le $_GET pour voir le profil puis afficher les info (exemple : rediger_news.php) ?>
<?php
try {
$cnx = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$cnx-> setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);
}
catch (PDOException $e) {
echo '<code>'.$e->getMessage().'<br />'.$e->getTraceAsString(),'</code>';
}
if(isset($_GET['profil'])){
var_dump ($_GET);
$get=$_GET['profil'];
$sql = $cnx->query("SELECT * FROM phpmembre WHERE prenom=$get");
while ($donnees = $sql->fetch()){
echo $donnees['email'];
}
}
?>
</body>
</html>
Le var_dump de la ligne 19 m'affiche pourtant bien le $_GET donc je ne sais pas quoi faire. Pourriez vous m'aider s'il vous plait ???