注意:未定义的变量:查询如何解决这个问题 [英] Notice: undefined variable: query how to fix this

查看:97
本文介绍了注意:未定义的变量:查询如何解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:未定义的变量:第87行的C:\ xampp \ htdocs \Project \ EBY.php中的查询

ErrorINSERT INTO birth(Date,Celeb,Venue,STime,ETime ,嘉宾,年龄,性别,主题,信,电子邮件,第一,最后,联系)价值观('','','','',','','','','','', '','','','')你的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以便在'','','','','','','','','','''''附近使用正确的语法2



Notice: Undefined variable: query in C:\xampp\htdocs\Project\EBY.php on line 87
ErrorINSERT INTO birth(Date, Celeb,Venue,STime,ETime,Guest,Age,Gender,Theme,Letter,Email,First,Last,Contact) VALUES('','','','',','','','','','','','','','')You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '','','','','','','','','','')' at line 2

<?php
$servername = "localhost";
	$username = "root";
	$password = "";
	
    $Date = $_POST['Date'];
	$nc = $_POST['nc'];
	$ven = $_POST['ven'];
	$STime  = $_POST['STime'];
	$ETime = $_POST['ETime'];
	$Gue = $_POST['Gue']; 
	$Gen= $_POST['Gen'];
	$Letter = $_POST['Letter'];
	$Theme = $_POST['Theme'];
    $fir = $_POST['first'];
	$las = $_POST['last'];
	$con = $_POST['con'];
	$email = $_POST['Email'];
	$age = $_POST['Age'];
	
$dbname = "dcprog";
	
	$conn = new mysqli($servername, $username, $password, $dbname);
	
	if($conn -> connect_error){
		
		echo("Connection Failed" . $conn -> connect_error);
	}
	$sql = "INSERT INTO birth(Date, Celeb,Venue,STime,ETime,Guest,Age,Gender,Theme,Letter,Email,First,Last,Contact)   
	VALUES('$Date','$nc','$ven','$STime','$ETime,'$Gue','$age','$Gen','$Theme','$Letter','$email','$fir','$las','$con')"; 
if($conn -> query($sql) === TRUE) {	
	
	if($Gue < 50)
	{

echo"<table align="center" width="700" cellspacing="5" cellpadding="5"><tbody><tr><td><center><h2>Reciept</h2></center></td></tr></tbody></table><hr>";	
echo"<table align="center" width="450" cellspacing="5" cellpadding="5"><tbody><tr><td><center> ";

echo"</center></td></tr></tbody></table><hr>";
echo"<width = 550 cellspacing = 5 cellpadding =5><table align="center" width="550" cellspacing="5" cellpadding="5"><tbody><tr><td>";
echo"</td></tr><tr><td>Day of the Event:</td><td>". $Date;
echo"</td></tr><tr><td>Name of the Celebrant:</td><td>" . $nc;
echo"</td></tr><tr><td>Venue:</td><td>" . $ven;
echo"</td></tr><tr><td>Starting Time of the Venue:</td><td>". $STime ;
echo"</td></tr><tr><td>Ending Time of the Venue:</td><td>". $ETime ;
	}
	if($Gue < 50)
	{
	$pack = 10000;
	$inclu = "Catering, Invitation letters and Location of the Party of the Party";	
	$them = 2000;
		echo"</td></tr><tr><td>Invited Guest:</td><td>". $Gue;
	}
	else if($Gue < 75 )
	{
	$pack = 12000;
	$them = 2000;
	$inclu = "Catering, Invitation letters, Location of the Party of the Party and Band";
		echo"</td></tr><tr><td>Invited Guest:</td><td>" . $Gue;
	}
	else if($Gue < 100)
	{
	$pack = 20000;
	$them = 2000;
	$inclu = "Unli-Catering, Invitation letters, Location of the Party of the Party and Band";	
	}
	else if( $Gue < 150)
	{
	$pack = 22000;
	$them = 2000;
	$inclu = "Unli-Catering, Invitation letters, Location of the Party of the Party, Host and Band";	
		echo"</td></tr><tr><td>Invited Guest:</td><td>" . $Gue;
	}
echo"</td></tr><tr><td>Theme:</td><td>". $evt;
echo"</td></tr><tr><td>Cake Price:</td><td>". $them ."pesos";
echo"</td></tr><tr><td>Wish to create Invitation:</td><td>". $Letter;
echo"</td></tr><tr><td>Package:</td><td>". $pack ."pesos";
echo"</td></tr><tr><td>Includes:</td><td>". $inclu;

$t = $pack + $them;
echo"</td></tr><tr><td>Total Payment :</td><td>". $t . "pesos";	
echo"</td></tr><tr><td>Thank You ". $las ." ". $fir . "We will contact at this No. ". $con . " Or with this email " . $email;
echo"</td></tr><tr><td>For any changes or Questions please contact us 091271304852 or email us Schoolfiles11@gmail.com";
echo"</td></tr></tbody></table>";	
	}
else {
		echo "Error".$query.$sql. $conn -> error;
	
	}
	$conn -> close();
	
	?>





我尝试了什么:



我不知道该做什么我已经尝试更改数据库但它没有工作



What I have tried:

I dunno what to do I already try to change the db but it didnt work

推荐答案

servername = localhost;
servername = "localhost";


用户名 = ;
username = "root";


密码 = ;

password = "";


这篇关于注意:未定义的变量:查询如何解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