【问题标题】:I keep getting an error in in MySQL syntax [closed]我不断收到 MySQL 语法错误 [关闭]
【发布时间】:2012-10-09 14:51:12
【问题描述】:
  • 服务器:通过 UNIX 套接字的本地主机
  • 服务器版本:5.5.23-55
  • 协议版本:10
  • MySQL 字符集:UTF-8 Unicode (utf8)
  • cpsrvd 11.32.4.13
  • MySQL 客户端版本:5.5.23

嗨, 我不断收到 MySql 错误。这是错误:

Error

SQL query:

# LedAds 2.x SQL Def file
# http://www.ledscripts.com/
# Do NOT try to dump this straight in
# If you must do dump this in yourself, then replace all of the
# {prefix} with whatever prefix you decided on when configuring everything
# Host: localhost
# Generation Time: Feb 11, 2002 at 08:32 PM
# Server version: 3.23.42
# Database : `pla`
# --------------------------------------------------------
#
# Table structure for table `pla_ads`
#
 CREATETABLE {prefix}_ads(

aid int( 10)unsigned NOTNULLAUTO_INCREMENT ,
 TYPE enum('image','rich')NOTNULL default'image',
did int( 10)unsigned NOTNULL default'0',
active enum('yes','no')NOTNULL default'yes',
datetime datetime NOTNULL default'0000-00-00 00:00:00',
 PRIMARYKEY ( aid ) 
) TYPE=MYISAM ;



MySQL said: 
#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 '{prefix}_ads (
   aid int(10) unsigned NOT NULL auto_increment,
   type enum('im' at line 18 

这是我的代码:

#

CREATE TABLE {prefix}_ads (
  aid int(10) unsigned NOT NULL auto_increment,
  type enum('image','rich') NOT NULL default 'image',
  did int(10) unsigned NOT NULL default '0',
  active enum('yes','no') NOT NULL default 'yes',
  datetime datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (aid)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `pla_images`
#

CREATE TABLE {prefix}_images (
  did int(10) unsigned NOT NULL auto_increment,
  image_url varchar(255) NOT NULL default '',
  url varchar(255) NOT NULL default '',
  alt_text varchar(150) NOT NULL default '',
  target varchar(20) NOT NULL default '',
  width int(11) NOT NULL default '0',
  height int(11) NOT NULL default '0',
  PRIMARY KEY  (did)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `pla_impressions`
#

CREATE TABLE {prefix}_impressions (
  aid int(10) unsigned NOT NULL default '0',
  impdate date NOT NULL default '0000-00-00',
  displays bigint(20) unsigned NOT NULL default '0',
  clicks int(11) NOT NULL default '0',
  PRIMARY KEY  (aid,impdate)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `pla_richtext`
#

CREATE TABLE {prefix}_richtext (
  did int(10) unsigned NOT NULL auto_increment,
  data mediumtext NOT NULL,
  PRIMARY KEY  (did)
) TYPE=MyISAM;

我确实将 TYPE 更改为 ENGINE,但仍然看到错误...

请帮忙!

【问题讨论】:

  • 您是否尝试按原样执行这些查询,意味着 {prefix} 是否曾经被实际前缀替换?我假设您可能在某个阶段想要用实际前缀替换它。
  • 答案在脚本顶部的评论部分。
  • # 如果您必须自己转储此文件,请将所有 # {prefix} 替换为您在配置所有内容时决定的任何前缀
  • 这可能会有所帮助:stackoverflow.com/questions/12769982/…

标签: php mysql sql syntax


【解决方案1】:

此 SQL 脚本应由将 {prefix} 更改为有效前缀名称的 PHP 脚本运行

简而言之:{prefix} 无效,它应该是你的前缀没有{}

【讨论】:

  • 谢谢!现在我遇到了另一个问题:致命错误:不在 /home/mu/public_html/ledads/common.inc.php(168) 的对象上下文中使用 $this:第 2 行运行时创建的函数
  • 那是另一回事。另一个问题,另一个问题。如果他们解决了这个问题并提出另一个问题,请考虑接受其中一个答案
  • 我希望我知道如何接受。怎么样?
【解决方案2】:

# 不要试图直接将其转储

#如果你必须自己转储这个,那么替换所有的

# {prefix} 使用您在配置所有内容时决定的任何前缀

【讨论】:

  • 感谢它的工作......现在我有另一个问题:
【解决方案3】:

您的 {prefix} 没有定义,因此 MySQL 不知道它的值是什么 -> 会产生错误。

出于测试目的,将“{prefix}”的所有条目替换为“my_prefix”即可。

【讨论】:

  • 现在开始工作了.. 如果我阅读它会有所帮助.. :(
猜你喜欢
  • 2020-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2013-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多