0
我看到我的腳本沒有錯,我不明白爲什麼它不會插入到我創建的數據庫中。請看看我的代碼,並告訴可能是錯的。 這是它被用於所有的數據庫連接插入查詢未插入數據庫
<?php
$host="localhost";
$user="root";
$password="";
$db="cottonboard";
$tablename="user";
mysql_connect($host,$user,$password) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
?>
這是現在是將輸入插入到數據庫腳本中dbcon.php,
<?php
include "dbcon.php";
extract($_POST);
/* just to test if all fields will be outputted
print_r($_POST);*/
$sql="INSERT INTO $tablename(id,username,password,accesslevel,sex,contactnmuber,employer)
VALUES('null','$usernameuser','$passworduser','$accesslevel','$gender','$contactnumberuser','$employeruser')" or die(mysql_error());
if($sql)
{
echo"we got here safe";
}
?>
那麼你在哪裏執行查詢?注意:避免使用'mysql_'函數,它們已被棄用 –
您正在'$ sql'中創建一個查詢,但您從未真正執行它。 – 2013-10-21 10:03:55
加入 mysql_query($ sql);問題已經解決了。謝謝 – Inventor