Welcome connect succeed!Warning: mssql_query() [function.mssql-query]: message: 第 1 行: '`' 附近有语法错误。 (severity 15) in C:\Inetpub\wwwroot\1.php on line 27Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\wwwroot\1.php on line 27 error!
create table {$_GET['tablename']}
...
SQL;
(
id int,
name varchar(12) not null)
if(mssql_query($sql,$link))
echo "表".$table_name."创建成功";
else echo"数据库错误".$table_name;(这样对吗?
heredoc 句法结构:<<<。在该运算符之后要提供一个标识符,然后换行。接下来是字符串本身,最后要用前面定义的标识符作为结束标志。<?php
$content = <<<FDIPZONE
<html>
<head>
<title>test</title>
</head>
<body>
<p><img src="http://www.csdn.net/css/logo.png"></p>
<p><a href='http://blog.csdn.net/fdipzone'>blog</a></p>
</body>
</html>
FDIPZONE;
echo $content;
?>
參考:http://blog.csdn.net/fdipzone/article/details/24937669
$sql =<<<SQL
CREATE TABLE `{$_GET['tablename']}` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`age` tinyint(4) unsigned NOT NULL,
`addtime` datetime NOT NULL,
PRIMARY KEY (`id`)
)
SQL;mysql_query($sql) or die(mysql_error());
<html><?phpecho "Welcome" . "<br />";
$connect = mssql_connect("xxx","xxx","");
if(!$connect){
die('Could not connect: ' . mysql_error());
}
else {
echo "connect succeed!" . "<br />";
}mssql_select_db("Northwind",$connect);$sql =<<<SQL
CREATE TABLE '{$_GET['table_name1']}'
(
`id` int(10),
`name` varchar(100) NOT NULL,
`age` int(4) NOT NULL,
)
SQL;
if(mssql_query($sql,$connect))
echo "good";
else echo "error";?>
</html>现在说我Query failed in C:\Inetpub\wwwroot\1.php on line 26
请帮助!!!
CREATE TABLE '{$_GET['table_name1']}' 人家让你用反撇号,你却要用正撇号
出了错,怪谁呢?
connect succeed!Warning: mssql_query() [function.mssql-query]: message: 第 1 行: '`' 附近有语法错误。 (severity 15) in C:\Inetpub\wwwroot\1.php on line 27Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\wwwroot\1.php on line 27
error!