Results 1 to 5 of 5

Thread: Array to String conversion...my ___

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Array to String conversion...my ___

    I'm echoing all the cookies that has been put on my system from my domain.
    PHP Code:
    <?
    $allcookies = array_keys($HTTP_COOKIE_VARS);
    $allcookievalues = array_values($HTTP_COOKIE_VARS);
    if (sizeof($allcookies) == 0)
    {
        echo '<br><br>TurtleTips hasn\'t put any cookies on your system.';
    }
    else
    {
        echo '<table border="0" cellpadding="4" cellspacing="0">';
        for ($i = 0; $i < sizeof($allcookies); $i++)
        {
            echo "<tr><td><font face=\"Verdana,Tahoma,Arial,sans-serif\" size=\"1\"><b>$allcookies[$i]</b> containing <b>";
            if (strlen($allcookievalues[$i]) > 20)
            {
                echo substr($allcookievalues[$i], 0, 12);
                echo " ... ";
                echo substr($allcookievalues[$i], -7);
            }
            else
            {
                echo $allcookievalues[$i];
            }
            echo "</b> (<a href=\"/setcookie.php?name=$allcookies[$i]";
            echo "&delete=true&returnto=$PHP_SELF\">delete</a>)</font></td></tr>\n";
        }
        echo '</table>';
    }
    ?>
    The code works fine most of the time, but for some reason the last cookie echoed has this before it:
    Warning: Array to string conversion in h:\header.php on line 179
    The equivalent of line 179 above is:
    PHP Code:
    if (strlen($allcookievalues[$i]) > 20

  2. #2
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    maybe make it > 19

    try that

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  3. #3

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Fixed.

  4. #4
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    was that the problem? I just took a guess, because it sounded like an array out of bounds error.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  5. #5

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    No, I just deleted the part of code that was the problem

    I think the cookie actually contained an array because it was always the same cookie that was giving the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width