Commands out of sync; you can't run this command now |
My problem is that I am using the DB to store session data so every time I run another query on any function that loads a page I get this error because of the session SQL write
Quote:Error Number: 2014 So far the only fix is to add session_write_close(); to the top of the page. Problem with that is I am storing data in the sessions "Well trying to." But because I have this write_close it destroys the session and I have nothing. Anyone else run into this and have a fix?? Thanks in advance (12-27-2015, 06:11 PM)mike7418 Wrote: My problem is that I am using the DB to store session data so every time I run another query on any function that loads a page I get this error because of the session SQL writeOk, I read the session doc and see the explanation. I guess I'll have to turn into the session super guru to find my resolution... (12-29-2015, 06:11 AM)mike7418 Wrote:(12-27-2015, 06:11 PM)mike7418 Wrote: My problem is that I am using the DB to store session data so every time I run another query on any function that loads a page I get this error because of the session SQL writeOk, I read the session doc and see the explanation. I guess I'll have to turn into the session super guru to find my resolution... My whole understanding of sessions is not making sense with this problem.
Maybe we could help if you could elaborate on the problem a little. You seem to be under the impression that you're running into a session concurrency issue, but the error message you've posted comes from MySQL under many different circumstances. For one, make sure you do not have pconnect enabled in your default database configuration.
(12-30-2015, 08:47 AM)mwhitney Wrote: Maybe we could help if you could elaborate on the problem a little. You seem to be under the impression that you're running into a session concurrency issue, but the error message you've posted comes from MySQL under many different circumstances. For one, make sure you do not have pconnect enabled in your default database configuration. pconnect is disabled, I have a login that after the member is verified it sets session variables then redirects you back to the page you logged in from. I have checked session state right up to the redirect, then it is dropped. I have session autoloaded, here is the authentication functions PHP Code: function authenticate($username, $password, $page) { Everything says to run session_write_close() or session_commit() * An alias of session_write_close() because I keep getting the 'Commands out of sync'. So the first line of the function is the session_write_close(). I've tried to set a variable with the session before the close and that doesn't work either. session variable is already unset in the redirect. PHP Code: function index() {
12-31-2015, 11:11 AM
(This post was last modified: 12-31-2015, 11:11 AM by mwhitney. Edit Reason: semi-colon was converted into a smiley )
The first thing to try is to take the semi-colon ( ; ) out of the query:
PHP Code: $auth = $this->db->query("CALL sp_authenticate('{$username}')"); If that change does not fix the issue or change the error you're receiving, then you may also need to free the result before modifying the session. This should be as simple as calling $auth->free_result() before returning from authenticate_user(), but you'll have to make sure you've retrieved any data you need from the result before doing so. (12-31-2015, 11:11 AM)mwhitney Wrote: The first thing to try is to take the semi-colon ( ; ) out of the query: I have done both as you suggested and still does not change it. I am wondering if there is something in the php.ini I should be looking at for the sessions? Like I said it holds on to the session values I am setting right up until I do the redirect back to the page that submitted the logon. When I check the session values on that page all I get is the session id which matches the last check of the session values at PHP Code: var_dump($this->session->all_userdata());
You need the next result to proceed. Maybe something like this right after your call to the procedure:
PHP Code: mysqli_next_result( $this->db->conn_id ); (12-31-2015, 04:24 PM)mike7418 Wrote:(12-31-2015, 11:11 AM)mwhitney Wrote: The first thing to try is to take the semi-colon ( ; ) out of the query: Well I found part of the problem. Apparently do not try setting your session variables in a model? I switched the sessions to files, moved the session write to the controller and it works. But it still doesn't like the database? But at 2am I'm not worrying about it... Thanks for everyone's help
See this page about the Commands Out of Sync error:
http://community-auth.com/blog-posts/com...procedures |
Welcome Guest, Not a member yet? Register Sign In |