Array to string conversion in php check my code

Try this:

$sql = "INSERT INTO info (firstname,lastname,subject,age) VALUES ('{$_POST ['fname']}','{$_POST ['lname']}','{$_POST ['subject']}', '{$_POST ['age']}')";

Explanation:

$_POST is an array
So, you need to take care of it while accessing

And, If arrays are accessed inside String, then we should use {}
For example: {$_POST['subject']}

Leave a Comment