Jump to content

print_r causes white screen


bftwofreak

Recommended Posts

Hey guys, I'm having a strange issue, but whenever I use a print_r(); function it causes the entire page to fail and this is a page that is included in with several others.

<?php

$gameid = $_GET['gameid'];
$rdetails = file_get_dom('http://www.bungie.net/Stats/GameStatsHalo3.aspx?gameid=' . $gameid . '&player=' . $url_player);

$tag = Array();
$color = Array();
$emblem = Array();
$pmedals = Array();
$pmedals_ct = Array();
$pmedals_img = Array();
$ranki = Array();
$rankt = Array();
$score = Array();
$stag = Array();
$tag = Array();
$tool_img = Array();
$tool_name = Array();
$view = Array();

/* Gameplay */
$playlist = $rdetails->find('li.styled', 2)->innertext;
$playlist = explode(' - ', $playlist);
$gametype = $rdetails->find('ul[class=summary]', 0)->find('li', 0)->innertext;
$map_img = '<img src="http://www.bungie.net' . $rdetails->getElementById('ctl00_mainContent_bnetpgd_imgMap')->src . '" />';
$game_img = '<img src="http://www.bungie.net' . $rdetails->getElementById('ctl00_mainContent_bnetpgd_imgVariantType')->src . '" />';


