下面的代碼沒有任何錯誤運行,雖然它沒有任何東西插入到我的數據庫:插入進不插入
<?php
$con=mysqli_connect("localhost","root","","teachme");
//check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//add details in database
if (isset($_POST['user']) and isset($_POST['pass']) and isset($_POST['division'])) {
$user = mysql_real_escape_string($_POST['user']);
$pass = mysql_real_escape_string($_POST['pass']);
$division = mysql_real_escape_string($_POST['division']);
mysqli_query($con,"INSERT INTO users (username, password, division, id)
VALUES ($user, $pass, $division)");
echo 'Succesfully added entries onto the database.. ';
echo $user;
echo $pass;
echo $division;
echo '<a href="../">Return to homepage</a>';
}
else {
echo "An error occured, try again!";
}
?>
所有的變量都正確傳輸,這就是爲什麼我用上面的echo語句。 我是新來的,我知道這肯定是一個非常愚蠢的問題。
你確定查詢甚至可以運行嗎?你確定錯誤報告是和? – 2013-03-27 23:50:51
已啓用。嘗試所有建議後,數據庫仍爲空。 – Tom 2013-03-28 00:03:03
粘貼回顯的查詢。 – zad 2013-03-28 00:04:20