问题描述
请有人帮助我验证此代码是否正确.我想在Pin列下的Pin表中基于Pin生成ID,并插入到appid列的Pin表中.我收到的错误是注意:第11行的C:\ xampp \ htdocs \ portal \ Compet_loginID.php中的appid:未定义索引:appid".这意味着找不到appid列,并且在那里.
Someone should please help me verify whether this code is right. I want to generate ID base on Pin from pin table under Pin column and insert into pin table in the appid column. The error I am receiving is "Notice: Undefined index: appid in C:\xampp\htdocs\portal\Compet_loginID.php on line 11". Which means appid column is not found and it is there.
$num = rand(98564654, 415231564);
If(isset($_POST['login'])){
$Pin='';
$ID =$_POST['appid'];
if($Pin=='Pin'){
$result = mysql_query("SELECT * FROM pin WHERE Pin == '$Pin'");
$test = mysql_fetch_array($result);
if (!$result)
mysql_query("UPDATE pin SET appid ='$num' WHERE Pin = '$Pin'")
or die(mysql_error());
header("location:compet_applicant.php");
我的表单以ID作为变量,并以登录按钮作为提交按钮,同时在顶部生成$num
并将其复制并粘贴到ID变量字段中.
My Form has ID as the variable and login as a submit button while a $num
is generated on top to be copied and pasted in the ID variable field.
推荐答案
只需尝试在字段名称中提供转义符(`)来编写类似这样的查询.
just try to write your query some thing like this with providing escape character ( ` ) to your field name.
mysql_query("UPDATE pin SET 'appid' ='$num' WHERE 'Pin' = '$Pin'");
这篇关于验证代码以更新查询表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!