AndorNot 发表于 2019-4-13 16:52:40

大神能否帮我看看为什么创建不了库,PHP

<?php
    header("content-type:text/html;charset=utf-8");

    $serverip = $_POST['host'];
    $sqluser = $_POST['sqluser'];
    $sqlpwd = $_POST['sqlpwd'];
    if($_POST['engine']){
      $engine = 'MyIsam';
    }else{
      $engine = 'InnoDB';
    }
    $conn = mysql_connect($serverip,$sqluser,$sqlpwd) or die('不能连接到数据库!');
   
    $database = $_POST['dbname'];
    mysql_select_db($database,$conn) or mysql_query("CREATE DATABASE '$database'",$conn);

    mysql_query('set names gbk');

    $admins = "create table Administrators(
      Username varchar(20) not null primary key,
      Password varchar(20) not null,
      Email varchar(30)
    )engine = '$engine';";

    $IDlenth = $_POST['IDlenth'];

    $users = "create table Users(
      UserID char(" + $IDlenth + ") not null primary key,
      Username varchar(20) not null,
      Password varchar(20) not null,
      Email varchar(30)
    )engine = '$engine';";

    mysql_query($admins,$conn);
    mysql_query($users,$conn);

    $adminuser = $_POST['adminuser'];
    $adminpwd = $_POST['adminpwd'];
    $adminmaill = $_POST['adminmaill'];
    mysql_query("insert into Administrators value(\"'$adminuser'\",\"'$adminpwd'\",\"'$adminmaill'\")",$conn);
?>

AndorNot 发表于 2019-4-13 16:54:44

我通过form提交得到的值,然后我自己也加了echo语句输出,都是正常的,跳转页面也没有报错,就是没有库。
页: [1]
查看完整版本: 大神能否帮我看看为什么创建不了库,PHP