On Thu, Feb 3, 2011 at 4:19 PM, Jostein Eriksen <php-l...@morits.net> wrote:

> Both php and memcached is running on the same server.
> memcached version 1.2.2
> php5-memcache version 2.2.0
> php version 5.2.4
> here is a snippet from my code that may be of interest
> $cfg['serverList'] = array('', 11211, 1, 1);
> ...
> $this->memcache = new Memcache();
> foreach($cfg['serverList'] as $value){
>                                /** host, port, persistent, weight, timeout,
> retry interval, status, failure callback */
>                                $this->memcache->addServer($value[0],
> $value[1], false, $value[2], $value[3], 2, true, array($this, 'fail'));
>                        }
Are you sure you copied this correctly?

In the code above, you set the array key 'serverList' to an array containing
('', 11211, 1, 1);

Then, you foreach through the values of the 'serverList' array (first
iteration, value would equal '', second, value would equal 11211,

Then, you use array notation to access the first position of $value.  In the
first iteration of the foreach, $value would equal '', so $value[0]
would give you '1', $value[1] would give you '2', etc.

Do you see what I'm saying? Did you forget or omit other relevant code? Or,
I'm just having a really bad code day (in this case, I'll likely see my
error just after sending this email.)


Nephtali:  A simple, flexible, fast, and security-focused PHP framework

Reply via email to