bftwofreak Posted October 28, 2008 Share Posted October 28, 2008 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 More sharing options...
genericnumber1 Posted October 28, 2008 Share Posted October 28, 2008 Add this to the top: error_reporting(E_ALL | E_STRICT); Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676288 Share on other sites More sharing options...
bftwofreak Posted October 28, 2008 Author Share Posted October 28, 2008 nada... still shows up blank... Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676290 Share on other sites More sharing options...
xtopolis Posted October 28, 2008 Share Posted October 28, 2008 what about: var_dump($kills[2]); Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676291 Share on other sites More sharing options...
bftwofreak Posted October 28, 2008 Author Share Posted October 28, 2008 tried it... same deal Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676294 Share on other sites More sharing options...
xtopolis Posted October 28, 2008 Share Posted October 28, 2008 So you're saying if you remove print_r.. the page works fine(aside from not getting the data you want)? That doesn't make sense. Also, all these tips should have given you something. If you are using cURL, perhaps it's timing out? Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676299 Share on other sites More sharing options...
bftwofreak Posted October 28, 2008 Author Share Posted October 28, 2008 That's pretty much what happens... I'm not sure... I've tried the similar functions like var_dump(); and neither work. It causes the entire page to fail. Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676607 Share on other sites More sharing options...
kenrbnsn Posted October 28, 2008 Share Posted October 28, 2008 There might be HTML in the array which is being interpreted. Try <?php echo '<pre>' . print_r(array_map('htmlentities',$kills),true) . '</pre>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-676628 Share on other sites More sharing options...
bftwofreak Posted October 29, 2008 Author Share Posted October 29, 2008 wow that worked for some reasons... I'm glad it worked, but I'm still wondering why... Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-677088 Share on other sites More sharing options...
kenrbnsn Posted October 29, 2008 Share Posted October 29, 2008 It worked because htmlentities() turns characters like "<" into ">" which makes any HTML or Javascript in the array just strings and they won't be executed.. Ken Link to comment https://forums.phpfreaks.com/topic/130370-print_r-causes-white-screen/#findComment-677128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.