作者:阿蕓 | 来源:互联网 | 2022-11-21 11:27
我想achievements
通过PHP 更新MySQLi表.该应用程序在AngularJS中编码并测量各种统计数据.当达到目标时,我使用AngularJS将信息发送到PHP脚本$http.post
.然后PHP应该处理信息并相应地更新我的表.在$http.post
返回成功消息,但没有更新的表.我相信数据库连接信息是正确的.
我的AngularJS $scope.updatePhp
函数使用$http.post
:
$scope.updatePhp = function(table, column, value, whereColumn, whereValue) {
$http.post(
"update-data.php", {
'table': table,
'column': column,
'value': value,
'whereColumn': whereColumn,
'whereValue': whereValue
}
);
}
我的AngularJS $scope.updatePhp
功能没有使用.post
快捷方式:
$scope.updatePhp = function(table, column, value, whereColumn, whereValue) {
console.log("Updating. Table: " + table + ", column: " + column + ", value: " + value + ", where: " + whereColumn + ", whereValue: " + whereValue);
$http({
method: 'POST',
url: 'update-data.php',
data: { table: table.toString(), column: column.toString(), value: value.toString(), whereColumn: whereColumn.toString(), whereValue: whereValue.toString() },
headers: { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' }
}).then(function successCallback(response) {
console.log("Success.");
}, function errorCallback(response) {
console.log("Error.");
});
}
我的整个PHP文件'update-data.php`:
table;
$column = $info->column;
$value = $info->value;
$whereColumn = $info->whereColumn;
$whereValue = $info->whereValue;
$query = "UPDATE '$table' SET '$column' = '$value' WHERE '$whereColumn' = '$whereValue' ";
$mysqli->query($query) or die(mysqli_error());
?>
我使用的PHP Error_log和我得到这个错误每个变量table
,column
,value
,等:
PHP Notice: Trying to get property 'table' of non-object in /update-data.php on line 16
.
信息的发布方式或发布信息的检索方式肯定存在问题,而不是SQL.
提前感谢您在整理这种情况时可以提供的任何帮助!