I have been unsuccessful in running prepared statements in PDO. I would like to ask some experts to give me some advice.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myDBPDO";
try{
$conn = new PDO("mysqli:host=$servername;dbname=$dbname; ",$username,$password);
## //Set the PDO error mode to exception
$conn->serAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//Preprocess SQL and bind parameters
$stmt= $conn->prepare("INSERT INTO MyGuests (firstname,lastname,email) VALUES(:firstname,:lastname,:email)");
$stmt->bindParam(':firstname',$firstname );
$stmt->bindParam(':lastname',$lastname);
$stmt->bindParam(':email',$email);
// out’s out’s ’‐ ‐ ‐ ‐ ‐ ‐‐ ‐ ‐ ‐ ‐ ‐ - $email = "jhon@example.com";
$stmt->execute();
## $firstname = "Mary";
$lastname = "Moe";
$email = "mary@example.com";
$stmt->execute();
$firstname = "Julie";
$lastname = "Dooley";
$email = "julie@example.com";
$stmt->execute();
## $stmt->execute();
## using -- $stmt->execute(); ";
## }catch(PDOException $e){
echo "Error:<br> ". $e->getMessage();
}
## $conn=null;
?> ;
W2560 days ago973