本文介绍了检查与您的MySQL服务器版本相对应的手册,以找到在第1行附近使用的正确语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?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', '$号');
$ result = mysql_query($ sql);
if($ result){
header('Location:thankyou2.php');
} else {
echoFailure!;
}
}
}
else
{
$ mysql_hostname =localhost;
$ mysql_user =root;
$ mysql_password =;
$ mysql_database =abcdef;
$ prefix =;
$ bd = mysql_connect($ mysql_hostname,$ mysql_user,$ mysql_password)或死(无法连接数据库);
mysql_select_db($ mysql_database,$ bd)或死(无法选择数据库);
$ JobID = $ _ GET ['JobID'];
$ job_sql =SELECT * FROM job WHERE JobID = $ JobID;
$ job_query = mysql_query($ job_sql)或死(mysql_error());
$ rsjob = mysql_fetch_assoc($ job_query);
};
?>
< b>< center>< table class =bordered>
(数据将通过GET方法在此表中获取)
< thead>
<?php echo $ rsjob ['jobname'];?>< / h1>< / font>
< tr>
< th>< font face =Script MT>描述< / th>
< th>< font face =Script MT>详情< / th>
< / tr>
< / thead>
< tr>
< td>名称< / td>
< td><?php echo $ rsjob ['jobname'];?>< / td>
< / tr>
< tr>
< td>类型< / a>< / td>
< td><?php echo $ rsjob ['type'];?>< / td>
< / tr>
< / table>< br>
if($ loggedin)
{
echo
< input type =checkboxname =termsconditionrequired />& nbsp;& nbsp;& nbsp;& nbsp;我已阅读所有
< a href =termscondition.html>条款和条件< / a>< br>
< br>< input type =submitvalue =Apply>< / form>
_END;
}
else
{
echo'< center>请注册并/或登录到< strong>应用< / strong>。< / center>';
};
?>
单击提交按钮时,用户信息将存储在abcdef数据库的申请表中。
错误:您的SQL语法有错误;检查对应于你的MySQL服务器版本的手册,在第一行使用正确的语法
$ sql =INSERT INTO'在列中有一个额外的逗号以及引号中的表名,申请人'(用户,姓名,号码)VALUES('$ user','$ name','$ number');
至此
$ sql =INSERT INTO申请人(用户,姓名,号码)VALUES('$ user','$ name','$ number');
我相信问题在这里(user,name,number) code>,这里
'申请者'
<?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>';
};
?>
On clicking submit button the user information get stored in applicant table in abcdef database.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 near '' at line 1
解决方案
You seem to have an extra comma in you columns and your table name in quotes, try changing this line:
$sql="INSERT INTO 'applicant' (user,name,number,) VALUES('$user','$name','$number')";
To this
$sql="INSERT INTO applicant (user,name,number) VALUES('$user','$name','$number')";
I believe the issue is here (user,name,number)
and here 'applicant'
这篇关于检查与您的MySQL服务器版本相对应的手册,以找到在第1行附近使用的正确语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!