我的Html文件
<!DOCTYPE html>
<html>
<head>
<script>
function myfun(){
var x,y,z;
x=document.input.name.value;
if((x=="")||(x==null))
{
alert("Please Enter Your Name");
document.input.name.focus();
return false;
}
y=document.input.hallticket.value;
if((y=="")||(y==null))
{
alert("Please Enter Your Hallticket");
document.input.hallticket.focus();
return false;
}
z=document.input.dob.value;
if((z=="")||(z==null))
{
alert("Please Enter Your Dob");
document.input.dob.focus();
return false;
}
}
</script>
<style>
h1{
text-align:center;
}
#header{
background-color:#985544;
}
#left{
background-color:#789564;
}
#center{
background-color:#888999;
}
#body{
background-image:url(bodyback.png);
}
#right{
background-color:#789564;
}
</style>
</head>
<body id="body" style=" no-repeat">
<div id="header" style="height:100px;width:100%">
</div>
<marquee>Welcome to CSE-A Website</marquee>
<div>
<div id="left" style="height:1000px;width:10%;float:left">
</div>
<div id="center" style="height:px;width:80%;float:left">
<h1>CSE-A</h1>
<p>Here you can check your details in this site :)</p>
<form name="input" action="data.php" id="searchform">
Name: <input type="text" name="name">
HallticketNo: <input type="text" name="hallticket">
Dob:<input type="date" name="dob">
<Input onclick="return myfun();" type="Submit" name="Submit" value="Search" id="n3"/>
</form>
</div>
<div id="right" style="height:1000px;width:10%;float:left">
</div>
</div>
</body>
</html>
我的Php文件:
<?php
$con=mysqli_connect("localhost","prabha","prabha","cvsr");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$_GET["hallticket"]'");
while($row = mysqli_fetch_array($result)) {
echo $row['name'] . " " . $row['hallticket'];
echo "<br>";
}
?>
当我提交表格时,它显示为此错误
解析错误:解析错误,期待
T_STRING' or
T_VARIABLE&#39;或者`T_NUM_STRING&#39;在C:\ wamp \ www \第8行的新文件夹\ data.php
其实我正在尝试检索名称,如果我通过检查hallticket动态提交价值,请告诉我有什么问题
答案 0 :(得分:1)
$hallticket = $_GET["hallticket"];
mysqli_real_escape_string($con,$hallticket);
$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$hallticket'");