PHP/MySQL : why my query doesn't work? -
i'm on cloud9 web project, can insert database in mysql using mysqli command. when try select data database query doesn't work : (the echo $result don't print anything). ideas ?
maybe better use pdo command ?
<?php //connect $servername = getenv('ip'); $username = getenv('c9_user'); $password = ""; $database = "myproject"; $dbport = 3306; // create connection $bdd = new mysqli($servername, $username, $password, $database, $dbport); // check connection if ($bdd->connect_error) { die("connection failed: " . $bdd->connect_error); } echo "connected (".$bdd->host_info.")"; $pseudonyme = $_post['pseudo']; $mot_de_passe = $_post['mdp']; $confirm_mdp = $_post['confirm_mdp']; $email = $_post['email']; if($mot_de_passe == $confirm_mdp) { $mot_de_passe = crypt($mdp); $pseudonyme = htmlspecialchars($pseudonyme); //verifying user mail in base $reqverif = $bdd->prepare('select id_utilisateur utilisateurs adresse_email = ?'); $reqverif->bind_param("sss",$email); $reqverif->execute(); $result = $reqverif->fetch(); //user exist in db if($result) { ?> <div class="nouveau_membre" > <p>you have account...</p> </div> <?php } else { //in case of new user $req = $bdd->prepare('insert utilisateurs(pseudonyme, mot_de_passe, adresse_email, date_inscription) values(?, ?, ?, curdate())'); $req->bind_param("sss", $pseudonyme, $mot_de_passe, $email); $req->execute(); ?> <div class="nouveau_membre" > <p>new user !</p> </div> <?php } } ?>
you binding email parameter, dont need 3 "s"
$reqverif->bind_param("sss",$email);
try:
$reqverif->bind_param("s",$email);
Comments
Post a Comment