FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Completely stumped
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Completely stumped (still) [message #185033 is a reply to message #185031] Mon, 24 February 2014 23:53 Go to previous messageGo to previous message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma:
Member
On Mon, 24 Feb 2014 14:51:23 -0800, Richard Yates
<richard(at)yatesguitar(dot)com> wrote:

> Sorry for the vague subject heading but i didn't know what else to put
> there. I have a script that works fine on my local server, and that I
> am using with no problem on three other production servers.
>
> However, on another production server it is failing in a very weird
> way. I get the message "Fatal error: cannot use string as offset in
> array" when it gets to this line:
>
> $fname=$_SESSION['to'][$ct]['fname'];
>
> I var_dumped the $_SESSION['to'] array to see what was going on and
> got this:
>
> string(23) "dyates(at)salemharvest(dot)org"
>
> So, the error seems to make sense given what is apparently in
> $_SESSION[to']. But that is not what is supposed to be in
> $_SESSION['to']. On the other servers - with IDENTICAL code - the
> script works and the variable dump is like this, as it is supposed to
> be:
>
> array (size=2)
> 0 =>
> array (size=3)
> 'fname' => string 'Dick' (length=4)
> 'lname' => string 'Yates' (length=5)
> 'email' => string 'dyates(at)salemharvest(dot)org' (length=23)
> 1 =>
> array (size=3)
> 'fname' => string 'Benjamin' (length=8)
> 'lname' => string 'Rasmus' (length=6)
> 'email' => string 'benjamin(at)harvest(dot)org' (length=25)
>
> The only difference I can find in the servers is that the ones that
> work are running php5.3 and the bad one is running php5.2. But I
> cannot see how that could account for this error.
>
> At this point I do not even know where to look to track this down.
> Does anyone have any ideas?
>
> Richard Yates

I inserted var_dump successively at each stage in the script to see
where it changes from the (correct) array to a (incorrect) string. I
narrowed it down to ONE statement, but cannot see how that could
possibly change the variable. Here's the section with var_dump, then
the one statement, and then the var_dump repeated exactly.

var_dump($_SESSION['to']);
$to=$_SESSION['to'][$ct]['email'];
var_dump($_SESSION['to']);

The output of the two var_dumps is:

The first:
array(1) { [0]=> array(3)
{ ["fname"]=> string(4) "Dick"
["lname"]=> string(5) "Yates"
["email"]=> string(23) "dyates(at)salemharvest(dot)org" }
}

The second:
string(23) "dyates(at)salemharvest(dot)org"

If I comment out the second line (that sets $to), the second var_dump
comes out correct. Am I losing my mind?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: JavaScript to PHP
Next Topic: Why is polymorphism in PHP not like other languages? Is there a bug in PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 01:28:43 GMT 2024

Total time taken to generate the page: 0.04963 seconds