标题:PHP建表请教错误
只看楼主
woa
Rank: 1
等 级:新手上路
帖 子:159
专家分:0
注 册:2008-12-4
结帖率:85.37%
 问题点数:0 回复次数:1 
PHP建表请教错误

<?php
$host="localhost";
$user="admin";
$password="abcde";
$db_name="info";
$table_name="User";
$conn=mysql_connect($host,$user,$password);
 if(!$conn)
{
  die ("".mysql_error());
}
  else
{
 echo "mysql host:$host,mysql user:$user<br>";
}

mysql_select_db($db_name,$conn) or
 die("select db error".mysql_error());
echo "db:$db_name table:$table_name<br>";

mysql_query("SET NAME'GB2312'");


$mysql_command="create table".$table_name."(name varchar(16),password(16))";


$result=mysql_query($mysql_command) or
      die("create table error".mysql_error());
echo "create table successed:$table_name";
?>
运行后,建表错误,可是看了半天也没发现语法哪错了,请教!!!
mysql host:localhost,mysql user:admin
db:info table:User
create table errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tableUserInfo(name varchar(16),password(16))' at line 1
搜索更多相关主题的帖子: PHP 
2010-05-06 09:02
Johnsylm
Rank: 2
等 级:论坛游民
威 望:4
帖 子:26
专家分:20
注 册:2008-12-12
得分:0 
$mysql_command="create table".$table_name."(name varchar(16),password(16))";
name 的类型是 varchar ,长度限制为 15 ,难道说是我孤陋寡闻尚未风闻最近出了个 “password”的新类型?就算是有这个新类型你的字段名写了吗 - - 。。。,
应该是 password varchar(16) 吧 - - 。。。
2010-08-01 18:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-305547-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.181354 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved