What did i do wrong?

Discussion in 'PHP' started by Drew007, Sep 23, 2008.

  1. #1
    I am trying to get php to grab data from a language file and place it on a page. Here is my code:

    <?php include_once("inc/language.php"); ?>
    PHP:
    Hello, my name is <?php echo $lang['name']?>
    PHP:
    Any help would be greatly appreciated. Thanks in advance.
     
    Drew007, Sep 23, 2008 IP
  2. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #2
    On the second line:
    
    Hello, my name is <?php echo $lang['name']; ?>
    
    Code (markup):
    Notice that you forget to write the ; before ?>
     
    chmdznr, Sep 23, 2008 IP
  3. nabz245

    nabz245 Well-Known Member

    Messages:
    677
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Could we take a look at your language.php file?

    Regards
     
    nabz245, Sep 23, 2008 IP
  4. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #4
    although it's good practice, this doesnt matter at the moment, i think the suspect here is the language file
     
    serialCoder, Sep 23, 2008 IP
  5. classic

    classic Peon

    Messages:
    96
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You need to take care of the structure of folders/files , here is how it can be done
    
    public_html/    //main site folder
    public_html/index.php  //a main file
    public_html/inc/language.php  //the language file
    
    Code (markup):
    language.php
    
    <?php
    $lang = array();
    $lang['name']="Name";
    $lang['key']="Value";
    .....
    
    PHP:
    index.php
    
    <?php 
    include_once("inc/language.php"); 
    //test to see if array is present see how many pairs you have
    echo count($lang);
    
    ?>
    Hello, my name is <?php echo $lang['name']; ?>
    
    
    PHP:
     
    classic, Sep 23, 2008 IP
    Drew007 likes this.
  6. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks everyone. The problem was in my lang file.
     
    Drew007, Sep 24, 2008 IP