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; } Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/ 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. Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341446 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. Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341447 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"; } Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341450 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? Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341456 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? Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341475 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. Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341512 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. Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-341516 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.. Link to comment https://forums.phpfreaks.com/topic/67932-cant-use-function-return-value-in-write-context/#findComment-342252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.