Hi everyone! what's wrong with this code? Visual Studio Code says "Unexpected EndOfFile". It ends on ";"

<?php include("../controllers/connectdb.php");

$first_name = $_POST["first_name"];

$last_name = $_POST["last_name"];

$age = $_POST["age"];

$dni = $_POST["dni"];

$email = $_POST["email"];

$password = $_POST["password"];

$sql = "INSERT INTO usuario(first_name,last_name1,age,dni,email,password) VALUES(?,?,?,?,?,?);

$stmt = mysqli_prepare($conn,$sql);

You’re missing a closing " on the penultimate line.

2 Likes

thanx so much!

1 Like

You’re welcome. Sometimes it just takes another pair of eyes. :slight_smile:

and/or a good syntax highlighter…
(If you look at the code in the code block above, you can see that all of your variable declarations are blue…except that last one… should be a signal that something’s gone wrong just before that point.)

2 Likes

thanx for your time!

If there was a way to award bonus points I would certainly give them for the correct usage of penultimate.

1 Like

Now that that is solved…

  1. NEVER EVER USE PLAIN TEXT PASSWORDS

  2. Do not create variables for nothing. You already have the POST variables, just use them.

  3. You should also validate the user supplied data before inserting into your DB.

  4. I would highly recommend you use PDO.
    https://phpdelusions.net/pdo

  5. If there is only one post that follows this one, this will be the penultimate post. :grin: