+ Reply to Thread
Results 1 to 7 of 7

Thread: PHP help

  1. #1
    Aravinthan is offline x10Hosting Member Aravinthan is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    68

    PHP help

    Hi,
    I am making a personal website in which I show my teams and my recent hockey scores. So I made this code, that will insert the recent games in a table and update the players points table.:
    form.php:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Aravinthan, Sivaneswaran</title>
    <meta http-equiv="Content-Language" content="English" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="../../style.css" media="screen" />
    </head>
    <body>
    <div id="wrap">
    <div id="header">
    <h1><a href="#">Aravinthan Sivaneswaran</a></h1>
    <h2>My Personal Website</h2>
    </div>
    <!-- Top Navigation -->
    <?php include("../../include/topnav.php"); ?>
    <!-- Top Navigation End -->
    <!-- Conteant -->
    <div id="content">
    <div class="right">
    <h2>Hockey</h2>
    <br /><br />
    <form method="post" action="formprocess.php">
     <table>
      <tr>
       <td>
        Game Number: <input type="text" name="gamenumber" maxlength="2" />
       </td>
      </tr>
      <tr>
       <td>
        Goals For: <input type="text" name="gf" maxlength="2" size="5%" />
       </td>
       <td>
        Goals Against: <input type="text" name="ga" maxlength="2" size="5%" />
       </td>
      </tr>
      <tr>
      <?php
      $link = mysql_connect ("localhost", "stmaxel_ara", "*edited*")
      or die("mysql_error()");
    mysql_select_db ("stmaxel_stats", $link);
    $result = mysql_query("SELECT fname, lname FROM `2008-2009` ",$link);
     echo "<th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'></font></th>
     <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>Name</font></th>
     <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>G</font></th>
     <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>A</font></th>
    <th align='center' BGCOLOR='#413326'><FONT COLOR='#FFFFFF' size='3'>P</font></th>";
    echo "</tr>";
    while($row = mysql_fetch_array($result))
    {
     $lname = $row['lname'];
     $fname = $row['fname'];
     echo "<tr>";
     echo "<td>";
     echo "$lname, $fname:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='$lname' value='$lname, $fname' readonly />";
     echo "</td>";
     echo "<td>";
     echo "<input size='1%' type='text' name='$lnameg' maxlength='2'/>";
     echo "</td>";
     echo "<td>";
     echo "<input size='1%' type='text' name='$lnamea' maxlength='2' />";
     echo "</td>";
     echo "<td>";
     echo "<input size='1%' type='text' name='$lnamep' maxlength='2' />";
     echo "</td>";
     echo "</tr>";
     }
    ?>
    <tr>
     <td>
      <input type="submit" value="Submit" />
      <input type="reset" value="Reset" />
     </td>
    </tr>
    </table>
    </form>
    <br /><br />
    Thanks for visiting my site and enjoy your stay,
    Ara
    </div>
    <!-- Content End -->
    <!-- Left Navigation -->
    <?php include("../../include/leftnav.php"); ?>
    <!-- Left Navigation End -->
    <div style="clear: both;"> </div>
    </div>
    <div id="bottom"> </div>
    <!-- Footer -->
    <?php include("../../include/footer.php"); ?>
    <!-- Footer End -->
    </div>
    </body>
    </html>
    formprocess.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Aravinthan, Sivaneswaran</title>
    <meta http-equiv="Content-Language" content="English" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="../../style.css" media="screen" />
    </head>
    <body>
    <div id="wrap">
    <div id="header">
    <h1><a href="#">Aravinthan Sivaneswaran</a></h1>
    <h2>My Personal Website</h2>
    </div>
    <!-- Top Navigation -->
    <?php include("../../include/topnav.php"); ?>
    <!-- Top Navigation End -->
    <!-- Conteant -->
    <div id="content">
    <div class="right">
    <h2>Hockey</h2>
    <br /><br />
    <?php
    $link = mysql_connect ("localhost", "user", "pass") or die(mysql_error());
    mysql_select_db("stmaxel_stats") or die(mysql_error());
    $gameid = $_POST['gamenumber'];
    $gf = $_POST['gf'];
    $ga = $_POST['ga'];
    $lname = $_POST['lname'];
    $lnameg = $_POST['lnameg'];
    $lnamea = $_POST['lnamea'];
    $lnamep = $_POST['lnamep'];
    if (gf > ga){
      $winner = "Win";
      }
      else{
      $winner = "Loss";
      }
    $sql="SELECT COUNT(*) AS count
            FROM games
            WHERE gameid='$gameid'";
    $result=mysql_query($sql);
    $row=mysql_fetch_assoc($result);
    if ($row['count']>0){
       echo "There is already a game with this id.";
       }
    else {
     if (lnamep > 0){
      mysql_query("INSERT INTO games (gameid, gf, ga, winner, lname, lnameg, lnameg, lnamep ) VALUES ('$gameid', '$gf', '$ga', '$winner', '$lname', '$lnameg', '$lnamea', '$lnamep')") or die(mysql_error());
      print "Game $gameid has been successfully inserted into the database. Details:
      Winner of the game: $winner<br/>
      Scorers: $lname, $lnameg, $lnamea, $lnamep ";
        $res = mysql_query("SELECT * FROM `2008-2009` WHERE lname='$lname' ",$link);
        while($row = mysql_fetch_array( $res)) {
                    $goals = $lnameg + $row['goals'];
                    $assists = $lnamea + $row['assists'];
                    $point = $lnamep + $row['points'];
                    mysql_query("UPDATE `2008-2009` SET points='$point', gp='$gp', goals='$goals', assists='$assists' WHERE lname='$lname'") or die(mysql_error());
                    print " The players have been succesfuly updated. <a href='http://aravinthan.x10hosting.com/English/hockey/myteamscorers.php?sort=p'> View Scorers </a>";
                   }
             }
      }
    
    ?>
    </div>
    <!-- Content End -->
    <!-- Left Navigation -->
    <?php include("../../include/leftnav.php"); ?>
    <!-- Left Navigation End -->
    <div style="clear: both;"> </div>
    </div>
    <div id="bottom"> </div>
    <!-- Footer -->
    <?php include("../../include/footer.php"); ?>
    <!-- Footer End -->
    </div>
    </body>
    </html>
    And when I want to test it, I enter the numbers in the form.php file well but I get this error when I reach formprocess.php:
    HTTP 500 Internal Server Error

    Thanks for your help,
    Ara
    Last edited by galaxyAbstractor; 01-24-2009 at 01:15 PM.

  2. #2
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: PHP help

    Modify that to hide your mysql username and password in the mysql_connect() call.

    I'll edit this soon to answer your question. Although a 500 error with php is unusual. I doubt the error is in your code.

    ***

    Well, aside from several typos and some other possible low-level issues, there's nothing that should cause a 500 error. Do you use any .htaccess files? If so, post them. Most 500 errors with php are caused by an error in a .htaccess file. You don't need to post any that were there when you first got your account, though, unless you modified them.
    Last edited by woiwky; 01-24-2009 at 12:37 PM.
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  3. #3
    Aravinthan is offline x10Hosting Member Aravinthan is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    68

    Re: PHP help

    No I dont use any .htaccess file....
    WEll I dont get get that 500 error any more. But my formprocess.php page is blank, well the code stays blank. No php echo() gets called. But except the coding everything else is displayed.

    ***********
    I look at the code and I know that it looks really noob, but I just cant find a way to make it better. If you can help me make it better, it would be really nice.....
    ***********
    And there is a comment script that worked 2 days ago that isnt working anymore:
    http://aravinthan.x10hosting.com/Eng...key/hockey.php
    There should be a comment form which isnt being showed.....
    and the rest of the page neither...
    here is the code that the tutorial told me to put:
    Code:
    <?php
    $page_id = "1"; // for example
    include("comments/comments_show.php");
    include("comments/comments_form.php");
    ?>
    Of course there is the rest of the pages that has been hosted.
    So the comments_show.php pages is shown, but the rest is ommited, the rest of my page too. Any one know why?
    Thanks for your help,
    Ara
    Last edited by Aravinthan; 01-24-2009 at 03:27 PM. Reason: More Info

  4. #4
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: PHP help

    is it possible to give us the page life? so we can see the errors.
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  5. #5
    Aravinthan is offline x10Hosting Member Aravinthan is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    68

    Re: PHP help

    Ok,
    here is the page with the include in it:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Aravinthan, Sivaneswaran</title>
    <meta http-equiv="Content-Language" content="English" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="../style.css" />
    </head>
    <body>
    <div id="wrap">
    <div id="header">
    <h1><a href="#">Aravinthan Sivaneswaran</a></h1>
    <h2>My Personal Website</h2>
    </div>
    <!-- Top Navigation -->
    <?php include("../include/topnav.php"); ?>
    <!-- Top Navigation End -->
    <!-- Conteant -->
    <div id="content">
    <div class="right">
    <h2>Hockey</h2>
    <br /><br />
    <h2>January 21</h2>
    <hr />
    <br /><br />
    We just passed the mid-way season of the <a href="http://nhl.com">NHL</a> and there has been some suprises. The biggest suprise I would say is the fact that Bruins are leading the Eastern Conference.<br /><br />
    At the beginning of the year, almost all of us tought it would be a tight race for the 1st spot in the Eastern Conference between <a href="www.canadiens.com">Montreal Canadiens</a>, <a href="http://capitals.nhl.com/">Washington Capitals</a> and the <a href="http://penguins.nhl.com/">Pittsburgh Penguins</a>.<br /><br />
    We were right for 2 of the 3 teams. But we complety were wrong with the Penguins. The Penguins are currently 10 in the Eastern Conference, with 50 points in 48 games which is 21 points less than the <a href="http://bruins.nhl.com/">Boston Bruins</a> who is suprsingly in the top of the standings.<br /><br />
    The Capitals are doing pretty well with 63 points in 48 games, which is worth for the 2nd place. Follwing closely is the <a href="http://rangers.nhl.com/">New York Rangers</a> with 60 points in 48 games. <br /><br />
    The Habs are ranked 4th with 60 points in 45 games.
    <br /><br />
    <hr />
    <h2>Sources / Intersting Links</h2>
    <ul>
    <li><a href="http://nhl.com">National Hockey League(NHL)</a></li>
    <li><a href="http://hockeybuzz.com">HockeyBuzz( Trade Rumors)</a></li>
    <li><a href="http://rds.ca">Reseau Des Sports(RDS in French)</a></li>
    </ul>
    <br /><br />
    <?php
    $page_id = "1"; // for example
    include("comments/comments_show.php");
    include("comments/comments_form.php");
    ?>
    <br /><br />
    Thanks for visiting my site and enjoy your stay,
    Ara
    </div>
    <!-- Content End -->
    <!-- Left Navigation -->
    <?php include("../include/leftnav.php"); ?>
    <!-- Left Navigation End -->
    <div style="clear: both;"> </div>
    </div>
    <div id="bottom"> </div>
    <!-- Footer -->
    <?php include("../include/footer.php"); ?>
    <!-- Footer End -->
    </div>
    </body>
    </html>
    comments_form.php:
    Code:
    <?php
    // edit form style ONLY in the HTML section enclosed in comment tags below
    include("includes/comments-config.php");
    if ($commoff != 1) {
    ?>
    <form action="comments/comments_process.php" method="post" style='margin-top:10px;'>
    <?php
    // get the page ID and URL and add to form as required inputs
    $ret_url = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
    echo "<input type='hidden' name='ret_url' value='". $ret_url. "'/>"; 
    echo "<input type='hidden' name='page_id' value='" .$page_id. "' />";
    ?>
    <!--form style is taken from your page style - you MAY edit below here-->
    <table cellpadding="3" cellspacing="1" style="border:1px dotted #666;">
    <tr><td><p><?php echo $your_name;?></p></td><td align='right'><input type="text" name="name" size="24" maxlength="40" /></td></tr>
    <tr><td><p><?php echo $your_location;?></p></td><td align='right'><input type="text" name="locn" size="24" maxlength="40"/></td></tr>
    <?php
    // this section provides the countries drop-down if 'show flags' is active
    if ($show_flags == 1) { include("includes/show-countries.php"); }
    ?>
    <?php
    // this section provides a 'rating' dropdown input if 'art_rating' is active
    if ($art_rating == 1) { include("includes/show-ratings.php"); }
    ?>
    <tr><td colspan="2"><p><?php echo $your_comments;?></p></td></tr>
    <tr><td colspan="2"><textarea cols="35" rows="5" name="comments"></textarea></td></tr>
    <?php
    // this section provides a captcha image and input if 'captchas' is active
    if ($captchas == 1) {
       echo "<tr><td><p>Security check *</p><img src='comments/captcha/captcha_image.php' alt='security image' border='0'/></td>";
       echo "<td valign='top' align='right'><input type='text' name='secure_match' size='6' style='background-color:#eee;'/></td></tr>";
    }
    ?>
    <tr><td>&nbsp;</td><td align='right'>
    <input style="margin:2px; background-color:#9999cc;" type="submit" name="submit" value="<?php echo $form_submit;?>" />
    </td></tr></table>
    </form>
    <!--do not edit below here-->
    <?
    }
    ?>

  6. #6
    Aravinthan is offline x10Hosting Member Aravinthan is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    68

    Re: PHP help

    comments_show.php:

    Code:
    <?php
    
    /************************************************************************************
    
    Page Comments - Written by Andy Bowers | http://www.halfadot.com | andy@halfadot.com
    
    Version 6.0 - release date 2008-02-28 [Original Version 1 release 2003-11-28]
    
    You are free to use this script as long as the credits and notes are not removed.  If
    
    you intend to distribute this script, make sure to include all of the files from the
    
    original zip package.  Your use of this script is subject to the terms of the license
    
    included in the zipped package as license.txt, and constitutes acceptance thereto.
    
    Please e-mail me with any questions or comments - I may even respond :)
    
    */
    
    /***********************************************************************************
    
    There is no need to edit ANYTHING below this comment.  Almost EVERYTHING you need
    
    to edit is contained in the comments-config.php file and comments-lang.php file. 
    
    PLEASE READ THE DOCUMENTATION FILE!
    
    ************************************************************************************/
    
    include("includes/comments-config.php"); // configuration parameters package
    
    include("includes/comments-lang.php"); // language/words package
    
    $comm_page = is_numeric($_GET['comm_page']) ? $_GET['comm_page'] : 1;
    
    if ($comm_page<1) {
    
     $comm_page = 1;
    
    }
    
    // Figure out the limit for the query based on the current page number. 
    
    $from = $comm_page * $comment_limit - $comment_limit;
    
    include("includes/db_conn.php"); // connect to host and select db
    
    mysql_connect($db_host, $db_user, $db_pass) or die("Connection Error: ". mysql_error());
    
    mysql_select_db($db_name);
    
    // construct page query to find out how many matches
    
    $result=mysql_db_query($db_name,"select count(*) from $db_table WHERE page_id='$page_id' AND is_approved = '1'");
    
    $count=mysql_result($result,0,"count(*)");
    
    $total_pages = ceil($count / $comment_limit);
    
    // and the average rating is ...
    
    $query = "SELECT AVG(rating) from $db_table WHERE page_id='$page_id' AND is_approved = '1' AND rating>'0'";
    
    $result = mysql_query($query) or die("error ". mysql_error(). " with query ".$query);
    
    $row = mysql_fetch_array($result);
    
    $av_rating = number_format($row['AVG(rating)'],2);
    
    // construct page query to find out how many matches
    
    $query = "SELECT * from $db_table WHERE page_id = '$page_id' AND is_approved = '1' ORDER by dated DESC LIMIT $from, $comment_limit";// what matches THIS page?
    
    $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); 
    
    // skip output if no comments exist
    
    if (!$count) {
    
     echo "<p style='". $num_style. "'>". $no_comments. "</p>";
    
    } else {
    
     echo "<p style='". $num_style. "'>". $comments_to_date. $count. $this_is_page. $comm_page. $page_of_page. $total_pages. ". ";
    
     if (($av_rating>0) && ($art_rating==1)) {
    
        $stars = 5 * round($av_rating/0.5);
    
        echo $average_rating. "<img src='comments/images/stars/stars_". $stars. ".gif' alt=''/>";
    
     }
    
     echo "</p>";
    
     // output comments
    
     echo "<table cellpadding='0' cellspacing='0' width='100%' border='0' align='center'>";
    
     while ($myrow = mysql_fetch_array($result)) // loop through all results
    
     { 
    
      $style = $style == $ro1 ? $ro2 : $ro1; 
    
      echo "<tr bgcolor='". $style. "'>";
    
      echo "<td><p style='". $comm_style. "'><strong>";
    
      if (!$myrow['name']) {
    
       echo $unknown_poster;
    
      } else {
    
       echo $myrow['name'];
    
      }
    
      echo "&nbsp;&nbsp;&nbsp;";
    
      if (!$myrow['location']) {
    
       echo $unknown_location;
    
      } else {
    
       echo $myrow['location'];
    
      }
    
      if ($show_flags == 1) {
    
       $flag_image = "comments/images/flags/". $myrow['flag']. ".gif";
    
       if (file_exists($flag_image)) {
    
        $size = getimagesize($flag_image);
    
        echo "&nbsp;<img src='". $flag_image. "' ". $size[3]. " alt=''/>";
    
       }
    
      }
    
      echo "</strong></p></td>";
    
      echo "<td align='right'><p style='". $comm_style. "'>";
    
      niceday($myrow['dated']);
    
      if (($art_rating==1) && ($myrow['rating']>0) && ($visitor_rating==1)) {
    
         $star_img = "comments/images/stars/stars_". 10*$myrow['rating']. ".gif";
    
         $size = getimagesize($star_img);
    
         echo "&nbsp;<img src='". $star_img. "' ". $size[3]. " alt=''/>";
    
      }
    
      echo "</p></td></tr>";
    
      echo "<tr bgcolor='". $style. "'>";
    
      echo "<td colspan='2' style='border-bottom:1px dotted ". $space_color. ";'><p style='". $comm_style. "'>";
    
      $comments = stripslashes($myrow['comments']);
    
      if (strlen($comments)>$maxshow_comments) {
    
         $comments = substr($comments,0,$maxshow_comments). "... <a href='comments/showmore.php?id=". $myrow['id']. "'>". $show_more. "</a>&nbsp;<strong>&raquo;</strong>";
    
      }
    
      echo nl2br($comments);
    
      if ($myrow['admin_comment']) {
    
       echo "<br/><br/>". $admin_comment. "&nbsp;<span style='color:#c30;'><em>". $myrow['admin_comment']. "</span></em>";
    
      } 
    
      echo "</p></td></tr>\n";
    
     }
    
     // loop done
    
     echo "</table>\n";
    
    }
    
    // Pagination magic (of sorts)
    
    if ($total_pages>1) {
    
       echo "<p><br/>Page:&nbsp;";
    
       for ($z=-5; $z<6;$z++) {
    
        $dapage = $comm_page+$z;
    
        if (($dapage>0) && ($dapage<=$total_pages)) {
    
         if ($dapage==$comm_page) {
    
          echo "-". $dapage. "-";
    
         } else {
    
          echo "<a class='pagelink' href='". $_SERVER['PHP_SELF']. "?comm_page=". $dapage. "'>&nbsp;". $dapage. "&nbsp;</a>";
    
         }
    
         echo "&nbsp;&nbsp;";
    
        }   
    
       }
    
       echo "</p>";
    
    }
    
    echo "<br/><a href='http://www.digitalmidget.com/php_noob' target='_blank'><img src='comments/images/credits.gif' border='0' alt=''/></a><br/>";
    
    ?>
    Thanks for your help,

    Ara

  7. #7
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: PHP help

    It works right?

    you can remove my comment
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers