Jump to content

Uncaught PDOException: SQLSTATE[HY093]:


Ehsan_Nawaz
 Share

Recommended Posts

<?php
require_once("config.php");

if(isset($_POST["register"])){

$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$username = $_POST["username"];
$email = $_POST["email"];

global $cn;

$sql ="INSERT INTO reg(firstname,lastname,username,email,password) VALUES(:firstname,:lastname,:username,:email,:passowrd)";

$stmt = $cn->prepare($sql);



$stmt->bindValue(":firstname",$firstname);
$stmt->bindValue(":lastname",$lastname);
$stmt->bindValue(":username",$username);
$stmt->bindValue(":email",$email);
$stmt->bindValue(":password",$password);

$run=$stmt->execute();

if($run) {
  echo "Data Upload";
}
}
?>


here is my databse code

<?php
session_start();


$servername = "localhost";
$username = "root";
$password = "";

try {
    
$cn = new PDO("mysql:host=$servername;dbname=login",$username,$password);
$cn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

} catch (PDOException $e) {
    
    echo "Server Offline" . $e->getMessage();
}




?>

 

Link to comment
Share on other sites

Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\xampp\htdocs\portfilo\index.php:25 Stack trace: #0 C:\xampp\htdocs\portfilo\index.php(25): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\portfilo\index.php on line 25

 

 

here this error

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.