extjs4和php问题-创建条目时出现500内部服务器错误
我已经被这个问题困扰了一天了。我想我忽略了一些简单的事情,但我看不到 我正在开发一个web应用程序,用户在其中填写表单并将表单保存在数据库中。但是,在表单中插入值时遇到问题。数据库没有更新,我在控制台收到一个500内部服务器错误 这是当用户保存填写的表单时我调用的控制器extjs4和php问题-创建条目时出现500内部服务器错误,php,sql,Php,Sql,我已经被这个问题困扰了一天了。我想我忽略了一些简单的事情,但我看不到 我正在开发一个web应用程序,用户在其中填写表单并将表单保存在数据库中。但是,在表单中插入值时遇到问题。数据库没有更新,我在控制台收到一个500内部服务器错误 这是当用户保存填写的表单时我调用的控制器 var personStore = Ext.getStore('personBaseDetails'); var caStore = Ext.getStore('creditApplication'); var form = b
var personStore = Ext.getStore('personBaseDetails');
var caStore = Ext.getStore('creditApplication');
var form = button.up('form').getForm();
var id = personStore.first().get('ID');
//use this to update
if(caStore.count() < 1){
var creditApplication = Ext.ModelManager.create({
}, 'app.model.creditApplicationModel');
caStore.add(creditApplication);
}
var record = caStore.first();
form.updateRecord(record);
caStore.getProxy().extraParams = {
selectedUserID: id
};
caStore.sync({
success: function(batch) {
console.log(batch.operations[0].request.scope.reader.jsonData['message']);
},
failure: function(batch) {
console.log("Failed syncing ca");
}
});
我使用各种console.log语句检查了这里的所有变量是否都具有正确的值
以下是导致500内部服务器错误问题的php文件:
<?php
require_once('../../db_connection.php');
require_once '../../lib/response.php';
require_once '../../lib/request.php';
class creditApplication{
var $ID_PERSON;
var $APPLICATION_TYPE;
var $APPLICATION_SUB_TYPE;
var $APPLICATION_NUMBER;
var $CUSTOMER_NUMBER;
var $DATE;
var $STATUS;
var $ID_UNIT;
}
$request = new Request(array());
if(isset($request->params)){
var $selectedCustomer = '';
if(isset($_GET['selectedUserID'])){
$selectedCustomer = $_GET['selectedUserID'];
$array_r=$request->params;
$inputData = new creditApplication();
$inputData->ID_PERSON=$selectedCustomer;
$inputData->APPLICATION_TYPE=($array_r->APPLICATION_TYPE);
$inputData->APPLICATION_SUB_TYPE=($array_r->APPLICATION_SUB_TYPE);
$inputData->APPLICATION_NUMBER='sample application number';
$inputData->CUSTOMER_NUMBER='sample customer number';
$inputData->DATE='2014-4-4';
$inputData->STATUS=42;
$inputData->ID_UNIT='sampleUnit';
$query="INSERT INTO CREDIT_APPLICATION (ID_PERSON, APPLICATION_TYPE, APPLICATION_SUB_TYPE, APPLICATION_NUMBER,
CUSTOMER_NUMBER, DATE, STATUS, ID_UNIT)
VALUES ($inputData->ID_PERSON,
'$inputData->APPLICATION_TYPE',
'$inputData->APPLICATION_SUB_TYPE',
'$inputData->APPLICATION_NUMBER',
'$inputData->CUSTOMER_NUMBER',
'$inputData->DATE',
$inputData->STATUS,
'$inputData->ID_UNIT')";
$result = mysql_query($query);
//object response
$res = new Response();
$res->success = true;
$res->message = "Created user";
print_r($res->to_json());
}
else{
$res = new Response();
$res->success = false;
$res->message = "Error - no userID";
$res->data = array();
print_r($res->to_json());
}
}
else{
$res = new Response();
$res->success = false;
$res->message = "Error - no request";
$res->data = array();
print_r($res->to_json());
}
?>
除了ID_PERSON和STATUS是int之外,所有数据库行都是varchar,因此insert中有单引号,DATE是DATE格式
现在,我已经试着对这些值进行编码,注释出if-else条件,并通过localhost:8888/…/createCreditApplication.php调用php文件,它确实起到了作用。当我返回if-else块并将值传递到php文件时,就会出现问题
谢谢你的帮助 PHP中的500错误意味着检查web服务器的错误日志。错误将在此处详细说明。但在开发代码时,始终要确保打开错误报告并在屏幕上显示错误。在PHP脚本的顶部:error_reportingE_ALL;ini设置“显示错误”,1;很抱歉,我忘了指定我目前正在本地运行web应用程序。从localhost:8888可以明显看出本地运行-但是您的本地服务器仍有错误日志。但是,如果在运行时通过这两个函数调用启用display_errors,则无需转到日志。