My SQL insert statement is resulting in nothing being added to my table. I have similar statements to other tables that are working fine, so my connection and database setup seems to be working OK. It's something specific to the INSERT that is going wrong. Anyone have any ideas?
MySQL table structure:
CREATE TABLE `gallery_new` (
`GalleryID` INTEGER(11) NOT NULL,
`Status` MEDIUMTEXT COLLATE utf8_general_ci,
`Title` MEDIUMTEXT COLLATE utf8_general_ci,
`Desc` LONGTEXT COLLATE utf8_general_ci,
`Author` MEDIUMTEXT COLLATE utf8_general_ci,
`MCName` MEDIUMTEXT COLLATE utf8_general_ci,
`Role` MEDIUMTEXT COLLATE utf8_general_ci,
`ImageURL` MEDIUMTEXT COLLATE utf8_general_ci,
`ThumbURL` MEDIUMTEXT COLLATE utf8_general_ci,
`Timestamp` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`Date` TEXT COLLATE utf8_general_ci,
`PHPDate` MEDIUMTEXT COLLATE utf8_general_ci
)ENGINE=MyISAM
AUTO_INCREMENT=1 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
COMMENT='';
ALTER TABLE `gallery_new` ADD PRIMARY KEY USING BTREE (`GalleryID`);
ALTER TABLE `gallery_new` ADD UNIQUE INDEX `GalleryID_new` USING BTREE (`GalleryID`);
ALTER TABLE `gallery_new` MODIFY COLUMN `GalleryID` INTEGER(11) NOT NULL AUTO_INCREMENT ;
Statements:
$mysqli = new mysqli(xxxxx, "rpnews", xxxxx, "rpnews");
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
// GATHER INFO FOR THE DB INSERT
$date = date("F j, Y");
$phpdate = time();
$author = ucfirst($user->data['username_clean']);
$mcname = $user->profile_fields['pf_minecraftname'];
$title = $mysqli->real_escape_string($_POST['posttitle']);
$body = $mysqli->real_escape_string($_POST['postbody']);
if ($user->data['group_id'] == 4) { $role = 'Mod';}
elseif ($user->data['group_id'] == 5) { $role = 'Admin';}
else { $role = 'None';}
$mysqli->query("INSERT INTO gallery (Status, Title, Desc, Author, MCName, Role, ImageURL, ThumbURL, Date, PHPDate)
VALUES ('Live', '$title', '$body', '$author', '$mcname', '$role', '$path', '$paththumb', '$date', '$phpdate')");
Also Desc
is a reserved word,use backticks
Wrong table name? gallery
!= gallery_new