Results 1 to 4 of 4

Thread: Error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    87

    Error

    This Code Always Show An Empty Alert Whay ?


    PHP Code:
    <?
    $Language=($HTTP_COOKIE_VARS["Language"]);
    if ($Language=="")  {
    setcookie("Language","English",time() + 43200);
    echo"<script>alert('$Language');</script>";
    }
    ?>

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Because you never set the $Language variable equal to anything.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    87
    and What About This ?
    $Language=($HTTP_COOKIE_VARS["Language"]);

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    Ok your setting $Language to the value of a cookie.
    Then if $Language is empty your writing a cookie.
    And then your outputting the empty value in $Language

    try this
    PHP Code:
    <?
    $Language=($HTTP_COOKIE_VARS["Language"]);
    if (empty($Language))  {
         setcookie("Language","English",time() + 43200);
         echo"<script>alert('English');</script>";
    }else{
         echo"<script>alert('$Language');</script>";
    }
    ?>

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