felic Posted November 19, 2015 Share Posted November 19, 2015 Hi, I am a bit surprised seeing a script works while on localhost, but triggers following error after shoving it to the online server. Logged Error while on the online server: Compile Error: Can't use method return value in write context The line in the script which triggers the error: if (empty($session->get("uploaded_documents"))) {... } So the getter session method causes the trouble here obviously. But since this all works flawlessly in my local dev environment, i currently have no idea, why this work only locally. Both PW installations, local and on the online are identical (PW 2.7.0.). A bit of context: I have a API Form which allows multiple file uploads. To prevent uploading each file over and over in case of a validation form error i set sessions to temp save the paths of uploaded files until the form validates. So the condition above lives within following structure: // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); if (empty($session->get("uploaded_documents"))) { // doing some things/condition if or not to init the session and fill it with files arrays a.s.o. } if($form->getErrors()) { // form contains errors... } else { // form validates, doing something... } } What bothers me, is why it works locally but not on the online server? Any ideas are much appreciated! greets Link to comment Share on other sites More sharing options...
adrian Posted November 20, 2015 Share Posted November 20, 2015 PHP version is the issue. If the server is < 5.5 you will need to set $session->get("uploaded_documents") to a variable first, then call empty on that variable. $uploaded_documents = $session->get("uploaded_documents"); if(empty($uploaded_documents)) { Read more about the 5.5 change here: http://php.net/manual/en/function.empty.php 4 Link to comment Share on other sites More sharing options...
felic Posted November 20, 2015 Author Share Posted November 20, 2015 PHP version is the issue. If the server is < 5.5 you will need to set $session->get("uploaded_documents") to a variable first, then call empty on that variable. Thank you very much! Indeed, this was the issue. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now