/* variables */
for( $i = 1; $i <= 16; $i++) {
$a = 2*$i-2;
$b = $a+1;
$c = $c*6-6;
$main = 'ctl00_mainContent_bnetpgd_overview_ctl0' . $i;
$pop = 'ctl00_mainContent_bnetpgd_rptPopOver_ctl0' . $i;
$_kills = 'ctl00_mainContent_bnetpgd_kills_ctl0' . $i . '_trPlayerRow';
if ($i >= 10) {
$main = 'ctl00_mainContent_bnetpgd_overview_ctl' . $i;
$pop = 'ctl00_mainContent_bnetpgd_rptPopOver_ctl' . $i;
$_kills = 'ctl00_mainContent_bnetpgd_kills_ctl' . $i . '_hlGamertag';
}

/* Player Stuff */
$tag[$i] = $rdetails->getElementById($main . '_hlGamertag')->innertext;
$color[$i] = $rdetails->getElementById($main . '_divColorBG')->style;
$emblem[$i]['s'] = '<img src="http://www.bungie.net' . $rdetails->getElementById($pop . '_EmblemLarge_imgEmblem')->src . '" alt="' . $tag[$i] . '" style="height: 25px; width: 25px;">';
$emblem[$i]['l'] = '<img src="http://www.bungie.net' . $rdetails->getElementById($pop . '_EmblemLarge_imgEmblem')->src . '" alt="' . $tag[$i] . '">';
$stag[$i] = $rdetails->find('table', 4)->find('div.larger', $a)->innertext;
$stag[$i] = explode(' - ', $stag[$i]);
/* Player Match Info */
if ($rdetails->find('td.colB', $i)->innertext == '-') {
$place[$i] = $place[$i-1];
} else {
$place[$i] = $rdetails->find('td.colB', $i)->innertext;
}
$score[$i] = $rdetails->find('td.colLast', $i)->innertext;
$ranki[$i] = '<img src="http://www.bungie.net' . $rdetails->getElementById($pop . '_imgRank')->src . '">';
$rankt[$i] = $rdetails->find('table', 4)->find('div.larger', $b)->innertext;
$tool_img[$i] = '<img src="http://www.bungie.net' . $rdetails->getElementById($pop . '_imgWepOfChoice')->src . '" />';
$tool_name[$i] = $rdetails->getElementById($pop . '_imgWepOfChoice')->alt;
$kills[$i] = $rdetails->find('td.col', $c);

/* Medals */
for ($k = 1; $k <= 10; $k++) {
if ($k < 10) {
$pmedals_num = '_rptPlayerMedals_ctl0' . $k . '_imgPlayerMedal';
} else {
$pmedals_num = '_rptPlayerMedals_ctl' . $k . '_imgPlayerMedal';
}
if (isset($tag[$i])){
if (isset($rdetails->getElementById($pop . $pmedals_num)->src)) {
$pmedals_img[$i][$k] = '<img src="http://www.bungie.net' . $rdetails->getElementById($pop . $pmedals_num)->src . '" />';
$pmedals_ct[$i][$k] = $rdetails->find('div[class=total_medals_player]', $i-1)->find('div', $k-1)->innertext;
$pmedals[$i] .= '<td><center><div style="background-color: black; width: 50px; text-align: center; height: 100%">' . $pmedals_img[$i][$k] . '<br /><br />' . $pmedals_ct[$i][$k] . '</div></center></td>';
$colspan[$i]++;
}
}
}

/* Display */
$width_1 = 100/7;
$info[$i] = '<table style="width: 100%">
<tr>
<td rowspan="2" style="width: 90px;">' . $emblem[$i]['l'] . '</td>
<td rowspan="2" style="width: 60px;">' . $ranki[$i] . '</td>
<th colspan="2" style="height: 60px;"><a href="modules.php?name=' . $module_name . '&tag=' . $tag[$i] . '" style="font-size: 20px">' . $tag[$i] . ' - ' . $stag[$i][1] . '</a></th>
</tr><tr>
<th style="width: 50%">' . $rankt[$i] . '</th><th style="width: 50%">' . $stag[$i][0] . '</th>
</tr>
</table><table style="width: 100%"><tr>
<th style="width: 169px">Tool of Destruction</th><th colspan="' . $colspan[$i] . '">Medals of the Round</th>
</tr><tr>
<td style="width: 169px; text-align: center; background-color: black;">' . $tool_img[$i] . '<br />' . $tool_name[$i] . '</td>' . $pmedals[$i] . '
</tr></table><table style="width: 100%">
<tr>
<th style="width: ' . $width_1 . '%">Score</th><th style="width: ' . $width_1 . '%">Kills</th><th style="width: ' . $width_1 . '%">Assists</th><th style="width: ' . $width_1 . '%">Deaths</th><th style="width: ' . $width_1 . '%">K/D Spread</th><th style="width: ' . $width_1 . '%">Suicides</th><th style="width: ' . $width_1 . '%">Betrayals</th>
</tr><tr>
<td style="width: ' . $width_1 . '%; text-align: center;">' . $score[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $kills[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $assist[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $death[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $spread[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $suicide[$i] . '</td><td style="width: ' . $width_1 . '%; text-align: center;">' . $betrayal[$i] . '</td>
</tr>
</table>';

$view[$i] = '<div class="tabbertab">
<h2>' . $place[$i] . ': ' . $tag[$i] . '</h2>
<p>' . $info[$i] . '</p></div>';


}
echo '<script type="text/javascript" src="modules/' .$module_name . '/d/tabber.js"></script>
<link rel="stylesheet" href="modules/' .$module_name . '/d/tabber.css" type="text/css" media="screen" />
<link rel="stylesheet" href="modules/' .$module_name . '/d/tabber-print.css" type="text/css" media="print" />
<div class="tabber">
<div class="tabbertab tabbertabdefault">
<h2>Overall</h2>
<p>
<table>
<tr>
<th>' . $gametype . '</th>	
</tr><tr>
<td><div>' . $map_img . $game_img . '</div></td>
</tr>
</table>
<table style="width: 40%">';
echo '<tr><th>Place</th><th>Emblem</th><th>Gamertag</th><th>Score</th></tr>';
for( $i = 1; $i <= 16; $i++ ){
if (isset($tag[$i])) {
echo '<tr><th style="' . $color[$i] . '">' . $place[$i] . '</th><th style="' . $color[$i] . '">' . $emblem[$i]['s'] . '</th><th style="' . $color[$i] . '">' . $tag[$i] . '</th><th style="' . $color[$i] . '">' . $score[$i] . '</th></tr>';
}
}

echo '</table>
</p>
</div>';

for( $i = 1; $i <= 16; $i++ ){
if (isset($tag[$i])) {
echo $view[$i];
}
}

echo '</div>';

print_r($kills[2]);

?>

I'm trying to figure out why $kills[2] is giving  me an array, but I can't figure out the keys unless I see the Array in a printable manner. Usually if there's something wrong with the script on this page, just this page fails where it is included as well as the script following it, but for some reason the entire page fails. Can anyone give a suggestion?

Link to comment
https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.