Jump to content

Football Results Updating Database Problem


jetpacmidge

Recommended Posts

Hi, I am new to using PHP & MYSQL and have developed a website for entering football results on a website and the tables get automatically updated. Everytime I enter the result a message of couldn't execute query appears. Where have I gone wrong ?? Below is the code for the webpages :-

[code][code]<?php
  /* Program: AddResult.php
   * Desc:    A confirmation screen  
   *          is sent to the user.
   */

  $season = $_POST['season'];
  $newteam = $_POST['newteam'];
  $fixtureDate = $_POST['fixtureDate'];
  $age = $_POST['age'];
  $division = $_POST['division'];
  $homeTeam = $_POST['homeTeam'];
  $homeScore = $_POST['homeScore'];
  $awayTeam = $_POST['awayTeam'];
  $awayScore = $_POST['awayScore'];
  $matchtype = $_POST['matchtype'];
  $team = $_POST['team'];
  $played = $_POST['played'];
  $won = $_POST['won'];
  $lost = $_POST['lost'];
  $drawn = $_POST['drawn'];
  $goalsfor = $_POST['goalsfor'];
  $goalsagainst = $_POST['goalsagainst'];
  $points = $_POST['points'];

if (@$_POST['newbutton'] == "Cancel")
  {
     header("Location: tadburnfc.htm");
  }
    if ($newteam == "new")
    {
    if ($newhometeam == "") // if the text field is blank
      {
       include("NewResultform.inc");
       exit();
    }
        else
        {
           $newteam = $newhometeam;
        }
    }

  
    
?>
<html>
<head><title>Add Result</title></head>
<?php
  include("connection.inc");
  $connection = mysql_connect($host,$user,$password)
       or die ("couldn't connect to server");
  $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

    $query = "INSERT INTO leagueTable (season,fixtureDate,age,division,homeTeam,homeScore,awayTeam,awayScore,matchtype,team,played,won,lost,drawn,goalsfor,goalsagainst,points)
            VALUES ('$season','$fixtureDate','$age','$division','$homeTeam','$homeScore','$awayTeam','$awayScore','$matchtype','','','','','','','','')";
  $result = mysql_query($query)
       or die ("Couldn't execute query.");
$teamID = mysql_insert_id();

echo "The following result has been added to the Tadburn FC database:<br>
        <ul>
         <li>Season: $season
     <li>Fixture Date: $fixtureDate
         <li>Age Group: $age
         <li>Home Team: $homeTeam
     <li>Home Score: $homeScore
     <li>Away Team: $awayTeam
     <li>Away Score: $awayScore
         <li>Match Type: $matchtype
</ul> \n";
?>
<br>
<br>
<br>
<br>
<br>
<br>
<font face="Arial, Helvetica, sans-serif" size="+2" color="#0000FF">
<div align='center'> <a href='results2.php'>Add Another Result ?</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href='tadburnfc.htm'>Return To Main Page</a></div>

</font>
</body>
</html>[/code][/code]
[code]


[code]<?php
  /* Program: results.php
   * Desc:    Allows the user to enter football results.
     *    There are drop down menus to choose the
     *    Division, Age Group, & Football Team
     */
?>
<?php
  if (@$_POST['newbutton'] == "Enter Football Results" or @$_POST['newbutton'] == "Cancel")
  {
    header("Location: tadburnfc.htm");
  }
?>
<html>
<head><title>Add Football Result</title></head>
<body>
<?php
  include("connection.inc");


  $connection = mysql_connect($host,$user,$password)
       or die ("couldn't connect to server");
  $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");


    /* create form */
  echo "<div style='margin-left: .1in'>";
  echo "<form action='AddFootballResult.php' method='post'>\n";

    include("FootballResultInfo_table.inc");

  echo "<input type='hidden' name='category' value='$category'>\n";
  echo "<p><input type='submit' value='Submit Result'>
        <input type='submit' name='newbutton' value='Cancel'>
        </form>\n";
?>[/code]

TABLE Information

create table leagueTable (
teamID INT(5) NOT NULL AUTO_INCREMENT,
season CHAR(10) NOT NULL,
fixtureDate VARCHAR(20) NOT NULL,
age CHAR(15) NOT NULL,
division VARCHAR (20) NOT NULL,
homeTeam CHAR(30) NOT NULL,
homeScore INT(3) UNSIGNED NOT NULL,
awayTeam CHAR(30) NOT NULL,
awayScore INT(3) UNSIGNED NOT NULL,
matchtype VARCHAR(10),
team CHAR(30) NOT NULL,
played INT(4) UNSIGNED NOT NULL,
won INT(4) UNSIGNED NOT NULL,
lost INT(4) UNSIGNED NOT NULL,
drawn INT(4) NOT NULL,
goalsfor VARCHAR(4) NOT NULL,
goalsagainst VARCHAR(4) NOT NULL,
points INT(3) NOT NULL,
PRIMARY KEY(teamID) );

Thanks for your help !!

Rgds,

Andy M. :D
Link to comment
Share on other sites

Hi,

Sorry the code should have read :-

<?php
/* Program: AddResult.php
* Desc: A confirmation screen
* is sent to the user.
*/

$season = $_POST['season'];
$newteam = $_POST['newteam'];
$fixtureDate = $_POST['fixtureDate'];
$age = $_POST['age'];
$division = $_POST['division'];
$homeTeam = $_POST['homeTeam'];
$homeScore = $_POST['homeScore'];
$awayTeam = $_POST['awayTeam'];
$awayScore = $_POST['awayScore'];
$matchtype = $_POST['matchtype'];
$team = $_POST['team'];
$played = $_POST['played'];
$won = $_POST['won'];
$lost = $_POST['lost'];
$drawn = $_POST['drawn'];
$goalsfor = $_POST['goalsfor'];
$goalsagainst = $_POST['goalsagainst'];
$points = $_POST['points'];

if (@$_POST['newbutton'] == "Cancel")
{
header("Location: tadburnfc.htm");
}
if ($newteam == "new")
{
if ($newhometeam == "") // if the text field is blank
{
include("NewResultform.inc");
exit();
}
else
{
$newteam = $newhometeam;
}
}



?>
<html>
<head><title>Add Result</title></head>
<?php
include("connection.inc");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");

$query = "INSERT INTO leagueTable (season,fixtureDate,age,division,homeTeam,homeScore,awayTeam,awayScore,matchtype,team,played,won,lost,drawn,goalsfor,goalsagainst,points)
VALUES ('$season','$fixtureDate','$age','$division','$homeTeam','$homeScore','$awayTeam','$awayScore','$matchtype','','','','','','','','')";
$result = mysql_query($query)
or die ("Couldn't execute query.");
$teamID = mysql_insert_id();

echo "The following result has been added to the Tadburn FC database:<br>
<ul>
<li>Season: $season
<li>Fixture Date: $fixtureDate
<li>Age Group: $age
<li>Home Team: $homeTeam
<li>Home Score: $homeScore
<li>Away Team: $awayTeam
<li>Away Score: $awayScore
<li>Match Type: $matchtype
</ul> \n";
?>
<br>
<br>
<br>
<br>
<br>
<br>
<font face="Arial, Helvetica, sans-serif" size="+2" color="#0000FF">
<div align='center'> <a href='results2.php'>Add Another Result ?</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href='tadburnfc.htm'>Return To Main Page</a></div>

</font>
</body>
</html>

Thanks,

Andy M.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.