Advanced Search

Results 1 to 5 of 5

Thread: While error neverending?

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default While error neverending?

    I have this page http://www.bluewalrus.net/testing.php. Which comes from this page http://www.bluewalrus.net/log.html. Its suppose to write code for a web page based on how many photos the user inputs but right now its ignoring the number and just keeps writing no stopping. Also the if statement above isn't working either so I don't know if theres something wrong with my declarations at the top or if its something else? Any suggestions I appreciate the php is below. Also if you go to test it the username and password don't matter yet i'm going to add those in later so you can put anything you want or nothing.
    PHP Code:
         <?php
    $user 
    $_POST['user'];
    $pass $_POST['password'];
    $event $_POST['event'];
    $maxnum $_POST['totalphotos'];
    $bp $_POST['bigpic'];
    $num 01;
         print 
    '<link rel="stylesheet" type="text/css" href="/Agov3/scripts/box/css/lightbox.css"></link> <p><script type="text/javascript" src="Agov3/scripts/box/js/prototype.js"><!--//--></script><script type="text/javascript" src="Agov3/scripts/box/js/scriptaculous.js?load=effects,builder"><!--//--></script><script type="text/javascript" src="Agov3/scripts/box/js/lightbox.js"><!--//--></script>TEXT ABOUT EVENT</p><p><a title="" href="?pageID=gov3terminal&amp;L=3&amp;L0=Home&amp;L1=Media+Center&amp;L2=Videos&amp;sid=Agov3&amp;b=terminalcontent&amp;f=videos_&amp;csid=Agov3" target="_self"><img title="" height="15" alt="" hspace="2" src="http://www.mass.gov/Agov3/images/video_icon.GIF" width="14" border="0" /></a> <a title="" href="?pageID=gov3terminal&amp;L=3&amp;L0=Home&amp;L1=Media+Center&amp;L2=Videos&amp;sid=Agov3&amp;b=terminalcontent&amp;f=videos_' $event '&amp;csid=Agov3" target="_self">Go to the video from this event</a><br /><a title="" href="?pageID=gov3subtopic&amp;L=4&amp;L0=Home&amp;L1=Key+Priorities&amp;L2=World-Class+Education+-+The+Readiness+Project&amp;L3=The+Commonwealth+Readiness+Project&amp;sid=Agov3" target="_self"><img title="transcript icon" height="15" alt="transcript icon" hspace="2" src="http://www.mass.gov/Agov3/images/complete_text_icon.gif" width="14" border="0" /></a> <a href="?pageID=gov3subtopic&amp;L=4&amp;L0=Home&amp;L1=Key+Priorities&amp;L2=World-Class+Education+-+The+Readiness+Project&amp;L3=The+Commonwealth+Readiness+Project&amp;sid=Agov3" target="_self">Learn more about the Readiness Project and read the final reports</a><br /><a title="" href="?pageID=gov3terminal&amp;L=3&amp;L0=Home&amp;L1=Media+Center&amp;L2=Speeches&amp;sid=Agov3&amp;b=terminalcontent&amp;f=text_' $event '&amp;csid=Agov3" target="_blank"><img title="transcript icon" height="15" alt="transcript icon" hspace="2" src="http://www.mass.gov/Agov3/images/complete_text_icon.gif" width="14" border="0" /></a> <a href="?pageID=gov3terminal&amp;L=3&amp;L0=Home&amp;L1=Media+Center&amp;L2=Speeches&amp;sid=Agov3&amp;b=terminalcontent&amp;f=text_' .$event '&amp;csid=Agov3" target="_blank">Read the transcript of the speech</a> (opens in a new window)<br /><a title="" href="?pageID=gov3pressrelease&amp;L=1&amp;L0=Home&amp;sid=Agov3&amp;b=pressrelease&amp;f=080625_education_reform3&amp;csid=Agov3" target="_blank"><img title="transcript icon" height="15" alt="transcript icon" hspace="2" src="http://www.mass.gov/Agov3/images/complete_text_icon.gif" width="14" border="0" /></a> <a href="?pageID=gov3pressrelease&amp;L=1&amp;L0=Home&amp;sid=Agov3&amp;b=pressrelease&amp;f=080625_education_reform3&amp;csid=Agov3" target="_blank">Read the press release</a><br /></p>';
        if (
    $bp "Yes") {
        print 
    '<h4>The "Big Picture"</h4><p>View a panoramic picture of the event. </p><table width="100%"><tbody><tr><td> <a title="" href="Agov3/images/' $event '_bp.jpg" rel="lightbox[roadtrip]"><img title="A panoramic view of the event." alt="A panoramic view of the event." src="/Agov3/images/' $event .'_bplk.jpg" border="0" /></a></td></tr></tbody></table><br />';
        }
        while ( 
    $num <= $maxnum )
        {
        print 
    '<p>Click photo to open larger version.  Right-click photo to download and save.<br /></p><table bordercolor="#c0c0c0" cellpadding="2" width="100%" border="1"><tbody><tr><td><a title="Info about photo" href="Agov3/images/' $event $num 'lb.jpg" rel="lightbox[roadtrip]"><img title="Info about photo" height="133" alt="Info about photo" src="/Agov3/images/' $event $num 'lk.jpg" width="200" border="0" /></a><center><a href="Agov3/images/' $event $num 'web.jpg" target="_blank">Full Res</a></center></td><td>Info about photo</td></tr></tbody></table>';
        }
        
    ?>

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    $num never changes, thus the infinite loop. Regardless, a for loop is more appropriate. (Remove the earlier $num = 01; assignment.)
    PHP Code:
        for ( $num 1$num <= $maxnum$num++ )
        {
        print 
    '<p>Click photo to open larger version.  Right-click photo to download and save.<br /></p><table bordercolor="#c0c0c0" cellpadding="2" width="100%" border="1"><tbody><tr><td><a title="Info about photo" href="Agov3/images/' $event $num 'lb.jpg" rel="lightbox[roadtrip]"><img title="Info about photo" height="133" alt="Info about photo" src="/Agov3/images/' $event $num 'lk.jpg" width="200" border="0" /></a><center><a href="Agov3/images/' $event $num 'web.jpg" target="_blank">Full Res</a></center></td><td>Info about photo</td></tr></tbody></table>';
        } 
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. The Following User Says Thank You to Jesdisciple For This Useful Post:

    bluewalrus (10-21-2008)

  4. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    oo thanks

    Do you see anything wrong with the if statement its showing up no matter what right now? Maybe Something suppose to be different cause i'm using radio buttons?

    [ICODE]if ($bp = 'Yes') {
    print '<h4>The "Big Picture"</h4><p>View a panoramic picture of the event.&#160;</p><table width="100%"><tbody><tr><td>&#160;<a title="" href="Agov3/images/' . $event . '_bp.jpg" rel="lightbox[roadtrip]"><img title="A panoramic view of the event." alt="A panoramic view of the event." src="/Agov3/images/' . $event .'_bplk.jpg" border="0" /></a></td></tr></tbody></table><br />';
    }[CODE]
    From the form page
    Code:
    Big Picture: Yes:<input type="radio" name="bigpic" value="Yes" checked="checked" /> No:<input type="radio" name="bigpic" value="No" />
    Last edited by bluewalrus; 10-21-2008 at 12:10 AM.

  5. #4
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Woops, I can't believe I forgot to look at that. if ($bp = "Yes") assigns "Yes" to $bp and then tests whether $bp is truthy (not unset, null, the empty string, or false). Since "Yes" is truthy, the block always executes.
    Code:
    if ($bp === "Yes")
    (The third = means the test is strict, which is usually better.)
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  6. #5
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    ooo Thanks again

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •