I am getting a really weird error in the following piece of code:
mysqli_query($database,"INSERT INTO userdetails (username,email_id)VALUES ($_POST['username'],$_POST['email_id'])";
Error:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in E:\Xampp\htdocs\newsreg.php on line 19
Line 19 is the code I have mentioned above. I have been trying to crack this but to no use. It works if the '
is removed from []
. According to me, $_POST['username'] and $_POST[username] both are valid.
username
is the name attribute of a text box in HTML form.
What is wrong with the above code?