Web Analytics Made Easy -
StatCounter array does not work from an include - CodingForum

Announcement

Collapse
No announcement yet.

array does not work from an include

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • array does not work from an include

    Thanks in advance for any advice. I appreciate the help as I'm struggling here after reading everything I can to figure this out. I volunteer my time for this Little League website trying to figure out how to eventually convert it over to PHP. I can get things to work using an array (not sure if an array is the best approach/method) but not when trying to call it from an include.
    WORKS:
    <?PHP
    $table = array (
    shellA=>"<p><TABLE align=center border=0><tr><td><TABLE align=center border=0 bgcolor=#036501>",
    shellB=>"<tr><td align=center bgcolor=#ECFFEC>Header text</td></tr>",
    bodytext=><tr><td bgcolor=#FFFFFF>Body text</td></tr></TABLE></td></tr></TABLE>
    );
    echo $table;
    ?>

    NOT WORKING:
    tablec.php = <? $table = array (
    shellA=>"<p><TABLE align=center border=0><tr><td><TABLE align=center border=0 bgcolor=#036501>",
    shellB=>"<tr><td align=center bgcolor=#ECFFECHeader text</td></tr>",
    bodytext=><tr><td bgcolor=#FFFFFF>Body text</td></tr></TABLE></td></tr></TABLE>
    ); ?>
    FILE:
    <?PHP
    include 'tablec.php';
    echo $table["shellA"]["shellB"]["bodytext"];
    or just simply
    echo $table;
    ?>
    What am I doing wrong

  • #2
    Hi... to see the contents of your array you need to call each element individually ...
    PHP Code:
    <?php
    include 'tablec.php';
    echo 
    $table['shellA']
    echo 
    $table['shellB']
    echo 
    $table['bodytext'];
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment


    • #3
      hmmm that doesn't seem to work either

      Could it be something else?

      Comment


      • #4
        sorry I typoed...

        PHP Code:
        <?php
        require 'tablec.php';
        echo 
        $table['shellA'];
        echo 
        $table['shellB'];
        echo 
        $table['bodytext'];
        ?>
        assuming that tablec.php is exactly as per below (which also had typos)

        PHP Code:
        <?
        $table 
        = array (
        'shellA'=>'<p><TABLE align=center border=0><tr><td><TABLE align=center border=0 bgcolor=#036501>',
        'shellB'=>'<tr><td align=center bgcolor=#ECFFEC>Header text</td></tr>',
        'bodytext'=>'<tr><td bgcolor=#FFFFFF>Body text</td></tr></TABLE></td></tr></TABLE>'
        ); 

        ?>
        resistance is...

        MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

        Comment


        • #5
          arrgghh

          firepages,
          I appreciate your help but it still doesn't work and I copied everything verbatum.
          I tried it by not using the include or require, by pasting directly and it worked so it has to be something in the way it is being called externally...

          Comment


          • #6
            So what seems to be the problem?

            Thanks for the help!
            Is this a server side issue?

            Comment


            • #7
              It was the extension, stupid

              Looks like on my servers I was getting in trouble using html as the extension. Once I switched it to htm it worked!
              I'll be back!

              Comment

              Working...
              X