SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form not showing up inside PHP code, but works fine if plain HTML

    Hello, I am trying to make a form display on my page, but it will not show up.
    I've tried just using the form code and it works fine on an html page.


    here is the code

    Code:
    <?php
    include("classes/privateleague.class.php");
    $private = new private_league();
    $league = $_GET['league'];
    
    if($private->check_if_user_exists_in_league($league, $_SESSION['id']))
    {
    
    
    //Displays league details
    $sql = mysql_query("SELECT * FROM pleagues WHERE id='".$league."'") or die(mysql_error());
    echo "<b>League Details:</b><br>";
    while($data2 = mysql_fetch_array($sql))
    {
    $exp_date = $data2['startdate'];
    $idd =  $data2['id'];
    echo "Name: ".$data2['name']."<br>
    Start Date: ".$data2['startdate']."<br>
    End Date: ".$data2['enddate']."<br>
    Total players per team: ".$data2['totalplayerallowed']."<br>
    Total players value: ".$data2['totalplayervalue']."<br>
    
    ";
      if($data2['owner'] == $_SESSION['id'])
      {
      echo "<a href=\"index.php?p=editleague&id=".$data2['id']."\"><font size=\"1\">Edit league</font></a><br>";
      echo "<a href=\"index.php?p=manageusers&id=".$data2['id']."\"><font size=\"1\">Manage Users</font></a><br><br>";
      }
    }
    if($_GET['league'])
    {
      //Display Users Teams for a Private League
      $sql2 = mysql_query("SELECT * FROM pteams WHERE league='".$league."'") or die(mysql_error());
      echo "<b>My Teams</b><br />";
      while($data = mysql_fetch_array($sql2))
      {
        if($data['userid'] == $_SESSION['id'])
    	{
    	echo "".$data['name']."<br><br>";
    	}
      }
    }
    ?>
    <a href="index.php?p=viewpteams&league=<?php echo $league ?>">View all league teams</a><br>
    <?php 
    $todays_date = date("Y-m-d"); 
    $today = strtotime($todays_date); 
    $expiration_date = strtotime($exp_date); 
    
    if ($expiration_date > $today) 
    { $valid = "yes"; 
    } 
    else 
    { 
    $valid = "no"; 
    }
      if($valid == 'yes')
      {
    echo $valid;
      ?>
    <?php
      $sql666 = mysql_query("SELECT * FROM pleagues WHERE id = '".$_GET['id']."'") or die(mysql_error());
      while($data66 = mysql_fetch_array($sql666))
      {
    ?>
    <form action="index.php?p=pjoin" method="POST">
    <input type="hidden" value="<?php echo $_GET['id'] ?>" name="id" />
    <input type="hidden" value="<?php echo $data66['totalplayervalue'] ?>" name="totalvalue" />
    <input type="hidden" value="<?php echo $data66['totalplayerallowed'] ?>" name="players" />
    <input type="hidden" value="<?php echo $_GET['id'] ?>" name="price" />
    <input type="hidden" value="<?php echo $data66['name'] ?>" name="name" />
    <input type="text" value="name" name="name" />
    <input type="submit" value="submit" name="submit" />
    </form>
    <?php
      }
    ?>
      <?
     
      echo "<a href=\"index.php?p=lp&id=$idd\">Create another team</a>";
      } 
      
    }
      ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    My first guess is that the following line returns false:
    PHP Code:
    if($private->check_if_user_exists_in_league($league$_SESSION['id'])) 
    To check, put this before the if statement:
    PHP Code:
    echo ($private->check_if_user_exists_in_league($league$_SESSION['id'])) ? 'this works fine' 'this is your problem'
    Another guess would be that a syntax error is causing the page to blank out.

    Try putting the following code at the top of your page to find any errors:
    PHP Code:
    <?php
    ini_set
    ('display_errors'2);
    error_reporting(E_ALL);
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $private->check_if_user_exists_in_league($league, $_SESSION['id'])
    is session is started ???
    Simply Sajan

  4. #4
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I fixed it, Thanks though

  5. #5
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What was the problem?

    Might be useful for others with a similar problem.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  6. #6
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We'll I did a mysql num rows for the sql query I wrote, and it turns out that I was calling the wrong get variable, I was calling $_GET['id'] instead of $_GET['league']

    Once I counted the rows and it came back as 0 I knew what the problem was.


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
  •