I tried to execute this query -
$sql="INSERT INTO REGISTRATIONS VALUES ('$_SESSION['fname']', '$_SESSION['username']', '$_SESSION['height']', '$_SESSION['image']');";
And this one as well -
$sql="INSERT INTO REGISTRATIONS VALUES ($_SESSION['fname'], $_SESSION['username'], $_SESSION['height'], $_SESSION['image']);";
But both these returns an error. So i stored the session variables into normal php variables. and tried to execute the query -
$name = $_SESSION['fname'];
$username = $_SESSION['username'];
$height = $_SESSION['height'];
$image = $_SESSION['image'];
$sql="INSERT INTO REGISTRATIONS VALUES ('$name', '$username', '$height', '$image');";
And it worked.
But i want to know why the first two didn't work and why we have to save Session into another variable to get it to work?
Please help :)