我遇到一个奇怪的问题。我有一个简单的网页,里面有一些验证规则,我已经在电脑上运行了几个星期,可以更新数据库。在localhost 上运行的测试阶段,一切都运行良好
此后,我将web表单和数据库移到了我的服务器上,当输入应该在本地机器上接受的数据时,我得到了以下错误
错误:您试图输入无法存储或包含代码的信息。请重新刷新来自的,然后重试整数值不正确:第1行的列"entryID"为"NULL"
这是表单处理的基本代码
mysql_connect ("host", "username" , "password") or die ('Error: ' .mysql_error());
mysql_select_db ("name of database");
$query= "INSERT INTO entry (entryID, studentName , tutorName , procedureName , grade , studentReflection , tutorComments, professionalism , communication , alert , dispute ) VALUES ('NULL', '".$options1."' , '".$options2." ' , '".$procedure."' , '".$grade."' , '".$studentReflection."', '".$tutorComments."' , '".$professionalism."' , '".$communication."' , '".$alert."' , '".$dispute."' )";
mysql_query($query) or die ('Error : You are attempting to enter information which cannot be stored or contains code. Please refesh the from and try again<br>' .mysql_error());
echo "<h3>The database has been updated.</br> Thank You </br><a href='form.php'>Enter another procedure</h3>";
}
?>
我哪里错了?
尝试删除NULL
周围的单引号。
我想你已经为entryID
设置了自动递增选项
$query= "INSERT INTO entry (entryID, studentName , tutorName , procedureName , grade , studentReflection , tutorComments, professionalism , communication , alert , dispute ) VALUES (NULL, '".$options1."' , '".$options2." ' , '".$procedure."' , '".$grade."' , '".$studentReflection."', '".$tutorComments."' , '".$professionalism."' , '".$communication."' , '".$alert."' , '".$dispute."' )";
或者尝试''
而不是NULL
本身
$query= "INSERT INTO entry (entryID, studentName , tutorName , procedureName , grade , studentReflection , tutorComments, professionalism , communication , alert , dispute ) VALUES ('', '".$options1."' , '".$options2." ' , '".$procedure."' , '".$grade."' , '".$studentReflection."', '".$tutorComments."' , '".$professionalism."' , '".$communication."' , '".$alert."' , '".$dispute."' )";
我想entryID是一个自动递增字段吗?如果是,请将其从查询中删除。