【问题标题】:Error: you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法使用
【发布时间】:2015-09-27 14:10:03
【问题描述】:

错误似乎是这样的:

注意:未定义索引:第 32 行 C:\wamp\www\job.php 中的 JobID 第 32 行是:$JobID=$_GET['JobID'];

我试图解决这个问题 10 天,阅读不同作者的不同书籍。但是我还是不知道哪里出错了。

<?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/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>';

};
?>

【问题讨论】:

标签: php mysql phpmyadmin get localhost


【解决方案1】:
$JobID=$_GET['JobID'];

这是勇敢的。您应该检查是否设置了 get-paramenter JobID。如果没有,请不要执行其余代码。

除此之外:您应该将所有获取参数设为小写。混合起来也可能是个问题。

if(isset($_GET['jobid'])){
  // your code her
}else{
  // Show some error to the user or try to deal with the missing parameter 
}

【讨论】:

    【解决方案2】:

    使用

    $JobID=$_GET['jobid'];
    

    而不是

    $JobID=$_GET['JobID'];
    

    【讨论】:

    • 您好先生,我也是用小写字母写的。但没有结果。
    • 请检查 if(isset($_GET['jobid'])){ // 你的代码她 }else{ // 向用户显示一些错误或尝试处理缺少的参数 }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-19
    • 2019-03-25
    相关资源
    最近更新 更多