note 13748 deleted from function.session-set-save-handler by irc-html
| From: | irc-html@php.net | Date: | Fri, 19 Apr 2002 00:16:53 +0000 |
| Subject: | note 13748 deleted from function.session-set-save-handler by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-29559@lists.php.net to get a copy of this message | ||
A weird thing happened to me. I was trying to use session_set_save_handler() and MySQL. I got to a
point where the session was created on the database but the variables wouldn't update. It
looked as if the script wouldn't read the variable and update it (I used the example from the
manual with the $counter variable). So $counter was always 1 (in the database as well).
Well, I went to phpbuilder.com and read the article "Custom Session Handlers in PHP4" by
Ying Zhang. I downloaded the zip file attached to the article, and to my surprise, his script
wasn't much different than mine, except it worked! I was going crazy trying to find the
differences. Nothing!
Well, eventually I was eliminating problems until I found the bug:
Under the write function (sess_write in this case) I wrote:
INSERT INTO session ('id','expiry','value') VALUES ('$id',
$expiry, '$value')
while Ying wrote:
INSERT INTO session VALUES ('$id', $expiry, '$value')
As you can see the only difference is I added a declaration of the fields to be updated while Yind
didn't. Bits me, but now it works :)
I'm developing on Win98 with Apache 1.3.20, PHP4.0.6 & MySQL 3.23.