无论我试图修复它们多少,我都会遇到这些问题。 我正在处理Html可视化编辑器CMS,每次我登录这些错误显示。 希望这篇文章清晰易懂。如果不问我,我会尽我所能来回答你。 下面是错误的:
call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
Call to a member function execute() on boolean
下面的代码:提前
class database{
public $root_db = 'cms';
public $server_name = 'localhost:3306';
public $root_db_user = 'root';
public $root_db_pass = '';
public $connection;
public $error = false;
function connect_to_db(){
$this->connection = new mysqli($this->server_name,$this->root_db_user,$this->root_db_pass,$this->root_db);
if($this->connection->connect_error){
$this->error = "Connection Failed: " . $this->connection->connect_error;
}
}
function executeCleanQuery($query,$params){
$type_string = '';
$param_arr = array();
if(!empty($params)){
for($i = 0; $i < count($params); $i++){
$type = gettype($params[$i]);
$type_string .= $type[0];
$param_arr[$i] = $this->connection->real_escape_string(htmlentities($params[$i]));
}
array_unshift($param_arr,$type_string);
if(!$stmt = $this->connection->prepare($query))
$error = "Unable to prepare statement";
call_user_func_array(array($stmt,"bind_param") ,$this->refValues($param_arr));
if (!$stmt->execute())
$error = "Unable to execute statement";
$result = $stmt->get_result();
if($result && (strstr($query,"SELECT") || strstr($query,"select")))
return $result->fetch_all(MYSQLI_ASSOC);
else{
return $this->connection->insert_id;
}
}else if(strstr($query,"SELECT") || strstr($query,"select")){
$result = $this->connection->query($query);
return $result->fetch_all(MYSQLI_ASSOC);
}else{
return true;
}
}
function refValues($arr){
if (strnatcmp(phpversion(),'5.3') >= 0) //Reference is required for PHP 5.3+
{
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
return $arr;
}
}
和感谢。
'对不起,长头衔哈哈。我讨厌告诉你,但那个完全可怕的头衔会杀死你的问题。它要么被低估并关闭(并最终被删除),否则将被忽略。努力写出一个有意义的标题来真正解释你的问题,或者期望遇到问题。这次你可能会得到一个答案,但它会在未来的事件中给你带来问题 – psubsee2003
对此很抱歉。 –