Jump to content

Troubleshooting a page that won't load?


subnet_rx

Recommended Posts

I have a page that processes a variable passed in the url to go get information out of a text file in JSON format.  For some reason though, passing one variable loads a page, passing a certain variable (who's data in the file is virtually identical to the first)  will cause the browser to just load the page indefinitely.  Maybe even more strange is that on my local machine, the variable that won't load is switched, and the other loads fine.  How can I debug what's happening when the page never loads so that I never get an error?

Link to comment
https://forums.phpfreaks.com/topic/247619-troubleshooting-a-page-that-wont-load/
Share on other sites

I think I've determined this is a browser issue, but I wouldn't mind someone taking a look at the code to see if I'm doing things correctly

 

<?php
	$menu_id=filter_input(INPUT_GET, 'q', FILTER_SANITIZE_NUMBER_INT);
	if (isset($menu_id)) {
		$url = "http://www.mysite.com/json/mobile_menu/".$menu_id;
		//load menu items
		$string=file_get_contents($url);
		$menu_object=json_decode($string);
		$m = $menu_object->nodes[0];
		//load external links in menu
		$lurl = "http://www.mysite.com/json/external_links/".$menu_id;
		//load menu items
		$lstring=file_get_contents($lurl);
		$ext_object=json_decode($lstring);
	}
	else {
		header( 'Location: http://m.mysite.com/' ) ;
	}
?>
<!DOCTYPE html> 
<html> 
<head> 
<title><?php print($m->menu->Menu_Title); ?></title> 	
<?php require_once 'includes/header.inc.php';  ?>
</head> 
<body> 
<div id="nid_menu" data-role="page">
<?php require_once 'includes/header_div.php';  ?>
<div data-role="content">
    <h1 class="menu_header"><?php print($m->menu->Menu_Title); ?></h1>	
    	<ul data-role="listview" data-dividertheme="a">
	<?php 
		if (isset($m->menu->Title)) {
		foreach($menu_object->nodes as $m) {
			if ($m->menu->Type == "mobile_menu") {
				echo '<li><a href="./menu.php?q='.$m->menu->Nid.'">'.$m->menu->Title.'</a></li>';
			}
			else {
				echo '<li><a href="./page.php?q='.$m->menu->Nid.'">'.$m->menu->Title.'</a></li>';
			}
		}
		}
	?>
        <?php if (array_key_exists("nodes",get_object_vars($ext_object))) { ?>
        <li data-role="list-divider">Other Resources</li>
        		<?php

		foreach($ext_object->nodes as $e) {
			echo '<li>'.$e->link->Link.'</li>';
		}}
	?>
	</ul>	
</div>
<?php require_once 'includes/footer.php';  ?>
</div>	
</body>
</html>

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.