mysql中的保留名称 [英] Reserved name in mysql

查看:64
本文介绍了mysql中的保留名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SQL插入语句导致什么都没有添加到我的表中.我有与其他工作正常的表相似的语句,因此我的连接和数据库设置似乎工作正常.这是INSERT特有的问题.有人有什么想法吗?

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表结构:

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 ;

声明:

$mysqli = new mysqli(xxxxx, "rpnews", xxxxx, "rpnews");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", 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')");

推荐答案

Desc也是保留字,请使用反引号

Also Desc is a reserved word,use backticks

文档

这篇关于mysql中的保留名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