Never ending loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terryvanduzee
Forum Newbie
Posts: 8
Joined: Fri May 23, 2008 11:52 pm

Never ending loop

Post by terryvanduzee »

Hello

I seem to be having a looping problem and I cannot figure out where it comes from.
Right now, if you go to http://vanduzee.net and click on the "Articles and Interviews" button, you will see the result.

I have my Index.php file that includes the link to the Articles and Interviews page.

Code: Select all

 
<map name="FPMap7">
    <area shape="rect" coords="18, 1, 157, 19" href="index.php?page=articles">
</map>
 
When the page name is used, it loads code that recognizes it as an html document and loads it.

This is the same method I am using for every other link on the index page (except the "contact your senator"). And every other page works fine.
But the Articles and Interviews page loads within index, then within itself again and again.

I cannot figure out why it would be doing this.
The Articles and interviews page just contains some other href links in it and loads within itself when clicked.

Ex:
In the Articles and interviews page there is a link for the News of orange.
Here is the link for it:

Code: Select all

 
<a href="articles.php?page=newsoforange">News Of Orange</a>
 
When this is clicked on, it should load the newsoforange.html file into the articles page.

If I have the Articles and interviews page load into its own page (_blank), everything works fine.

Any suggestions?

Thank you
Terry
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Never ending loop

Post by hansford »

We would need to see the index page to be able to see what was going on.
terryvanduzee
Forum Newbie
Posts: 8
Joined: Fri May 23, 2008 11:52 pm

Re: Never ending loop

Post by terryvanduzee »

Here is the code for the entire index.php:

Code: Select all

 
 
<html>
<head>
<title>Unfair US Immigration Laws</title>
<META name=author content="Terry VanDuzee">
<META name=copyright content="Copyright Terry VanDuzee">
<!-- <META name=revisit-after content="14 days"> -->
<META name=distribution content="Global">
<meta name=rating content="general">
<meta name=keywords content="INS DHS Bush USA US Canada Government Immigration Immigrate Waiver Visa I-130 I-129F I-601 I-192 US Government Bush Department of Homeland Security US Immigration US Consulate Sign our Petition INS DHS Department of Homeland Security Immigrate Immigrant Visa Waiver I-301 I-129F I-601 I-192 Marriage between countries Wedding Marriage Kept apart Without my wife Couple Unfair Law Love Bible Jesus Prayer God Holy Spirit Drive North Carolina Canada NC Senator David Price Edwards Dole State Department Criminal Record,Pardon Visit the US US Border Patrol Live in the US Automobile sports children child boy girl Our Story Radio Interview Newspaper Article Orange County Hillsborough Raleigh Durham President Email Fax Contact Congressman Vice President Department of Liaison Department of State American Canadian">
<meta name=description content="The US Immigration will not allow me to move to the US with my American wife, because of two -25/26 year old possession of marijuana convictions">
<meta name="MSSmartTagsPreventParsing" content="True">
 
 
 
 
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Unfair Immigration Laws</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<!--<script type="text/javascript">
/*<![CDATA[*/
 
/***********************************************
* Encrypt Email script- Please keep notice intact
* Tool URL: http://www.dynamicdrive.com/emailriddler/
* **********************************************/
 Encrypted version of: insproblems [at] ********.*** 
 
var emailriddlerarray=[105,110,115,112,114,111,98,108,101,109,115,64,118,97,110,100,117,122,101,101,46,110,101,116]
var encryptedemail_id90='' //variable to contain encrypted email 
for (var i=0; i<emailriddlerarray.length; i++)
 encryptedemail_id90+=String.fromCharCode(emailriddlerarray[i])
 
 
</script>
-->
</head>
 
 
 
 
<body>
 
<basefont face="Arial">
 
 
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="539">
  <tr>
    <td colspan="2" height="48" background="images/New/topbkg.gif">
    <img border="0" src="images/New/title.gif" align="right" width="239" height="52">
 
<?php
 
$dbhost=localhost;
$dbuser=myusername;
$dbpwd='mypassword';
$dbname=mydatabasename;
 
