请帮忙,提-6ren">
gpt4 book ai didi

php - 错误消息 : Premature end of script headers

转载 作者:搜寻专家 更新时间:2023-10-30 20:59:06 26 4
gpt4 key购买 nike

这是有效的,但突然间我收到了这条错误消息。 “错误信息:脚本头过早结束:cust.php"

<?php
//contact to database
$user = '';
$pass = '';
$db_name=""; // Database name
$tbl_name="cust"; // Table name

// Create a connection to the MySql server
$conn = mysql_connect('', $user, $pass);
mysql_select_db("$db_name")or die("cannot select DB");


//Get data in local variable
$v_Fname=$_POST['First_Name'];
$v_Lname=$_POST['Last_Name'];
$v_FAdd=$_POST['First_Add_Line'];
$v_postCode=$_POST['Postcode'];
$v_Num=$_POST['ContactNum'];
$v_Email=$_POST['Email'];


// check for null values
if ($v_Fname=="" or $v_Lname=="" or $v_FAdd=="" or $v_postCode=="" or $v_Num=="" or $v_Email=="")
echo "All fields must be entered, hit back button and re-enter information";
else{
$query="INSERT INTO $tbl_name(First_Name,Last_Name,First_Add_Line,Postcode,ContactNum,Email) values('$v_Fname','$v_Lname','$v_FAdd','$v_postCode','$v_Num','$v_Email')";
mysql_query($query) or die(mysql_error());
echo "You have registered as a Customer, Thank you";
echo "<BR>";
echo "<a href='index.html'>Back to main page</a>";
}

mysql_close();

?>

请帮忙,提前谢谢你:)

最佳答案

你试试这个

mysql_select_db("$db_name",$conn)or die("cannot select DB");

您还应该为每个发布变量使用 mysql_real_escape_string()

谢谢。

关于php - 错误消息 : Premature end of script headers ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10383711/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com