Php 错误:您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法
错误如下所示: 注意:第32行C:\wamp\www\job.php中未定义的索引:JobID 第32行是:$JobID=$\u GET['JobID'] 我花了10天时间试图解决这个问题,阅读不同作者的不同书籍。但我仍然不知道我错在哪里Php 错误:您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法,php,mysql,phpmyadmin,get,localhost,Php,Mysql,Phpmyadmin,Get,Localhost,错误如下所示: 注意:第32行C:\wamp\www\job.php中未定义的索引:JobID 第32行是:$JobID=$\u GET['JobID'] 我花了10天时间试图解决这个问题,阅读不同作者的不同书籍。但我仍然不知道我错在哪里 <?php if(isset($_POST["submit"])) //this is form action { $result3 = mysql_query("SELECT * FROM members where user='$user'");
<?php
if(isset($_POST["submit"])) //this is form action
{
$result3 = mysql_query("SELECT * FROM members where user='$user'");
while($row3 = mysql_fetch_array($result3))
{
$name=$row3['name'];
$user=$row3['user'];
$number=$row3['number'];
}
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$sql="INSERT INTO applicant (user,name,number,) VALUES('$user','$name','$number')";
$result=mysql_query($sql);
if($result){
header('Location: thankyou2.php');
} else {
echo "Failure!";
}
}
}
else
{
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "abcdef";
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
$JobID=$_GET['JobID'];
$job_sql="SELECT * FROM job WHERE JobID=$JobID";
$job_query = mysql_query($job_sql) or die(mysql_error());
$rsjob=mysql_fetch_assoc($job_query);
};
?>
<b><center><table class="bordered">
//Data will fetch in this table by GET method
<thead>
<?php echo $rsjob['jobname'];?></h1></font>
<tr>
<th><font face="Script MT">Description</th>
<th><font face="Script MT">Details</th>
</tr>
</thead>
<tr>
<td>Name</td>
<td><?php echo $rsjob['jobname'];?></td>
</tr>
<tr>
<td>Type</a></td>
<td><?php echo $rsjob['type'];?></td>
</tr>
</table><br>
<?php
if ($loggedin)
{
echo
<<<_END
<form action="job.php" method="POST" name="jobapply">
<input type="checkbox" name="termscondition" required/> I have read all the
<a href="termscondition.html">Terms and Condition</a><br>
<br><input type="submit" value="Apply"></form>
_END;
}
else
{
echo '<center> please sign up and/or log in to <strong>Apply</strong>. </center>';
};
?>
使用
而不是
$JobID=$_GET['JobID'];
这很勇敢。您应该检查get参数JobID
是否已设置。如果没有,就不要删掉剩下的代码
除此之外:您应该将所有get参数设置为小写。混为一谈也可能是个问题
if(isset($_GET['jobid'])){
// your code her
}else{
// Show some error to the user or try to deal with the missing parameter
}
您是否在URI中添加了?JobID=1234?可能重复您将发布多少个处理相同问题的问题?尝试了解JobID='$JobID'
应解决查询错误并添加检查。您的代码有许多SQL注入漏洞,如果将此代码放到internet上,这些漏洞很可能被利用。您可以通过将包含数字的字符串强制转换为整数或使用mysql\u real\u escape\u string()
来解决此问题,但最好切换到支持参数化的数据库库。您当前使用的库现在已被弃用。您好,先生,我也是用小写字母写的。但是没有结果。请检查if(isset($\u GET['jobid']){//您的代码her}或者{//向用户显示一些错误或尝试处理缺少的参数}
$JobID=$_GET['JobID'];
if(isset($_GET['jobid'])){
// your code her
}else{
// Show some error to the user or try to deal with the missing parameter
}