I have this SQL error while inserting data into one of my tables, I’m using php to insert it, could someone please tell me whats wrong with this is it because I am repeating a variable name of ID or something?
Errornumber 1064: “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 ‘PlayerPositionID` ,
[code=php]
$query = “CREATE TABLE `”.$DBprefix.”playerpositions` (
`PlayerPositionID` tinyint(1) unsigned NOT NULL default ‘0’,
`PlayerPositionName` varchar(64) NOT NULL default ”,
PRIMARY KEY (PlayerPositionID)
) TYPE=MyISAM;”;
$result = mysql_query($query);
// check it it was succesfull
if ($result == 1)
{
$resultReturner .= “<tr><th>Creation of playerpositions table</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Creation of playerpositions table</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;
}
// check if there isn’t any data in the table.
$query3 = “Select * from “.$DBprefix.”playerpositions where PlayerPositionsID=’1′”;
$result3 = mysql_query($query3);
if ($row3 = mysql_fetch_array($result3)){
$resultReturner .= “<tr><th>Creation of playerpositions table</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Admin account already exists</td></tr>”;
}else{
// create the matchplace home and away
$query2 = “INSERT INTO `”.$DBprefix.”playerpositions` (`PlayerPositionID` , `PlayerPositionName`) VALUES (‘1’, ‘GoalKeeper’)”;
$result2 = mysql_query($query2);
// check it it was succesfull
if ($result2 == 1){
$resultReturner .= “<tr><th>Insertion of 1 GoalKeeper</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 1 GoalKeeper</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query4 = “INSERT INTO `”.$DBprefix.”playerpositions` (“PlayerPositionID` , `PlayerPositionName`) VALUES (‘2’, ‘Defender’)”;
$result4 = mysql_query($query4);
// check it it was succesfull
if ($result4 == 1){
$resultReturner .= “<tr><th>Insertion of 2 Defender</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 2 Defender</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query5 = “INSERT INTO `”.$DBprefix.”playerpositions` (`PlayerPositionID` , `PlayerPositionName`) VALUES (‘3’, ‘Midfielder’)”;
$result5 = mysql_query($query5);
// check it it was succesfull
if ($result5 == 1){
$resultReturner .= “<tr><th>Insertion of 1 Midfielder</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 1 Midfielder</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query6 = “INSERT INTO `”.$DBprefix.”playerpositions` (“PlayerPositionID` , `PlayerPositionName`) VALUES (‘4’, ‘Forward’)”;
$result6 = mysql_query($query6);
// check it it was succesfull
if ($result6 == 1){
$resultReturner .= “<tr><th>Insertion of 4 Forward</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 4 Forward</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query7 = “INSERT INTO `”.$DBprefix.”playerpositions` (`PlayerPositionID` , `PlayerPositionName`) VALUES (‘5’, ‘Committee’)”;
$result7 = mysql_query($query7);
// check it it was succesfull
if ($result7 == 1){
$resultReturner .= “<tr><th>Insertion of 5 Committee</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 5 Committee</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query8 = “INSERT INTO `”.$DBprefix.”playerpositions` (“PlayerPositionID` , `PlayerPositionName`) VALUES (‘6’, ‘Manager’)”;
$result8 = mysql_query($query8);
// check it it was succesfull
if ($result8 == 1){
$resultReturner .= “<tr><th>Insertion of 6 Manager</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 6 Manager</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query9 = “INSERT INTO `”.$DBprefix.”playerpositions` (`PlayerPositionID` , `PlayerPositionName`) VALUES (‘7’, ‘Supporter’)”;
$result9 = mysql_query($query9);
// check it it was succesfull
if ($result9 == 1){
$resultReturner .= “<tr><th>Insertion of 7 Supporter</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 7 Supporter</th><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
// create the matchplace home and away
$query10 = “INSERT INTO `”.$DBprefix.”playerpositions` (“PlayerPositionID` , `PlayerPositionName`) VALUES (‘8’, ‘Old Boy’)”;
$result10 = mysql_query($query10);
// check it it was succesfull
if ($result10 == 1){
$resultReturner .= “<tr><th>Insertion of 8 Old Boy</th><td><img src=”../assets/images/icon_ok.gif” height=”16″ width=”16″ title=”SUCCESSFUL” /></td></tr>”;
}else{
// if it wasn’t succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= “<tr><th>Insertion of 8 Old Boy</th><td><img src=”../assets/images/icon_cancel.gif” height=”16″ width=”16″ title=”ERROR” /></td><td>Errornumber “. mysql_errno() .”: “”. mysql_error() .””</td></tr>”;}
}