This question already has an answer here:
I have been looking for answers everywhere but just can't find out why I keep getting parse error for this line.
$sql = "INSERT INTO NIMET(NIMI) VALUES("$_POST['fname']")";
Can anyone tell me why this line gets a parse error?
</div>
$sql = "INSERT INTO NIMET(NIMI) VALUES(".$_POST['fname'].")";
You need to use .
to combine strings.
There is also a fanzy way, but for that you need a new enough version from PHP:
$sql = "INSERT INTO NIMET(NIMI) VALUES({$_POST['fname']})";
I think the php-version you need for that is either 5.3 or 5.6. But I'm not shure about that.
Beside that: You shouldn't insert any unvalidated data from $_POST
or $_GET
into your DB. This could be used to insert malicious code.
Use .
To concatenate two strings like this :
$sql = "INSERT INTO NIMET(NIMI) VALUES(".$_POST['fname'].")";