Jump to content

Unable to submit data to the database


midge1970

Recommended Posts

Hi,

I am having problems sending data to the database as. The following msg appears :-
"Couldn't Execute Query". Below code for scripts :-

connection.inc file

[code]<?php
  $user="root";
  $host="localhost";
  $password="tigg3r";
  $database="tadburnfc";
?>[/code]
ADDFOOTBALLRESULT.php
[code]<?php
  /* Program: AddResult.php
   * Desc:    A confirmation screen  
   *          is sent to the user.
   */

  $season = $_POST['season'];
  $fixturedate = $_POST['fixturedate'];
  $agegroup = $_POST['agegroup'];
  $division = $_POST['division'];
  $hometeam = $_POST['hometeam'];
  $homescore = $_POST['homescore'];
  $awayteam = $_POST['awayteam'];
  $awayscore = $_POST['awayscore'];
  $matchtype = $_POST['matchtype'];
  

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 results (season,fixturedate,agegroup,division,hometeam,homescore,awayteam,awayscore,matchtype)
            VALUES ('$season','$fixturedate','$agegroup','$division','$hometeam','$homescore','$awayteam','$awayscore','$matchtype')";
  $result = mysql_query($query)
       or die ("Couldn't execute query.");
$resultid = 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: $agegroup
         <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]
footballresults.php
[code]<?php
  /* Program: footballresults.php
   * Desc:    Allows the Administrator to enter the football
   *          results which updates the tables.
     */
?>
<?php
  if (@$_POST['newbutton'] == "Return to Tadburn Boys Main Page" or @$_POST['newbutton'] == "Cancel")
  {
    header("Location: tadburnfc.htm");
  }
