你能告诉我我的代码发生了什么变化吗? 它显示错误
解析错误:语法错误,第12行的C:\ xampp \ htdocs \ xampp \ dhiraj \ queryverify.php中的意外T_STRING
这是我的代码
<head>
<style>
#margin_left{margin-left:400px;
height:400px;}
#spanning{margin-left:70px;}
#spanning_gender{margin-left:66px;}
#spanning_marstatus{margin-left:27px;}
#spanning_city{margin-left:82px;}
#spanning_country{margin-left:62px;}
#spanning_religion{margin-left:63px;}
#spanning_crime{margin-left:74px;}
#spanning_crimetype{margin-left:39px;}
#table{border:thick;border-color:#09F;}
#insert{margin-left:140px;}
#foot{
background:none;}
</style>
</head>
<body>
<?php
include('database.php');
include('commonheader.php');
?>
<form method="get" name="queries" action="queryverify.php">
<h3 align="center"><font face="Tahoma, Geneva, sans-serif" color="#6C6">Queries</font></h3>
<div id="margin_left"><table id="table" border="1"cellpadding="10">
<tr>
<td>
Name: <span id="spanning"><input type="text" name="name" size="30"></span><br/>
Gender:<span id="spanning_gender"><select id="gender" size="1"><option value="r">male</option><option value="m">female</option></select></span><br/>
Marital Status:<span id="spanning_marstatus"><select size="1" id="marstatus"><option value="f">Married</option><option value="g">Unmarried</option><option value="h">Unknown</option></select></span><br/>
City: <span id="spanning_city"><input type="text" name="city" size="30"></span><br/>
Country:<span id="spanning_country"><input type="text" name="country" size="30"></span><br/>
Religion:<span id="spanning_religion"><input type="text" name="religion" size="30"></span><br/>
Crime:<span id="spanning_crime"><select id="crime" size="1"><option value="a">Murder</option></select></span><br/>
Crime Type:<span id="spanning_crimetype"><select id="crimetype" size="1"><option value="b">Half Murder</option></select></span>
</td>
</tr>
</table>
<div id="insert"><input type="submit" name="Insert" value="Insert"></div>
</div>
</form>
<?php include('footer.php');?>
<br />
<br/>
</body>
queryverify.php
<?php
$name = $_GET['name'];
$gender=$_GET['gender'];
$marstatus=$_GET['marstatus'];
$city=$_GET['city'];
$country=$_GET['country'];
$religion=$_GET['religion'];
$crime=$_GET['crime'];
$crimetype=$_GET['crimetype'];
include('database.php');
$query="insert into criminal(cid,name,gender,marital_status,religion,city,country,crime,crime_types) values(NULL,'".$name."','".$gender."','".marstatus."','".$religion."','".$city."','".$country."','".$crime."','".$crimetype."')";
mysql_query($query)or die mysql_error();
?>
答案 0 :(得分:2)
缺少$。如果您有PHP错误(可能是每个开发人员最常见的错误),也许以后您应该检查以下内容:
此外,我看到你得到不同的值,但不过滤它们,我建议你在将查询发送到数据库之前使用mysql_real_escape_string()
$name = mysql_real_escape_string($_GET['name']);
(只是一些建议)