博文';t在php中插入值
你好!我试图将一些数据保存到我的数据库中,但它不会工作,但不会显示任何类型的错误。请告诉我我做错了什么。我试图找出错误,但我认为另一双眼睛和大脑真的可以帮我。谢谢!:) 这是我的密码博文';t在php中插入值,php,html,Php,Html,你好!我试图将一些数据保存到我的数据库中,但它不会工作,但不会显示任何类型的错误。请告诉我我做错了什么。我试图找出错误,但我认为另一双眼睛和大脑真的可以帮我。谢谢!:) 这是我的密码 <?php $user_name = "root"; $password = ""; $database = "db_tocode"; $server = "127.0.0.1"; $content = "content_temp1"; $uname = $_GET['username'];
<?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);
}
?>
执行您的查询:
$query = mysql_query($sql);
并且您正在使用localhost,因此您的服务器名称将
$server = "localhost";
并使用
mysqli
而不是mysql
危险:您正在使用并且应该使用。您还容易受到以下问题的影响:一个现代API会使您从.echo$sql更轻松,并在phpmyadmin中手动触发该查询,然后检查是否存在任何查询errors@krishna-表名为content\u temp1
$
表示PHP中变量的开头。@krishna-否。PHP双引号字符串插入变量。删除和删除文本以及添加一堆串联运算符只会造成混乱。@krishna-您似乎不知道PHP字符串中的变量插值。我建议你阅读手册中关于的章节。非常感谢。哈哈。我早就知道了!谢谢你的帮助!!