php - ERROR WHILE INSERTING USING MYSQLI -


i'm new php please me here i'm unable insert values table. if gave values directly insert command in place of variables works.

<?php include ("db.php");  $msg = ""; if(isset($_post["submit"])) {     $name = $_post["name"];     $email = $_post["email"];     $password = $_post["password"];     $name = mysqli_real_escape_string($db, $name);     $email = mysqli_real_escape_string($db, $email);     $password = mysqli_real_escape_string($db, $password);     $password = md5($password);     $sql="select email users2 email='$email'";     $result=mysqli_query($db,$sql);     $row=mysqli_fetch_array($result,mysqli_assoc);     if(mysqli_num_rows($result) == 1)     {         $msg = "sorry...this email exist...";     }     else     {         $query = mysqli_query($db, "insert users2 (name, email, password)values ('$name', '$email', '$password')");         if($query)         {             $msg = "thank you! registered.";         }     } } ?> 

$sql = "insert users2 (name, email, password) values (?,?,?)";             if (!$stmt = $db->prepare($sql)) {             die($db->error);             }             $stmt->bind_param("sss", $name, $email, $password);             if (!$stmt->execute()) {             die($stmt->error);             } 

i don't know problem in above question used above query instead of 1 put in question , succedded. if 1 still know whats problem there in question please let me know.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -