Вставка данных в таблицу 2 с помощью PHP
Hi everyone, I'm new to PHP, so I need help from your. Currently I have 2 table for database Customer and Login. Table Customer (CustID, CustName, Phone) CustID primary key, auto increment. Table Login (Email, Password, CustID) Email Primary key, CustID Foreign key to table Customer Now, I can insert all the detail into table customer, but I can't insert any data into table login, it shows the Error "<i>PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\xampp\htdocs\Assignment\suSuccess.php on line 74"</i>
//Connection try { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = "pizza"; $odb = new PDO("mysql:host=" . $dbhost . ";dbname=" . $dbname, $dbuser, $dbpass); } catch (PDOException $ex) { echo $ex->getMessage(); exit(); } $q = "INSERT INTO customer (`CustName`, `DOB`, `Address`, `Phone`) VALUES (:name, :dob, :address, :phone)"; $query = $odb->prepare($q); $result = $query->execute(array( ":name" => $name, ":dob" => $dob, ":address" => $address, ":phone" => $phone )); if ($result > 0) { $id = $odb->lastInsertId(); $q2 = "INSERT INTO login (`Email`,`Password`,`CustID`) VALUES (:email, :password,:custid)"; $query2 = $odb->prepare($q2); $result2 = $query2->execute(array( ":email" => $email, ";password" => $password, ":custid" => $id )); //<----- Here is the error echo $odb->lastInsertId(); if ($result2 > 0) { echo "Sucess"; } else { echo "Fail"; } } else { echo "Fail"; }
Что я уже пробовал:
Я не уверен, правильно ли код вставляет данные в мою таблицу входа.