Jump to content

why is this php include not working??


Mr.Victor

Recommended Posts

I'm having an issue with a php include I added to a web page.  I have several php includes on this webpage and they are formatted the same exact way.  It was working and for some reason it is no longer working now.  I'm not sure what happened.  I view the source code of the webpage and the code ends just before the php include.  I have tried to include the same file in other pages also with no success so I'm guessing the issue must be in the code of the included php file.  When I browse to the actual php file it displays properly.  When I paste the php code directly into the web page it displays properly.  I am racking my brain here.  I have spent hours trying to figure out what is wrong and I can't.  Please help.

 

php file displaying properly when browsed to directly:  http://www.metrowestpoker.com/includes/api/ChipLeaders.php

 

the php code in that file:

 

<?php

  $topcount = 20;  // display top 10 or use any number you like

  include "API.php";  // API $url and $pw values set here

  // Fetch the Site Name using the SystemGet API command.

  $params = "Password=" . $pw . "&Command=SystemGet&Property=SiteName";
  $api = Poker_API($url,$params,true);
  $result = $api["Result"];
  if ($result == "Error") die("Error: " . $api["Error"]);
  $sitename = $api["Value"];

  // Fetch the list of players using the AccountsList API command.

  $params = "Password=" . $pw . "&Command=AccountsList&Fields=Player,Balance";
  $api = Poker_API($url,$params,true);
  $result = $api["Result"];
  if ($result == "Error") die("Error: " . $api["Error"]);

  // Iterate through the players in the response and create a associative
  // chips array keyed on player name.

  $accounts = $api["Accounts"];
  $chips = Array();
  for ($i = 1; $i <= $accounts; $i++)
  {
    $player = $api["Player" . $i];
    $chips[$player] = $api["Balance" . $i];
  }

  // Sort array in decending order.

  arsort($chips);

  // Display results in an html table.

  echo "<table border='1' cellspacing='0' cellpadding='5'>\r\n";
  echo "<tr><th colspan='3'>$sitename - Chip Leaders</th></tr>\r\n";
  echo "<tr><th>Rank</th><th>Player</th><th>Balance</th></tr>\r\n";
  $rank = 0;
  foreach ($chips as $p => $c)
  {
    $rank++;
    echo "<tr><td>$rank</td><td>$p</td><td>$c</td></tr>\r\n";
    if ($rank == $topcount) break;
  }
  echo "</table><br>\r\n";

?>

 

here is the page with the above code pasted directly in (working fine...click on the online leaderboard tab):

 

http://www.metrowestpoker.com/leaderboard2.php

 

now here is the page with the above code in file ChipLeaders.php put in the includes/api/ folder (view the source to see the html cuts off where the include should begin):

 

http://www.metrowestpoker.com/leaderboard.php

 

here is a code snippet from the above page:

 

          <!--Tab2-->
          <div class="TabbedPanelsContent">
            <h4 align="center">MWPT Online Hold'em - Monthly Top 20</h4>
            <p align="center">
            <?php require 'includes/api/ChipLeaders.php'; ?> 
            </p>
          </div>

 

I feel like I looked over everything but can't figure it out.  It's driving me nuts.  Please help.  Thank you in advance.

Link to comment
Share on other sites

try....

error_reporting (E_ALL); 

right after <?php then post an error

 

like this?

 

<?php error_reporting (E_ALL); require 'includes/api/ChipLeaders.php'; ?>

 

 

Also,

 

I tried putting the include statement ( in another file and now it displayed like it should but still won't in the original web page.  Man this has me so confused.

Link to comment
Share on other sites

Just a stab but if it works pasted directly in page located in the root dir

but doesnt when its in the includes

but both times your are calling api.php

then that tells me that api.php is in the root dir not the includes dir.

Wouldnt you need to change that path?

 

Dreamweaver automatically updates links when the code calls it from the root dir...api.php is definitely in the includes/api/ folder.

Link to comment
Share on other sites

Thanks Rajiv!  Making some progress.  Here is the error i got:

 

 

Fatal error: Cannot redeclare poker_api() (previously declared in /services2/webpages/util/m/w/mwpl.site.aplus.net/public/includes/api/API.php:6) in /services2/webpages/util/m/w/mwpl.site.aplus.net/public/includes/api/API.php on line 47

Link to comment
Share on other sites

I changed:

 

include "API.php";

 

to:

 

include_once "API.php";

 

in the ChipLeaders.php file and that worked out!  Sweeeet!  I'm just curious why that did it.  There is no other: include "API.php"; anywhere else in the ChipLeaders.php so I'm not sure why it's saying it's calling it twice.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.