php - PHP 未捕获错误:在 null 上调用成员函数 escape_value()
问题描述
我收到此错误:
未捕获的错误:在 /opt/bitnami/nginx/html/blog/assets/includes/Library/Misc.php:15 中调用成员函数 escape_value()
这是第 15 行:
public static function get_function($func="") {
global $db;
$result_array = self::preform_sql("SELECT * FROM " . DBTP . self::$table_name . " WHERE function = '" . $db->escape_value($func) . "' LIMIT 1");
return !empty($result_array) ? array_shift($result_array) : false;
}
我该如何解决这个问题?
解决方案
global $db;
//add this to check $db
if (empty($db)) { //better to use instanceof function
return null; //or do something your: show error | throw exception | else
}
推荐阅读
- javascript - 在 FullCalendar 中使用 eventClick(在 Shiny 中)
- python - 未检测到对象时,SORT 跟踪算法不起作用
- c++ - dx11 渲染到纹理只显示 clearcolor
- wordpress - Apache Tika 正在索引 HTTP 响应而不是文档内容
- javascript - 当迭代之前有值时,对象数组的属性为 NULL
- python - 从 PyCharm 迁移到 VS Code:设置路径
- react-native - 将参数传递给 createStackNavigator 中的嵌套屏幕
- vue.js - 使用 vuetify 在标签后显示工具提示图标
- django-rest-framework - Django rest swagger 文档显示选择文件作为字符串
- python - SQLAlchemy 不执行查询