doutizha7526 2017-11-24 22:38
浏览 29
已采纳

使用PHP创建数据库时出错

I'm trying to create a database with a php file but I don't know why when i run it, it displays this error: "Error: CREATE TABLE contaclick ( id int(20) NOT NULL auto_increment, link varchar(255) NOT NULL default '', count int(20) NOT NULL default '0', PRIMARY KEY (id) ) TYPE=MyISAM;" Someone knows how to fix it?

my code in php is this:

<?
$login = "xxx";
$password = "xxx";
$database = "xxx";

$db = mysql_connect("xxx", $login, $password) or die ("Errore!");
mysql_select_db($database, $db);

$sql = "CREATE TABLE contaclick (
id int(20) NOT NULL auto_increment,
link varchar(255) NOT NULL default '',
count int(20) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM;";

@mysql_query($sql) or die("Errore: $sql");

$sql = "INSERT INTO contaclick VALUES('', 'https://www.mywebsite.com/', '0')";
@mysql_query($sql) or die("Errore: $sql");
?>
  • 写回答

1条回答 默认 最新

  • duangu4980 2017-11-24 22:48
    关注

    TYPE is deprecated, use ENGINE instead

    CREATE TABLE contaclick ( id int(20) NOT NULL auto_increment,
     link varchar(255) NOT NULL default '',
     count int(20) NOT NULL default '0', PRIMARY KEY (id) ) ENGINE = MyISAM
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?