SQL error

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Albino

Munky DesignsEstablished Member
Impact
17
ok hey

im usually ok at finding these, but this one has got me baffled!

Code:
<?php 	include "config.php";
 if(isset($_POST['submit']))
  {//begin of if($submit).
      // Set global variables to easier names
      $type = $_POST['type'];
	  $team = $_POST['team'];
	  $lineup1 = $_POST['lineup1'];
	  $lineup2 = $_POST['lineup2'];
	  $date = $_POST['date'];
	  $time = $_POST['time'];
	  $map = $_POST['map'];
	  $mom = $_POST['mom'];
	  $desc = $_POST['desc'];
	  $score = $_POST['score'];
	  $score_indiv = $_POST['score_indiv'];
	  $outcome = $_POST['outcome'];
	  
              //check if (title) field is empty then print error message.
              if(!$team){  //this means If the title is really empty.
                     echo "Error: Matches Need to be played against someone!";
                     exit(); //exit the script and don't do anything else.
              }// end of if

         //run the query which adds the data gathered from the form into the database
         $result = mysql_query("INSERT INTO matches (match_type, team, lineup1, lineup2, date, time, map, mom, desc, score, score_indiv, outcome)
		 VALUES ('$type', '$team', '$lineup1', '$lineup2', '$date', '$time', '$map', '$mom', '$desc', '$score', '$score_indiv', '$outcome')",$connect) or die(mysql_error());
          //print success message.
          echo "<b>Thank you! Match added Successfully!<br>You'll be redirected to Home Page after (4) Seconds";
          echo "<meta http-equiv=Refresh content=4;url=matches_edit.php>";
  }//end of if($submit).


  // If the form has not been submitted, display it!
else
  {//begin of else

      ?>
<html>
<head>
<title>B.O.M.|Barrel Of Munkys</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" style="text/css"
href="../bomstyle.css" />
</head>

<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class="title" colspan="2"><p><img src="../table/Banner2.jpg" width="700" height="150"></p>
      </td>
  </tr>
  <tr> 
    <td align="right" valign="top" class="menu"> 
      <? include("http://localhost/BOM/admin/adminlinks.htm") ?>
    </td>
	<td valign="top">
	
<table width="100%" cellpadding="0" cellspacing="0">
	    <tr> 
          <td height="66" valign="top" class="contenttop"><img src="../table/admin.gif" width="510" height="50"></td>
	</tr>
	    <tr> 
          <td height="33" valign="top" background="../table/main_mid.gif" class="mid">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
              <table width="357" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="95" height="31">Team: </td>
                  <td width="262"><input name="team" size="40" maxlength="255"></td>
                </tr>
                <tr> 
                  <td height="34">Type of Match: </td>
                  <td><select name="type">
                      <option value="ED">Enemy Down</option>
                      <option value="PCW">PCW</option>
                    </select></td>
                </tr>
				<tr> 
                  <td width="95" height="31">Date: </td>
                  <td width="262"><input name="date" size="40" maxlength="255"></td>
                </tr><tr> 
                  <td width="95" height="31">Time: </td>
                  <td width="262"><input name="time" size="40" maxlength="255"></td>
                </tr><tr> 
                  <td width="95" height="31">Map: </td>
                  <td width="262"><input name="map" size="40" maxlength="255"></td>
                </tr><tr> 
                  <td width="95" height="31">Man Of The Match: </td>
                  <td width="262"><input name="mom" size="40" maxlength="255"></td>
                </tr>
                <tr> 
                  <td valign="top">Description: </td>
                  <td><textarea name="desc" rows="7" cols="30"></textarea></td>
                </tr>
				<tr> 
                  <td width="95" height="31">Score: </td>
                  <td width="262"><input name="score" size="40" maxlength="255"></td>
                </tr>
				<tr> 
                  <td width="95" height="31">Idividual round scores: </td>
                  <td width="262"><input name="score_indiv" size="40" maxlength="255"></td>
                </tr>
				<tr> 
                  <td width="95" height="31">Outcome: </td>
                  <td width="262"><input name="outcome" size="40" maxlength="255"></td>
                </tr>
                <tr> 
                  <td colspan="2"><div align="center"> 
                      <input type="submit" name="submit" value="Add Match">
                    </div></td>
                </tr>
              </table>
</form>
          </td>
	</tr>
	<tr>
	    <td class="contentbottom"  valign="top"><img src="../table/main_bottom.gif" width="510" height="50"></td>
	</tr>
</table>
	
	</td>
  </tr>
</table>
</body>
</html>
<?
}
?>

Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, score, score_indiv, outcome) VALUES ('PCW', '{UK}', ''


if anyone can help fix the error, 30NP$ is available :D

cheers
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
your best bet would be to exho out the SQL so that you can see exactly what it looks like.
 
0
•••
im not sure what that means sorry, lol

in simpler terms, im still pretty new to php and mysql
 
0
•••
You have 'desc' as a field name. This is a no-no as it is a reserved word in SQL.

Try renaming the field to 'descrip' and alter your SQL accordingly.

-Bob
 
2
•••
once again you have come to my rescue moondog

Legend :D
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back