首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP和mysql从测试服务器迁移到实时服务器时出现错误

PHP和mysql从测试服务器迁移到实时服务器时出现错误
EN

Stack Overflow用户
提问于 2012-07-25 22:00:42
回答 2查看 68关注 0票数 1

我遇到了一个奇怪的问题。我有一个简单的网络与一些验证规则,我已经在我的pc上运行了几个星期,它更新了一个数据库。在本地主机上运行的测试阶段,一切都运行得很好

此后,我将web表单和数据库移动到了我的服务器上,当输入本地计算机应该接受的数据时,我得到了以下错误

错误:您正在尝试输入无法存储或包含代码的信息。请重新调整from,然后重试不正确的整数值:第1行的列'entryID‘的'NULL’

下面是表单处理的基本代码

代码语言:javascript
复制
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>"; 
}
?>

我哪里错了?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-25 22:30:33

尝试删除NULL周围的单引号。

我认为您已经为entryID设置了自动增量选项

代码语言:javascript
复制
$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本身

代码语言:javascript
复制
$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."' )";
票数 2
EN

Stack Overflow用户

发布于 2012-07-25 22:14:59

我假设entryID是一个自动递增的字段?如果是,只需将其从查询中删除即可。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11651478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档