I cannot insert data into databae with php pdo | SoloLearn: Learn to code for FREE!

0

I cannot insert data into databae with php pdo

Hello guys I cannot figure out what is wrong with this code why it does not send information to database can anyone try it for me if there is just problem with my database connection which probably not because I used try and catch and everything looks fine --- ``` else { $first = $_POST['first']; $last = $_POST['last']; $email = $_POST['email']; $username = $_POST['username']; $password = password_hash($_POST['password'], PASSWORD_DEFAULT); include_once 'database.php'; $query = "USE". $database . "INSERT INTO USERS(FIRST, LAST, EMAIL, USERNAME, PASSWORD) VALUES (:FIRST, :LAST, :EMAIL, :USERNAME, :PASSWORD))"; $sql = $connect->prepare($query); $fields = array( ':FIRST' => $first, ':LAST' => $last, ':EMAIL' => $email, ':USERNAME' => $username, ':PASSWORD' => $password, ); $sql->execute($fields); $code = $sql->errorCode(); $error = '<div class="alert alert-danger" role="alert">ERROR CODE :' . $code . '! </div>'; } ``` ---

4/14/2020 2:53:05 PM

Jalal Mitali

0 Answers

New Answer