I’m working on the website for a mmo-rpg game-based group, and I’m having trouble on the insert form for their ‘hitlist’; my code is as follows:
function check_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$Pri = check_input($_GET['Pri']);
$Pir = check_input($_GET['Pir']);
$Lvl = check_input($_GET['Lvl']);
$XCd = check_input($_GET['XCd']);
$YCd = check_input($_GET['YCd']);
$Nts = mysql_real_escape_string(check_input($_GET['Nts']));
$Opl = check_input($_GET['Opl']);
$Kwl = check_input($_GET['Kwl']);
$Ktl = check_input($_GET['Ktl']);
$Tty = mysql_real_escape_string(check_input($_GET['Tty']));
$Grp = check_input($_GET['Grp']);
$sql="INSERT INTO modattacklist (`Id`, `Priority`, `Pirate`, `Level`, `KnownFltLvl`, `XCoord`, `YCoord`, `Notes`, `BaseLevel`, `KnownWallLvl`, `KnownTurretLvl`, `TurretTypes`, `BasePicture`, `Group`)
VALUES ('','$Pri','$Pir','$Lvl','$XCd','$YCd','$Nts','$Opl','$Kwl','$Ktl','$Tty','Coming Soon.','$Grp')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error() . ' ' . $sql);
}
Yes, I’ve looked elsewhere, and yes, here is a printout of the query:
INSERT INTO modattacklist (`Id`, `Priority`, `Pirate`, `Level`, `KnownFltLvl`, `XCoord`, `YCoord`, `Notes`, `BaseLevel`, `KnownWallLvl`, `KnownTurretLvl`, `TurretTypes`, `BasePicture`, `Group`) VALUES ('','1','Eri','13','13751','408','?','?','?','?','?','Coming Soon.','Sector 23')
I really don’t understand what I’m doing wrong. The Id is auto-incremented, and this query works in phpMyAdmin
A new set of eyes would really be appreciated here.
You are only inserting 13 values, there are 14 columns. The ‘KnownFltLvl’ variable is missing.
If your table accepts nulls for this column, you can remove it from the INSERT all together.