$SignGoal = 1000000;
$conn = mysql_connect($dbhost, $dbuser, $dbpwd);
 
mysql_select_db($dbname,$conn) or die("Query failed : " . mysql_error());
 
$SQLString = "SELECT * FROM Petition ORDER BY id";
$result = mysql_query($SQLString);
 
$num = mysql_num_rows($result);
$num1 = mysql_num_rows($result) + 1;
 
$SignLeft = $SignGoal - $num;
 
###################################
## THIS DISPLAYS THE INFORMATION ##
###################################
echo "<b><font color=\"White\">" . $num . "</b> people have signed our petition to date, please be # <b>" . $num1 . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Signatures to go : " . $SignLeft . "
</b></font><br>\n";
 
###################################
 
?>
 
 
 
 </td>
  </tr>
  <tr>
    <td width="19%" height="466" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
      <p><img border="0" src="images/New/topleft.gif" width="182" height="62"><br>
        
        
        
        
        <!-- **********************************Begin Buttons and Links ***************************** -->
        
      
            <map name="FPMap0">
              
              <area shape="rect" coords="19,1,154,18" href="http://vanduzee.net" target="_parent" alt="Home">
        </map>
<img border="0" src="images/New/home.gif" usemap="#FPMap0" width="175" height="20"><br>
  
        
            <map name="FPMap1">
              <area href="missionstatement.html" target="main">
              <area shape="rect" coords="17,2,156,18" href="index.php?page=missionstatement" alt="link to ourmission statement">
        </map>    
        <a href="missionstatement.html" target="main"><img border="0" src="images/New/ourmission.gif" usemap="#FPMap1" width="175" height="20"></a><br>
        
     
    <map name="FPMap2">
    <area shape="rect" coords="17, 1, 157, 19" href="mycaptcha/captcha-petition.php" >
    </map>
    <img border="0" src="images/New/signpetition.gif" usemap="#FPMap2" width="175" height="20"><br>
    <img src="images/New/petitioncomments.gif" width="175" height="20" border="0" usemap="#Map2"><br> 
    
<map name="FPMap4">
            <area shape="rect" coords="19, 1, 156, 19" href="http://www.visi.com/juan/congress" target="_blank">
        </map>
        <img src="images/New/contactsenator.gif" width="175" height="20" border="0" usemap="#FPMap4" href="http://www.visi.com/juan/congress/"><br>
        
            <map name="FPMap5">
              <area shape="rect" coords="17, 2, 156, 19" href="index.php?page=letters">
        </map>
        <img border="0" src="images/New/govcorrespondence.gif" usemap="#FPMap5" width="175" height="20"><br>
         
            <map name="FPMap6">
              <area shape="rect" coords="18, 1, 155, 18" href="index.php?page=TheLaws">
        </map>
        <img border="0" src="images/New/laws.gif" usemap="#FPMap6" width="175" height="20"><br>
        
            <map name="FPMap7">
              <area shape="rect" coords="18, 1, 157, 19" href="index.php?page=articles">
        </map>
        <img border="0" src="images/New/articlesandinterviews.gif" usemap="#FPMap7" width="175" height="20"><br>
        
            <map name="FPMap8">
              <area shape="rect" coords="19, 2, 155, 19" href="index.php?page=ourstory">
        </map>
        <img border="0" src="images/New/ourstory.gif" usemap="#FPMap8" width="175" height="20"><br>
        
        
        
        
         <map name="FPMap9">
    <area href="mycaptcha/captcha-othercomments.php" shape="rect" coords="17, 2, 158, 19">
    </map>
    <img border="0" src="images/New/makeacomment.gif" width="175" height="20" usemap="#FPMap9"><br>
 
 
 
 
    <map name="FPMap10">
    <area href="index.php?page=viewothercomments" shape="rect" coords="18, 2, 157, 19">
    </map>
    <img border="0" src="images/New/viewothercomments.gif" width="175" height="20" usemap="#FPMap10"><br>
 
 
    <map name="FPMap11">
    <area href="mycaptcha/captcha-yourstory.php" shape="rect" coords="17, 2, 156, 19">
    </map>
    <img border="0" src="images/New/shareyourstory.gif" width="175" height="20" usemap="#FPMap11"><br> 
        
 
    <map name="FPMap12">
    <area href="index.php?page=viewstory" shape="rect" coords="18, 1, 156, 19">
    </map>
    <img border="0" src="images/New/readsubmittedstories.gif" width="175" height="20" usemap="#FPMap12"><br>
 
    <map name="FPMap14">
    <area shape="rect" coords="17, 1, 157, 18" href="index.php?page=Resume/resume">
    </map>
