douzong5835 2012-07-25 14:00 采纳率: 100%
浏览 40
已采纳

从测试服务器移动到实时服务器时PHP和mysql错误

I am experiencing a strange problem. I have a simply web from with some validation rules which I have been running on my pc for a few weeks which updates a database. It has all be running fine during the testing phase running on localhost

I have since moved the web form and database to my server and when entering data which should and is accepted on my local machine I get the following error

Error : You are attempting to enter information which cannot be stored or contains code. Please refesh the from and try again Incorrect integer value: 'NULL' for column 'entryID' at row 1

Here is the basic code for the form processing

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>"; 
}
?>

Where am I going wrong?

  • 写回答

2条回答 默认 最新

  • dongtao4319 2012-07-25 14:30
    关注

    Try removing single quote around NULL.

    I think you have auto-increment option set for 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."' )";
    

    or try '' instead of NULL itself

    $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."' )";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 定制ai直播实时换脸软件
  • ¥100 栈回溯相关,模块加载后KiExceptionDispatch无法正常回溯了
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding
  • ¥15 Marscode IDE 如何预览新建的 HTML 文件
  • ¥15 K8S部署二进制集群过程中calico一直报错
  • ¥15 java python或者任何一种编程语言复刻一个网页
  • ¥20 如何通过代码传输视频到亚马逊平台
  • ¥15 php查询mysql数据库并显示至下拉列表中