创建数据表出错,错误号:1064 错误原因:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' varchar(255),LATITUDE varchar(255),DATE varchar(255),FREQUENCY ' at line 1。
我写的sql语句在数据库中使用可以建表,但是用mysql_query执行就报错了,
程序如下:
if($id==0){
// $str0表示创建数据表的语句,$str表示插入时数据表的字段
$str = "";
$str0 = "id int unsigned not null auto_increment primary key,";
$title = array();
$length = sizeof($v_1);
$length1 = $length-1;
for ($k=0; $k <$length ; $k++) {
$title[$k] = $v_1[$k];
if($k==$length1){
$str .=$title[$k];
$str0 .= $v_1[$k]." "."varchar(255)";
}else{
$str .=$title[$k].",";
$str0.=$v_1[$k]." "."varchar(255)".",";
}
}
$sqlTable="create table $tablename ($str0)";
echo $sqlTable;
$query=mysql_query($sqlTable);
if($query){
echo "数据表创建成功";
}else{
echo "创建数据表出错,错误号:".mysql_errno()." 错误原因:".mysql_error();
}
}
放狗过来
田心枫