Ehsan_Nawaz Posted March 18, 2022 Share Posted March 18, 2022 <?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(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/314608-uncaught-pdoexception-sqlstatehy093/ Share on other sites More sharing options...
Ehsan_Nawaz Posted March 18, 2022 Author Share Posted March 18, 2022 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 Quote Link to comment https://forums.phpfreaks.com/topic/314608-uncaught-pdoexception-sqlstatehy093/#findComment-1594424 Share on other sites More sharing options...
ginerjm Posted March 18, 2022 Share Posted March 18, 2022 Check your spelling.... Quote Link to comment https://forums.phpfreaks.com/topic/314608-uncaught-pdoexception-sqlstatehy093/#findComment-1594426 Share on other sites More sharing options...
Strider64 Posted March 19, 2022 Share Posted March 19, 2022 and make sure you are inserting all the data if that is the whole script.... Quote Link to comment https://forums.phpfreaks.com/topic/314608-uncaught-pdoexception-sqlstatehy093/#findComment-1594430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.