我有這個php代碼,沒有錯誤引發,但數據沒有插入到表中,也沒有創建表,請問我可以告訴我哪裏出錯了?未上傳數據的php mysql錯誤
乾杯提前:)
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;
}
什麼錯誤你好嗎? –
IM沒有得到一個,說白了信息不被incerted到表中,表中沒有創建 – Nick
@Nicholas刪除圍着桌子'CREATE TABLE IF NOT EXISTS $電子郵件名稱的單引號...'[點擊此鏈接](http://sqlfiddle.com/#!2/06dfb)爲例。正如你所看到的查詢已成功構建。嘗試通過添加單引號離子tableName來修改它,它不會生成。 –