Report this

What is the reason for this report?

INSERT INTO syntax Error MYSQL with PHP

Posted on February 19, 2015

I attempt to insert data with this code $user_name = mysqli_real_escape_string($mysqli, $POST[“user_name”]); $user_pass = mysqli_real_escape_string($mysqli, $POST[“user_pass”]); $user_email = mysqli_real_escape_string($mysqli, $POST[“user_email”]); $sql = “INSERT INTO users(id, user_name, user_pass, user_email ,user_level) VALUES(NULL, $user_name, $user_pass, $user_email, 0)”; $result = mysqli_query($mysqli, $sql); However when I actually launch the query, I get an error that says this. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’ , , 0)’ at line 4 I also know this isn’t a very secure at all, but it’s for school and not for actual use.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.