Marc Blase

PHP Sessions

Now I’m not sure this is due to the short comings of my coding skills or what. But I’ve found it necessary to re-declare session variables before including them in a MySQL INSERT statement.

Here’s the (il)logic:

$_SESSION["mysessionarray"] = arrary();

Push all $_POST variables, or what-have-you, into the array. Then prior to your INSERT statement:

$myvar = $_SESSION["mysessionarray"]["myvar"];

Use your new $myvar in your MySQL INSERT

EDIT: Um, rookie mistake 101. Should’ve just escaped the quotes in the $_SESSION vars. My bad.

Published on February 28, 2011