我有这个php代码,没有错误,但是没有将数据插入表中,也没有创建表,您能告诉我我要去哪里了吗?

提前加油:)

DB_Functions.php

private $db;

     // constructor
     function __construct() {
         require_once 'DB_Connect.php';
         // connecting to database
         $this->db = new DB_Connect();
         $this->db->connect();
     }

// destructor
function __destruct() {

}

 public function storeUnit($email, $units, $maint, $attent, $done) {
    $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error());
    mysql_select_db(DB_DATABASE, $con);

        $format = 'Y-m-d G:i:s';
        $date = date($format);
        $result = mysql_query("CREATE TABLE IF NOT EXISTS $email( Units VARCHAR(10), Finish VARCHAR(20), Attent VARCHAR(200), Maint VARCHAR(200), created_at VARCHAR(30))",$con);
        $result = mysql_query("INSERT INTO '$email'(Units, Finish, Attent, Maint, created_at) VALUES('$units', '$done', '$attent', '$maint', '$date')");
        return true;
}

最佳答案

尝试使用`代替'作为表名

$result = mysql_query("INSERT INTO `$email`(Units, Finish, Attent, Maint, created_at) VALUES('$units', '$done', '$attent', '$maint', '$date')");


编辑:尝试查看您的数据库是否使用InnoDB,则可以使用事务模式...因此,如果禁用了自动提交,则必须提交更改

10-05 22:47