/    Sign up×
Community /Pin to ProfileBookmark

Trouble inserting data into table some error?

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` , `PlayerPositionName`) VALUES (‘2’, ‘Defender’)’ at line 1″

[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>”;}
}
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 15.2006 — You have ` when you should only have around here:

[code=php]
s (PlayerPositionID
[/code]


Right before PlayerPositionID
Copy linkTweet thisAlerts:
@solidaritiauthorJan 15.2006 — Thanks Chazzy! Much appreciated.
×

Success!

Help @solidariti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...