<img border="0" src="images/New/terrysresume.gif" width="175" height="20" usemap="#FPMap14"><br>
 
        
            <map name="FPMap15">
            <area href="mailto:&#105;&#110;&#115;&#112;&#114;&#111;&#98;&#108;&#101;&#109;&#115;&#64;&#118;&#97;&#110;&#100;&#117;&#122;&#101;&#101;&#46;&#110;&#101;&#116;?subject=INS Problems Web Site Comments" shape="rect" coords="18,0,156,18">
              <!--<area href="mailto:insproblems@vanduzee.net?subject=INS Problems Web Site" shape="rect" coords="18, 0, 156, 18">-->
        </map>
        <img border="0" src="images/New/emailus.gif" width="175" height="20" usemap="#FPMap15"><br>
            <map name="FPMap18">
              <area href="index.php?page=financialassistance" shape="rect" coords="17, 1, 157, 18">
        </map>
        <img border="0" src="images/New/financialassistance.gif" width="175" height="22" usemap="#FPMap18"><br>
        <img src="images/New/updates.gif" alt="Updates" width="175" height="20" border="0" usemap="#Map"><br>
        
         
        <!-- <map name="FPMap19">
    <area target="_blank" href="http://vanduzee.net/ChatClient/livechat.cgi" shape="rect" coords="17, 1, 157, 18">
    </map>
    <img border="0" src="images/New/chatwithus.gif" width="175" height="22" usemap="#FPMap19"><br> -->
      
        
      <!-- ************************************ End Buttons and Links ************************************
         *********************************************************************************************** -->
    <img border="0" src="images/New/bottomleft.gif" width="183" height="62"></td>
    <td width="81%" height="590" valign="top">
    
    <?php
    $page = $_GET['page'];
    //check $page for xss here - strip html tags etc
    //$page_location = "$page.".html;
    $page_location="$page.".html;
    if(file_exists($page_location))  //checks to see if file exists
       include($page_location);   //includes user selected page
    //if(file_exists($page_location)){
    }else
       include("Main.html");   //include default page - as user requested page doesnt exist
    //}
?>
    </td>
  </tr>
  <tr>
    <td colspan="2" height="23" background="images/New/topbkg.gif">
    <p align="right"><font face="Arial" size="1" color="#FFFFFF">© COPYRIGHT 
    2004 ALL RIGHTS RESERVED VANDUZEE.NET - All Information property of vanduzee.net</font></td>
  </tr>
</table>
<map name="Map"><area shape="rect" coords="17,2,157,18" href="index.php?page=updates">
</map>
 
<map name="Map2"><area shape="rect" coords="18,1,154,19" href="index.php?page=viewComments">
</map></body>
</html>
 
 
Here is the code for the Articles and Interviews page:

Code: Select all

 
 
<html>
<head><Title>Articles and Interviews</Title>
 
<META name=author content="Terry VanDuzee">
<META name=copyright content="Copyright Terry VanDuzee">
<META name=revisit-after content="14 days">
<META name=distribution content="Global">
<meta name=rating content="general">
<meta name=keywords content="INS DHS Bush USA US Canada Government Immigration Immigrate Waiver Visa I-130 I-129F I-601 I-192 US Government Bush Department of Homeland Security US Immigration US Consulate Sign our Petition INS DHS Department of Homeland Security Immigrate Immigrant Visa Waiver I-301 I-129F I-601 I-192 Marriage between countries Wedding Marriage Kept apart Without my wife Couple Unfair Law Love Bible Jesus Prayer God Holy Spirit Drive North Carolina Canada NC Senator David Price Edwards Dole State Department Criminal Record,Pardon Visit the US US Border Patrol Live in the US Automobile sports children child boy girl Our Story Radio Interview Newspaper Article Orange County Hillsborough Raleigh Durham President Email Fax Contact Congressman Vice President Department of Liaison Department of State American Canadian">
<meta name=description content="These are some of the articles and interviews we have had.">
<meta name="MSSmartTagsPreventParsing" content="True">
 
