美好的一天!我試圖將一些數據保存到我的數據庫中,但它不會工作,但不會顯示任何類型的錯誤。請告訴我我做錯了什麼。我試圖找到這個錯誤,但我認爲另一雙眼睛和大腦可以真正幫助我。謝謝! :)POST不會在php中插入值
這是我的代碼
<?php
$user_name = "root";
$password = "";
$database = "db_tocode";
$server = "127.0.0.1";
$content = "content_temp1";
$uname = $_GET['username'];
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
$header = $_POST['header'];
$title1 = $_POST['title1'];
$content1 = $_POST['content1'];
$title2 = $_POST['title2'];
$content2 = $_POST['content2'];
$title3 = $_POST['title3'];
$content3 = $_POST['content3'];
$title4 = $_POST['title4'];
$content4 = $_POST['content4'];
$title5 = $_POST['title5'];
$content5 = $_POST['content5'];
$title6 = $_POST['title6'];
$content6 = $_POST['content6'];
$title7 = $_POST['title7'];
$content7 = $_POST['content7'];
$title8 = $_POST['title8'];
$content8 = $_POST['content8'];
$title9 = $_POST['title9'];
$content9 = $_POST['content9'];
$title10 = $_POST['title10'];
$content10 = $_POST['content10'];
$content11 = $_POST['content11'];
if ($db_found) {
$SQL="INSERT INTO $content (user_uname, header, title1, content1, title2, content2, title3,content3,title4, content4, title5, content5, title6, content6, title7, content7, title8, content8, title9, content9, title10, content10, content11) VALUES('$uname', ' $header', '$title1', '$content1', '$title2', '$content2', '$title3', '$content3', '$title4', '$content4', '$title5', '$content5', '$title6', '$content6', '$title7', '$content7', '$title8', '$content8', '$title9', '$content9', '$title10', '$content10', '$content11')";
header('Location:1stTemplate/index.php');
}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}
?>
**危險**:您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068),並應使用[現代替換](http:// php。淨/手動/ EN/mysqlinfo.api.choosing.php)。你也**易受[SQL注入攻擊](http://bobby-tables.com/)**,現代的API會使[防禦]更容易(http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php)自己從。 – Quentin
echo $ sql並在phpmyadmin中手動觸發該查詢並檢查是否有任何錯誤 –
@krishna - 表名是'content_temp1'。 '$'表示PHP中變量的開始。 – Quentin