解析错误:语法错误,意外的T-STRING

时间:2013-12-07 02:30:47

标签: php mysql database

我正在尝试完成最后一个项目,但我遇到了错误。这是故事,我试图在mtsql php中创建一个带有表的数据库,当我尝试加载本地文件时,我收到以下错误消息:

解析错误:语法错误,第37行的C:\ xampp \ htdocs \ franchisecalllogdb.php中的意外“特许经营”(T_STRING)

第37行看起来很好,我真的想在这个项目上获得一个A,但我不相信我这样做。

这是我使用Notepad ++的代码

<?php
//connect to MySQL
include("inc_connect_local.php");
mysql_select_db("Franchise Call Log");
$caller_info = "CREATE TABLE caller_info (
caller_id int(11) unsigned auto_increment primary key not null,
first_name varchar(35) not null, 
Last_name varchar(35) not null, 
franchise varchar(25) not null)
";
$results = mysql_query($caller_info) or die (mysql_error());

//create "caller_call_record" table
$caller_call_record = "CREATE TABLE caller_call_record (
(call_record_id int(11) not null,
Call_Description varchar(50),
franchise_id int(10) not null,
Email varchar(40) not null, 
Username varchar(25) primary key not null)
";
$results = mysql_query($caller_escalation)
or die(mysql_error());

//create "caller_escalation" table
$caller_escalation = "CREATE TABLE caller_escalation (
call_escalation_id int(11) unsigned auto_increment not null, 
Second_Level varchar(5) not null, 
caller_id int(11) unsigned not null, 
PRIMARY KEY(call_escalation_id),
username varchar(25) not null,  
FOREIGN KEY(caller_id) 
REFERENCES caller_info(caller_id),
FOREIGN KEY (username) REFERENCES caller_call_record (username)
);
$results = mysql_query($caller_escalation)
or die(mysql_error());
echo "Franchise Call Log Database successfully created!";

2 个答案:

答案 0 :(得分:1)

试试这个: $ caller_escalation 之后缺少

<?php
//connect to MySQL
include("inc_connect_local.php");
mysql_select_db("Franchise Call Log");
$caller_info = "CREATE TABLE caller_info (
caller_id int(11) unsigned auto_increment primary key not null,
first_name varchar(35) not null, 
Last_name varchar(35) not null, 
franchise varchar(25) not null)
";
$results = mysql_query($caller_info) or die (mysql_error());

//create "caller_call_record" table
$caller_call_record = "CREATE TABLE caller_call_record (
(call_record_id int(11) not null,
Call_Description varchar(50),
franchise_id int(10) not null,
Email varchar(40) not null, 
Username varchar(25) primary key not null)
";
$results = mysql_query($caller_escalation)
or die(mysql_error());

//create "caller_escalation" table
$caller_escalation = "CREATE TABLE caller_escalation (
call_escalation_id int(11) unsigned auto_increment not null, 
Second_Level varchar(5) not null, 
caller_id int(11) unsigned not null, 
PRIMARY KEY(call_escalation_id),
username varchar(25) not null,  
FOREIGN KEY(caller_id) 
REFERENCES caller_info(caller_id),
FOREIGN KEY (username) REFERENCES caller_call_record (username)
)";
$results = mysql_query($caller_escalation)
or die(mysql_error());
echo "Franchise Call Log Database successfully created!";

答案 1 :(得分:1)

语法高亮显示了一切。你错过了一个引号:

REFERENCES caller_info(caller_id),
FOREIGN KEY (username) REFERENCES caller_call_record (username)
)"; // <-- here