Tutorials
Unable to insert data into table
$conn=mysqli_connect('localhost:8080', 'root', ' ','user_accounts' );
$sql="INSERT INTO users
    (name,Lastname,Email_ID,Phonenumber,Password)
    VALUES($firstname,$lastname,$email,$phonenumber,$password)";


if($is_query_run=mysqli_query($conn,$sql))
{
    echo 'Query successfully executed';
    //$query_execute=mysqli_fetch_assoc($is_query_run)
}

Why am i unable to insert data into the database?

``` $conn=mysqli_connect('localhost:8080', 'root', ' ','user_accounts' ); $sql="INSERT INTO users (name,Lastname,Email_ID,Phonenumber,Password) VALUES($firstname,$lastname,$email,$phonenumber,$password)"; if($is_query_run=mysqli_query($conn,$sql)) { echo 'Query successfully executed'; //$query_execute=mysqli_fetch_assoc($is_query_run) } ``` Why am i unable to insert data into the database?
edited May 26 '19 at 3:34 pm

You missed the quotes

INSERT INTO users
(name,Lastname,Email_ID,Phonenumber,Password)
VALUES('$firstname','$lastname','$email','$phonenumber','$password')

Also what you are doing is dangerous, it is better to use PDO with prepared statements instead of mysqli_connect

You missed the quotes ``` INSERT INTO users (name,Lastname,Email_ID,Phonenumber,Password) VALUES('$firstname','$lastname','$email','$phonenumber','$password') ``` Also what you are doing is dangerous, it is better to use PDO with prepared statements instead of mysqli_connect
Necessity is the mother of all inventions!
77
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft