SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Array key - how should I examine it

    Hi.

    I need to test if this array key $anp_cinfo["code"] is equal to US and if it is, the site should load in Englush.

    I am testing it like this

    PHP Code:
    if($anp_cinfo["code"] = "US"){ //English
            
    $lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=1"));
            if (
    $lng_a$lang_uri $lng_a["uri"];
        }elseif(
    $anp_cinfo["code"] = "RU"){ //Russian
                
    $lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=16"));
                if (
    $lng_a$lang_uri $lng_a["uri"];
            }else{ 
    //Deutch by Default
                  
    $lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=7"));
                    if (
    $lng_a$lang_uri $lng_a["uri"];
            }
          } 
    However, it looks like I am doing something wrong because either the site loads in English no matter where are you browsing it from or it loads only in Deutch, again, no matter where are you browsing it from.

    I would aprreciate if you point me what I am doing wrong.

  2. #2
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your not checking for equality, but actually assigning a value.

    First line should be if($anp_cinfo["code"] == "US") { ...

    not if($an_cinfo["code"] = "US")

    PHP Code:
    if($anp_cinfo["code"] = "US"){ //English 
    intragenesis, llc professional web & graphic design

  3. #3
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply.

    I found out that in addition I had a scope issue.

    I was trying to call local functions and variables from files I included from within the function stdhead()

    I used a variable $usercountry = get_country() and put it in the global scope.

    if($usercountry == US) now works correctly and my users get contents in their language.

    Thanks again for your help.
    Last edited by Dellius; Oct 12, 2007 at 14:57.


Bookmarks

Posting Permissions

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