miklesw Posted September 4, 2007 Share Posted September 4, 2007 I'm getting this error just before this function.. can't figure it out..pls help function createSession(){ global $conn, $dbname; global $AgentEmail,$AgentFirstName,$AgentLastName,$AgentIsVerified,$AgentID; session_start(); $_SESSION("Username")= $POST_User; $_SESSION("Email")= $AgentEmail; $_SESSION("AgentID")= $AgentID; $_SESSION("FirstName")= $AgentFirstName; $_SESSION("LastName")= $AgentLastName; } Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted September 4, 2007 Share Posted September 4, 2007 It would help to know the error. Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 session_start() needs to be exectuted before anything else in your php file. So, you can't use it in another function. Quote Link to comment Share on other sites More sharing options...
miklesw Posted September 4, 2007 Author Share Posted September 4, 2007 The error is: [Tue Sep 04 20:34:08 2007] [error] [client 127.0.0.1] PHP Fatal error: Can't use function return value in write context in C:\\Apache2.2\\htdocs\\eProperty\\init.php on line 36 I execute the function before in an include before the <head> The error is also happening with other functions (not all of them) .. it comes up with the first one it encounters.. function hasAuthSession() { if(isset($_SESSION) && isset($_SESSION("Username") && isset($_SESSION("AgentID")){ return true; }else { return false; } } function GetPageLocation($PageCode) { if ($PageCode=="login") $PageCode="myacc" ; return "My Account"; } function GetPageTitle($PageCode) { if ($PageCode=="login") $PageCode="myacc"; return "content/agentarea/myacc.php"; } Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 Did you try to take session_start() out of that function and put it at the beginning of the php block? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 4, 2007 Share Posted September 4, 2007 session_start() needs to be exectuted before anything else in your php file. So, you can't use it in another function. AFAIK this is untrue. session_start modifies header information so only needs to be called before any output is sent to the browser or before the $_SESSION variable is used. How are these functions being called? Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 You are probably right, roopurt18. Looking at it again, I am pretty sure the error is in the array syntax. You need to use square brackets instead of parenthesis. $_SESSION["Username"]= $POST_User; etc. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 4, 2007 Share Posted September 4, 2007 Ah there it is. I usually have a careful eye but some how I missed the parens to index the array. Quote Link to comment Share on other sites More sharing options...
miklesw Posted September 5, 2007 Author Share Posted September 5, 2007 thanks, that was the prob..amongst other things.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.