?>
<html>
<head><title>Enter Football Results</title>
<style>
<!--
        A {text-decoration: none; color:#00008B}
-->
</style>


</head>
<BODY BGCOLOR="FAFAD2" TEXT="00008B" LINK="00008B" VLINK="00008B" ALINK="00008B">

<?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 */

  include("FootballResultInfo_table.inc");

  echo "<form action='ADDFOOTBALLRESULT.php' method='post'>\n";

  echo "<p><input type='submit' value='Submit Result'>&nbsp;&nbsp;&nbsp;&nbsp;
        <input type='submit' name='newbutton' value='Cancel'>
        </form>\n";

    
?>

</body>
</html>[/code]
FOOTBALLRESULTSINFO_TABLE.inc

[code]<HTML><HEAD><TITLE>Results</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE>A {
    COLOR: #00008b; TEXT-DECORATION: none
}
</STYLE>

<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY text=#00008b vLink=#00008b aLink=#00008b link=#00008b bgColor=#fafad2>
<FORM action=ADDRESULT.php method=post>
<CENTER><B><FONT face="Arial, Helvetica, sans-serif" color=#0000ff
size=+3>Results</FONT></B> </CENTER><BR><BR><FONT
face="Arial, Helvetica, sans-serif" color=#0000ff size=+1>
<P>Enter the football score on the form below !!</P><BR><BR><FONT
face="Arial, Helvetica, sans-serif" color=#0000ff>
<TABLE border=0>

  <tr><td align='right'>Season :</td>
<td><input type='text' name='season'
               value="<?php echo $season ?>"
      size='7' maxlength='7'> (enter season as 2003/04)</td>

<tr><td align='right'>Fixture Date :</td>
<td><input type='text' name='fixturedate'
            value="<?php echo $fixturedate ?>"
            size='12' maxlength='12'> (enter date as 13 Jan 2006)</td>
</tr>
<TR>
    <TD align=right>Age Group:</TD>
    <TD><SELECT name=agegroup> <OPTION value="Under 8">Under 8</OPTION><OPTION value="Under 9">Under 9</OPTION><OPTION
        value="Under 10">Under 10</OPTION><OPTION value="Under 11">Under 11</OPTION><OPTION value="Under 12">Under 12</OPTION><OPTION
        value="Under 13">Under 13</OPTION><OPTION value="Under 14">Under 14</OPTION><OPTION value="Under 15">Under 15</OPTION><OPTION
        value="Under 16">Under 16</OPTION></SELECT></TD>
  <TR>
    <TD align=right>Division or League :</TD>
    <TD><SELECT name=division> <OPTION value="Blue League">Blue League</OPTION><OPTION value="White League">White League</OPTION><OPTION value="Division 1">Division 1</OPTION><OPTION value="Division 2">Division 2</OPTION><OPTION value="Division 3">Division 3</OPTION><OPTION value="Division 4">Division 4</OPTION></SELECT></TD>
  <TR>
    <TD align=right>Home Team :</TD>
    <TD><SELECT name=hometeam> <OPTION value="AFC Hiltingbury Blue">AFC Hiltingbury Blue</OPTION><OPTION value="Alresford Town Tigers">Alresford Town Tigers</OPTION><OPTION
        value="Baddesley Park">Baddesley Park</OPTION><OPTION value="Bashley Blades">Bashley Blades</OPTION><OPTION value="Bitterne">Bitterne</OPTION><OPTION value="Botley Village">Botley Village</OPTION><OPTION value="Brendon">Brendon</OPTION><OPTION value="BTC Southampton">BTC Southampton</OPTION><OPTION value="Burridge">Burridge</OPTION><OPTION value="City Wide">City Wide</OPTION><OPTION value="Colden Common A">Colden Common A</OPTION><OPTION value="Colden Common B">Colden Common B</OPTION><OPTION value="Dougland Blue">Dougland Blue</OPTION><OPTION value="Eastleigh Blue">Eastleigh Blue</OPTION><OPTION value="Eastleigh FC">Eastleigh FC</OPTION><OPTION
        value="Fawley Falcons">Fawley Falcons</OPTION><OPTION value="Hedge End A">Hedge End A</OPTION><OPTION value="Hedge End B">Hedge End B</OPTION><OPTION value="Hedge End C">Hedge End C</OPTION><OPTION value="Hedge End Rangers A">Hedge End Rangers A</OPTION><OPTION value="Hedge End Rangers B">Hedge End Rangers B</OPTION><OPTION value="Hillcrest Red">Hillcrest Red</OPTION><OPTION value="Hiltingbury Blue">Hiltingbury Blue</OPTION><OPTION value="Hythe Strikers">Hythe Strikers</OPTION><OPTION value="Hythe Strikers B">Hythe Strikers B</OPTION><OPTION value="Hythe Strikers Spitfires">Hythe Strikers Spitfires</OPTION><OPTION value="Ice Sports">Ice Sports</OPTION><OPTION value="Itchen Royals">Itchen Royals</OPTION><OPTION value="Jewson Jfc">Jewson Jfc</OPTION><OPTION value="Langley Manor Blue">Langley Manor Blue</OPTION><OPTION value="Littleton Leopards">Littleton Leopards</OPTION><OPTION
        value="M & T Hawks">M & T Hawks</OPTION><OPTION value="Marchwood Rangers">Marchwood Rangers</OPTION><OPTION value="Oakwood Colts">Oakwood Colts</OPTION><OPTION value="Pace Pumas">Pace Pumas</OPTION><OPTION value="Sarisbury Sparks">Sarisbury Sparks</OPTION><OPTION value="St Francis Rovers">St Francis Rovers</OPTION><OPTION value="Stoneham Rangers">Stoneham Rangers</OPTION><OPTION value="Tadburn">Tadburn</OPTION><OPTION value="Tadburn Panthers">Tadburn Panthers</OPTION><OPTION
        value="Testwood Dragoons">Testwood Dragoons</OPTION><OPTION value="Testwood Lancers">Testwood Lancers </OPTION><OPTION value="Testwood United">Testwood United</OPTION><OPTION value="Townhill Emperors">Townhill Emperors</OPTION><OPTION value="Warsash Wasps Blue">Warsash Wasps Blue</OPTION><OPTION value="Warsash Wasps">Warsash Wasps</OPTION><OPTION value="West Totton Wanderers">West Totton Wanderers</OPTION><OPTION value="Winsoor Sports">Winsor Sports</OPTION><OPTION
        value="Wyvern Blue">Wyvern Blue</OPTION><OPTION value="Wyvern Youth">Wyvern Youth </OPTION></TD>
    </tr>
    <TR>
    <TD align=right>Home Score :</TD>
<td><input name='homescore'
            value="<?php echo $homescore ?>"
            size='3' maxlength='3'></td>
        </tr>

  <TR>
    <TD align=right>Away Team :</TD>

    <TD><SELECT name=awayteam><OPTION value="AFC Hiltingbury Blue">AFC Hiltingbury Blue</OPTION><OPTION value="Alresford Town Tigers">Alresford Town Tigers</OPTION><OPTION
        value="Baddesley Park">Baddesley Park</OPTION><OPTION value="Bashley Blades">Bashley Blades</OPTION><OPTION value="Bitterne">Bitterne</OPTION><OPTION value="Botley Village">Botley Village</OPTION><OPTION value="Brendon">Brendon</OPTION><OPTION value="BTC Southampton">BTC Southampton</OPTION><OPTION value="Burridge">Burridge</OPTION><OPTION value="City Wide">City Wide</OPTION><OPTION value="Colden Common A">Colden Common A</OPTION><OPTION value="Colden Common B">Colden Common B</OPTION><OPTION value="Dougland Blue">Dougland Blue</OPTION><OPTION value="Eastleigh Blue">Eastleigh Blue</OPTION><OPTION value="Eastleigh FC">Eastleigh FC</OPTION><OPTION
        value="Fawley Falcons">Fawley Falcons</OPTION><OPTION value="Hedge End A">Hedge End A</OPTION><OPTION value="Hedge End B">Hedge End B</OPTION><OPTION value="Hedge End C">Hedge End C</OPTION><OPTION value="Hedge End Rangers A">Hedge End Rangers A</OPTION><OPTION value="Hedge End Rangers B">Hedge End Rangers B</OPTION><OPTION value="Hillcrest Red">Hillcrest Red</OPTION><OPTION value="Hiltingbury Blue">Hiltingbury Blue</OPTION><OPTION value="Hythe Strikers">Hythe Strikers</OPTION><OPTION value="Hythe Strikers B">Hythe Strikers B</OPTION><OPTION value="Hythe Strikers Spitfires">Hythe Strikers Spitfires</OPTION><OPTION value="Ice Sports">Ice Sports</OPTION><OPTION value="Itchen Royals">Itchen Royals</OPTION><OPTION value="Jewson Jfc">Jewson Jfc</OPTION><OPTION value="Langley Manor Blue">Langley Manor Blue</OPTION><OPTION value="Littleton Leopards">Littleton Leopards</OPTION><OPTION
        value="M & T Hawks">M & T Hawks</OPTION><OPTION value="Marchwood Rangers">Marchwood Rangers</OPTION><OPTION value="Oakwood Colts">Oakwood Colts</OPTION><OPTION value="Pace Pumas">Pace Pumas</OPTION><OPTION value="Sarisbury Sparks">Sarisbury Sparks</OPTION><OPTION value="St Francis Rovers">St Francis Rovers</OPTION><OPTION value="Stoneham Rangers">Stoneham Rangers</OPTION><OPTION value="Tadburn">Tadburn</OPTION><OPTION value="Tadburn Panthers">Tadburn Panthers</OPTION><OPTION
        value="Testwood Dragoons">Testwood Dragoons</OPTION><OPTION value="Testwood Lancers">Testwood Lancers </OPTION><OPTION value="Testwood United">Testwood United</OPTION><OPTION value="Townhill Emperors">Townhill Emperors</OPTION><OPTION value="Warsash Wasps Blue">Warsash Wasps Blue</OPTION><OPTION value="Warsash Wasps">Warsash Wasps</OPTION><OPTION value="West Totton Wanderers">West Totton Wanderers</OPTION><OPTION value="Winsoor Sports">Winsor Sports</OPTION><OPTION
        value="Wyvern Blue">Wyvern Blue</OPTION><OPTION value="Wyvern Youth">Wyvern Youth </OPTION></SELECT>
    </TD>
    <TR>
    <TD align=right>Away Score :</TD>
<td><input name='awayscore'
            value="<?php echo $awayscore ?>"
            size='3' maxlength='3'></td>
        </tr>
<TR>
    <TD align=right>Match Type :</TD>
<td><input name='matchtype'
            value="<?php echo $matchtype ?>"
            size='10' maxlength='10'></td>
        </tr>
    </TABLE>
</FORM>
</FONT></FONT></BODY></HTML>[/code]

Thanks.

Rgds,
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.