I made a small php script to check which link adress is browsed, I am quite new to php and I only read a small tutorial so I am quite a newbie :rolleyes:

here is the code

    <?php 
$page= array("index.php, underC.php");
if (in_array("index.php", $page, true))
{
include ("Newsfact_01");
}
elseif (in_array("underC.php", $page, true))
{
Include ("underC.php");
}
?>

The things that happens is, no error, but the tale in which the page is displayed does not display at all

Suggestions are much appreciated

    Hellusius wrote:

    I made a small php script to check which link adress is browsed, I am quite new to php and I only read a small tutorial so I am quite a newbie :rolleyes:

    here is the code

        <?php 
    $page= array("index.php, underC.php");
    if (in_array("index.php", $page, true))
    {
    include ("Newsfact_01");
    }
    elseif (in_array("underC.php", $page, true))
    {
    Include ("underC.php");
    }
    ?>

    The things that happens is, no error, but the tale in which the page is displayed does not display at all

    Suggestions are much appreciated

    looks like you're just filling your array wrong. You put both items within the same set of double quotes

    change

    $page= array("index.php, underC.php");

    to

    $page= array("index.php", "underC.php");

      No errors this time, but it does not include the page, it displays nothing

        Does anyone have any suggestions?

        here is the code again

        <?php 
        $page= array("index.php, underC.php");
        if (in_array("index.php", $page, true))
        {
        include ("Newsfact_01");
        }
        elseif (in_array("underC.php", $page, true))
        {
        Include ("underC.php");
        }
        ?>

          Its my understanding that you still need to make this call at the beginning of your script eventhough you are adding them into the array. Then seperate by " ", " "

          <?php

          include("index.php");
          include("underC.php");

          $page= array("index.php, underC.php");
          if (in_array("index.php", $page, true))
          {
          include ("Newsfact_01");
          }
          elseif (in_array("underC.php", $page, true))

          ?>

            now I get this error

            Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/www/warnicro.awardspace.com/SidebarNews.php on line 28

            the page sidebar news look like this

            <table width="100%" border="0" cellpadding="10">
              <tr>
                <td width="125" rowspan="20" bgcolor="1155CC">
            <b>Maps</b><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">Campaign</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">Altred melee</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">Melee</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">RPG</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">ORPG</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">Defense</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="http://warnicro.awardspace.com/index.php" onClick="tempfunc()">Offense</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="/index.php" onClick="tempfunc()">Arena/CTF</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="/index.php" onClick="tempfunc()">Tag</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="/index.php" onClick="tempfunc()">Mini-games</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="/index.php" onClick="tempfunc()">Cinematic</a><br>
            &nbsp;&nbsp;&nbsp;-<a href="/index.php" onClick="tempfunc()">Other</a><br><br>
            &nbsp;&nbsp;&nbsp;-<a href="/submitamap.php"><abbr title="submit your new warcraftIII maps in here">Submit map(s)</abbr></a><br>
                </td>
              </tr>
              <tr>
                <td width="*" align="center" bgcolor="1155FF">
            <?php
            
            include("Newsfact_01");
            include("underC.php");
            
            $page= array("index.php", underC.php");
            if (in_array("Newsfact_01", $page, true));
            {
            include ("Newsfact_01");
            }
            elseif (in_array("underC.php", $page, true))
            {
            Include ("underC.php");
            }
            ?>
                </td>
              </tr>
            </table>

            What should I do now?

              you dont need the 3rd parameter in_array() true
              as you only are dealing with strings here

              If I should do it, it would be someting like this

              <?php
              
              $page= array("index.php", "underC.php"); // quotes around each item
              
              if (in_array("index.php", $page))
              {
              echo 'Newsfact_01';
              }
              elseif (in_array("underC.php", $page))
              {
              echo 'underC.php';
              }
              ?>

              but this code is meaningless, as 'index.php' is ALWAYS in array

                well that does not include my page's information

                  What I have now is this

                  <?php
                  
                  $page= array("index.php", "underC.php");
                  
                  if (in_array("index.php", $page))
                  {
                  include ('Newsfact_01');
                  }
                  elseif (in_array("underC.php", $page))
                  {
                  include ('underC.php');
                  }
                  ?> 
                  

                  But the Newsfact_01 keeps apearing even when the link is underC.php

                    going to cancel this, so resolved.

                    thanks for your time though, everyone

                      Write a Reply...