</Head>
<Body stylesrc="color2.htm" background="BG2.gif">
<basefont face="Arial">
<B><Font size="4" color="Black">Articles and Interviews</font></B><hr size="5" color="Black"><br>
<p>
 
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" height="428">
  <tr>
    <td width="26%" height="100%" valign="top"><a href="articles.php?page=cbcinterview">Radio Interview CBC</a>
           <br>
       <a href="articles.php?page=OrangeCounty1">Orange County 1</a>
            <br>
       <a href="articles.php?page=OrangeCounty2">Orange County 2</a>
            <br>
       <a href="articles.php?page=NewsObserver">News Observer</a>
            <br>
       <a href="articles.php?page=heraldsun">Chapel Hill Herald Sun</a>
            <br>
       <a href="articles.php?page=newsoforange">News Of Orange</a>
            <br>
    </td>
 
 
 
    <td width="74%" height="100%">
    
    <?php
    $page = $_GET['page'];
    //check $page for xss here - strip html tags etc
    //$page_location = "$page.".html;
    $page_location="$page.".html;
    if(file_exists($page_location)){ //checks to see if file exists
       include($page_location);   //includes user selected page
 
    //if(file_exists($page_location)){
    }else
       include("cbcinterview.html");   //include default page - as user requested page doesnt exist
    //}
?>
    
 
    </td>
  </tr>
</table>
 
 
</Body>
</html>
 
 
Thank you
Terry
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Never ending loop

Post by hansford »

you're not ending your </map>
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Never ending loop

Post by hansford »

nevermind Terry - I see the </map>
As far as the loop is concerned here it is.
In articles.html you have the following code. Since the $_GET has already been set from the index.php this code will keep loading and loading the page.

<?php
$page = $_GET['page'];
//check $page for xss here - strip html tags etc
//$page_location = "$page.".html;
$page_location="$page.".html;
if(file_exists($page_location)){ //checks to see if file exists
include($page_location); //includes user selected page

//if(file_exists($page_location)){
}else
//include("cbcinterview.html"); //include default page - as user requested page doesnt exist
//}
?>
terryvanduzee
Forum Newbie
Posts: 8
Joined: Fri May 23, 2008 11:52 pm

Re: Never ending loop

Post by terryvanduzee »

Thank you Hansford

Is there any way for me to prevent this? Is it just a matter of // the $page = $_GET['page']; ?

Thank you
Terry
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Never ending loop

Post by hansford »

Terry,
You really should be using a template based system for processing these pages. That would take too much time to go into but here is a fix for your immediate problem. All of the links contained within your site should point back to the index.php page. This way people always have a menu of the site. The content ie; articles etc.. should contain no php code. This makes it easier to edit content and code when they are seperated. The 'articles.html 'is just basically a menu of article links, so erase the php code and change the URL links to point back to index.php. if a user clicks on 'articles' then we'll include the 'articles.html' page as a menu, then we'll check if the user selected an 'article' and if so, we'll include that page as well. Let me know if this is going to work for you.

//index.php code
--------------------------------
$page = $_GET['page'];
$page_location= $page .".html";

if(file_exists($page_location)){
include($page_location); //this will load articles.html etc...

if(isset($_GET['article_id'])){ //check to see if page is article
$article = $_GET['article_id'] . ".html"; //get the article
include($article); //include article
}
}
else{
include("Main.html");
}

links on articles.html should all be in this format
------------------------------------
<a href="/index.php?page=articles&article_id=cbcinterview">articles</a><br>
Post Reply