SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast Stika's Avatar
    Join Date
    Sep 2002
    Location
    Australia
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not showing output

    Hi i created this script do a First Aid training simulator and what it does is is lists all the scenario's you can do and you click on a scenario to complete it, the problem though is when i go to click on it nothing happens, here is the code


    PHP Code:
    <?php
    session_start
    ();
    include 
    'db.php';
    if (!isset(
    $id)): ?> 
    <body bgcolor="#F5E9E9"> 
    <table width="304" bgcolor="#F5E9E9" border="0" cellspacing="0" cellpadding="0" align="center"> 
      <tr> 
        <td height="17" width="300" colspan="3"></td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3" height="17">&nbsp;</td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3"> 
          <div align="center"> <b><font size="3">Module List</font></b><br><BR>  
            <? 
    mysql_select_db
    ($database_name$connection); 
    //definine table sections here 
    // Counter Strike 
    $listquery "SELECT * FROM scenario WHERE active = '1'"
    $list mysql_query($listquery$connection) or die(mysql_error()); 
    $num_results mysql_num_rows($list); //Row Count 
    for ($i=0$i <$num_results$i++) 

        
    $row mysql_fetch_assoc($list); 
        
    $rowid $row["ID"]; 
        
    $rowname $row["Name"]; 
        echo 
    "<a href='?id=$rowid'>$rowname</a><br>"

    mysql_free_result($list); 
    ?> 
          </div> 
        </td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3" height="17">&nbsp; </td> 
      </tr> 
      <tr> 
        <td height="17" background="images/site/bottom_1.gif" width="130"></td> 
        <td height="17" background="images/site/bottom_2.gif" width="146"></td> 
        <td height="17" background="images/site/bottom_3.gif" width="28"></td> 
      </tr> 
    </table> 
    </body> 
    <? else: ?> 
    <? 
    mysql_select_db
    ($database_name$connection); 
    $result mysql_query("SELECT * FROM scenario WHERE id = $id"); 
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) 

    $name $row['Name']; 
    $description $row['Description']; 
    $correct1 $row['Correct1']; 
    $wrong1 $row['Wrong1']; 
    $wrong12 $row['Wrong1-2']; 
    $correct2 $row['Correct2']; 
    $wrong2 $row['Wrong2']; 
    $wrong22 $row['Wrong2-2']; 
    $correct3 $row['Correct3']; 
    $wrong3 $row['Wrong3']; 
    $wrong32 $row['Wrong3-2']; 
    $correct4 $row['Correct4']; 
    $wrong4 $row['Wrong4']; 
    $wrong42 $row['Wrong4-2'];
    $correct5 $row['Correct5'];
    $wrong5 $row['Wrong5'];
    $wrong52 $row['Wrong5-2'];
    $correct6 $row['Correct6'];
    $wrong6 $row['Wrong6'];
    $wrong62 $row['Wrong6-2'];
    $correct7 $row['Correct7'];
    $wrong7 $row['Wrong7'];
    $wrong72 $row['Wrong7-2'];
    $correct8 $row['Correct8'];
    $wrong8 $row['Wrong8'];
    $wrong82 $row['Wrong8-2'];
    $correct9 $row['Correct9'];
    $wrong9 $row['Wrong9'];
    $wrong92 $row['Wrong9-2'];
    $correct10 $row['Correct10'];
    $wrong10 $row['Wrong10'];
    $wrong102 $row['Wrong10-2'];
    $question1 $row['Question1'];
    $question2 $row['Question2'];
    $question3 $row['Question3'];
    $question4 $row['Question4'];
    $question5 $row['Question5'];
    $question6 $row['Question6'];
    $question7 $row['Question7'];
    $question8 $row['Question8'];
    $question9 $row['Question9'];
    $question10 $row['Question10'];
    $active $row['active'];


    mysql_free_result($result); 
    ?> 

    <body bgcolor="c0c0c0"> 
    <table width="304" bgcolor="c0c0c0" border="0" cellspacing="0" cellpadding="0" align="center"> 
    <tr> 
        <td width="300" colspan="3"> 
          <div align="right"> 
            <p align="center"><font size="6"> 
              <? echo $name?> 
              </font> <br> 
              <img src="images/site/news_300_break.gif" width="304" height="7"><br> 
          </div> 
          <div align="center"> 
          <? 
          
    if ($active == "1"
          { 
          
    ?> 
    <BR><BR><b>::Minor Details::</b><BR> 
        <b>Name:</b> <? echo $name?> <BR> 
        <b>Description:</b> <? echo $description?> <BR> 
      
              </div> 
          <div align="center"> 
              </div> 
             <br> 
          </td> 
      </tr> 
    </table> 
    </body> 
    <?php 
    endif; 
    ?> 
    <p>&nbsp;</p> 
    <p>&nbsp;</p>
    btw i havent finished the code second page but it should still show up, any help would be greatly appreciated

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    vta,ca,usa
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off, you're relying on global vars in the script; is register_globals turned on in the server config? You should not rely on this, instead make use of the superglobals. Rather than use $id, you would use $_GET['id']. If you're using a current version (v4.2 or greater), register_globals is turned off by default and $id will have no value.

  3. #3
    SitePoint Enthusiast Stika's Avatar
    Join Date
    Sep 2002
    Location
    Australia
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mate, all these little simple things

  4. #4
    SitePoint Enthusiast Stika's Avatar
    Join Date
    Sep 2002
    Location
    Australia
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so maybe i forgot to turn register_globals back off, I still have the same problem, i click on the link and nothing i added the $_get['id'] thing and it dident fix it. Here is an update of the code, any help would be greatly appreciated

    PHP Code:
    <?php
    session_start
    ();
    include 
    'db.php';
    if (!isset(
    $id)): 
    ?>
    <body bgcolor="#F5E9E9"> 
    <table width="304" bgcolor="#F5E9E9" border="0" cellspacing="0" cellpadding="0" align="center"> 
      <tr> 
        <td height="17" width="300" colspan="3"></td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3" height="17">&nbsp;</td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3"> 
          <div align="center"> <b><font size="3">Module List</font></b><br><BR>  
            <? 
    mysql_select_db
    ($database_name$connection); 
    //definine table sections here 
    // Counter Strike 
    $listquery "SELECT * FROM scenario WHERE active = '1'"
    $list mysql_query($listquery$connection) or die(mysql_error()); 
    $num_results mysql_num_rows($list); //Row Count 
    for ($i=0$i <$num_results$i++) 

        
    $row mysql_fetch_assoc($list); 
        
    $rowid $row["ID"]; 
        
    $rowname $row["Name"]; 
        echo 
    "<a href='?id=$rowid'>$rowname</a><br>";
     

    mysql_free_result($list); 
    ?> 
          </div> 
        </td> 
      </tr> 
      <tr> 
        <td width="300" colspan="3" height="17">&nbsp; </td> 
      </tr> 
      <tr> 
        <td height="17" background="images/site/bottom_1.gif" width="130"></td> 
        <td height="17" background="images/site/bottom_2.gif" width="146"></td> 
        <td height="17" background="images/site/bottom_3.gif" width="28"></td> 
      </tr> 
    </table> 
    </body> 
    <? else: ?>
    <?
    mysql_select_db
    ($database_name$connection); 
    $sql 'SELECT * FROM scenario WHERE id='.$_GET['ID'].'';
    $result mysql_query($sql$db) or die(mysql_error()); 
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) 

    $name $row['Name']; 
    $description $row['Description']; 
    $correct1 $row['Correct1']; 
    $wrong1 $row['Wrong1']; 
    $wrong12 $row['Wrong1-2']; 
    $correct2 $row['Correct2']; 
    $wrong2 $row['Wrong2']; 
    $wrong22 $row['Wrong2-2']; 
    $correct3 $row['Correct3']; 
    $wrong3 $row['Wrong3']; 
    $wrong32 $row['Wrong3-2']; 
    $correct4 $row['Correct4']; 
    $wrong4 $row['Wrong4']; 
    $wrong42 $row['Wrong4-2'];
    $correct5 $row['Correct5'];
    $wrong5 $row['Wrong5'];
    $wrong52 $row['Wrong5-2'];
    $correct6 $row['Correct6'];
    $wrong6 $row['Wrong6'];
    $wrong62 $row['Wrong6-2'];
    $correct7 $row['Correct7'];
    $wrong7 $row['Wrong7'];
    $wrong72 $row['Wrong7-2'];
    $correct8 $row['Correct8'];
    $wrong8 $row['Wrong8'];
    $wrong82 $row['Wrong8-2'];
    $correct9 $row['Correct9'];
    $wrong9 $row['Wrong9'];
    $wrong92 $row['Wrong9-2'];
    $correct10 $row['Correct10'];
    $wrong10 $row['Wrong10'];
    $wrong102 $row['Wrong10-2'];
    $question1 $row['Question1'];
    $question2 $row['Question2'];
    $question3 $row['Question3'];
    $question4 $row['Question4'];
    $question5 $row['Question5'];
    $question6 $row['Question6'];
    $question7 $row['Question7'];
    $question8 $row['Question8'];
    $question9 $row['Question9'];
    $question10 $row['Question10'];
    $active $row['active'];


    mysql_free_result($result$connection); 
    ?> 

    <body bgcolor="c0c0c0"> 
    <table width="304" bgcolor="c0c0c0" border="0" cellspacing="0" cellpadding="0" align="center"> 
    <tr> 
        <td width="300" colspan="3"> 
          <div align="right"> 
            <p align="center"><font size="6"> 
              <? echo $name?> 
              </font> <br> 
              <img src="images/site/news_300_break.gif" width="304" height="7"><br> 
          </div> 
          <div align="center"> 
          <? 
          
    if ($active == "1"
          { 
          
    ?> 
    <BR><BR><b>::Test::</b><BR> 
        <b>Name:</b> <? echo $name?> <BR> 
        <b>Description:</b> <? echo $description?> <BR> 
        <b>Rank:</b> <? echo $rank?> <BR> 
        <b>Location:</b> <? echo $location?> <BR> 
        <b>Personal Site:</b> <a href="<? echo $website?>"><? echo $website?></a> <BR><BR> 
    <b>::Counter-Strike::</b><BR> 
        <b>Favourite Weapon:</b> <? echo $cs_primary_weapon?> <br> 
        <b>Favourite Handgun:</b> <? echo $cs_secondary_weapon?><br> 
        <b>Favourite Server:</b> <? echo $server?><BR> 
        <b>Favourite Team:</b> <? echo $team?><BR> 
        <b>Average hours A week playing <? echo $division?>:</b> <? echo $hours?><BR> 
        <b>Have been playing <? echo $division?> for how long:</b> <? echo $time?><BR> 
        <b>Favourite Map:</b> <? echo $map?><br> 
              </div> 
          <div align="center"> 
              </div> 
             <br> 
          </td> 
      </tr> 
    </table> 
    </body> 
    <?php };
    endif; 
    ?>

  5. #5
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (!isset($id)): should be if(empty($_GET['id'])):

    echo "<a href='?id=$rowid'>$rowname</a><br>"; doesn't look right either as it would produce a link to somewhere link "?id=4" .. surely you want a link to somewhere like somefile.php?id=4 ?

  6. #6
    SitePoint Enthusiast Stika's Avatar
    Join Date
    Sep 2002
    Location
    Australia
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweet, your a legend mate, thanks.

    Also what would i do about that link thing i changed it to filename.php?id=$id but i just realised you could type id=4 and still get the same page, mind you there is no id 4 anyway but still.

    Any help would be greatly appreciated


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
  •