473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Call to a member function execute() on a non-object

Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in C:\xampp\htdocs\project\modules\Sql.php on line 23


call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in C:\xampp\htdocs\project\modules\Sql.php on line 24


below is the code of Sql.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. abstract class Sql{
  3.     public static $mysqli=null;
  4.     public static function init($DB){
  5.         if(!isSet(self::$mysqli))
  6.             self::$mysqli=$DB;
  7.     }
  8.     public static function query($query,$param_string="",$param_array=array()){//used in void type query like insert,delete,update
  9.         $stmt=self::$mysqli->prepare($query);
  10.         array_unshift($param_array,$param_string);
  11.         if(count($param_array)>1)
  12.             call_user_func_array(array($stmt,'bind_param'),$param_array);
  13.         $stmt->execute();
  14.         $ans=max(self::$mysqli->affected_rows,self::$mysqli->insert_id);
  15.         $stmt->close();
  16.         return $ans;
  17.     }
  18.  
  19.     public static function getArray($query,$param_string="",$param_array=array()){//used in select type query
  20.         $stmt=self::$mysqli->prepare($query);
  21.         array_unshift($param_array,$param_string);
  22.         if(count($param_array)>1)
  23.             call_user_func_array(array($stmt,'bind_param'),$param_array);
  24.         $stmt->execute();
  25.         $result=$stmt->result_metadata();
  26.         $row=array();
  27.         $temp=array();
  28.         $params=array();//list of location,of some pointer where value of answill come.
  29.  
  30.         while($field=$result->fetch_field()){
  31.             $row[$field->name]=null;
  32.             $params[]=$field->name;
  33.             $temp[]=&$row[$field->name];
  34.         }
  35.         call_user_func_array(array($stmt,'bind_result'),$temp);
  36.         $out=array();
  37.         while($stmt->fetch()){
  38.             $thisRow=array();
  39.             for($i=0;$i<count($row);$i++){
  40.                 $thisRow[$params[$i]]=$row[$params[$i]];
  41.             }
  42.             $out[]=$thisRow;
  43.         }
  44.         $stmt->close();
  45.         return $out;
  46.     }
  47.     public static function getArrayLength($query,$param_string="",$param_array=array()){//used in select type query, to know length only
  48.         $stmt=self::$mysqli->prepare($query);
  49.         array_unshift($param_array,$param_string);
  50.         if(count($param_array)>1)
  51.             call_user_func_array(array($stmt,'bind_param'),$param_array);
  52.         $stmt->execute();
  53.         $stmt->store_result();
  54.         $numRows=$stmt->num_rows;
  55.         $stmt->close();
  56.         return $numRows;
  57.     }
  58. }
  59.  
  60. ?>


the above error is coming on running the project , Please resolve the problem anyone or give some solution.
Aug 4 '14 #1
1 3963
Dormilich
8,658 Expert Mod 8TB
call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
it’s like in the message, make sure you pass the correct data. and if the logic doesn’t seem off, test the variables to see what they actually contain.
Aug 5 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

37
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
2
by: dmitry.freitor | last post by:
Why would someone call a non-static provate member function from another non-static member function of the same class via the this pointer? Thanks. DF
8
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
5
by: loudwinston | last post by:
Hello, I'm encountering a strange error with PDO. The server is FreeBSD 4.4, PHP 5.1.2, mySQL 4.0.20 with 4.1.18 client libs. I have the following code (usernames and passwords changed to...
18
by: tbringley | last post by:
I am a c++ newbie, so please excuse the ignorance of this question. I am interested in a way of having a class call a general member function of another class. Specifically, I am trying to...
2
by: mahesh | last post by:
Can anyone direct me to the place where i find the solution for the error message "cannot call member function 'X' without object"??? thanks in advance
2
by: Elliott | last post by:
Hello Everyone, I have a function in a header (KeyDialog.h) as such: void setKey(Key&); The function implementation is as such (KeyDialog.cpp): void KeyDialog::setKey(Key& k1) {
4
by: Immortal_Nephi | last post by:
I had a lot of research to see how function pointer works. Sometimes, programmers choose switch keyword and function in each case block can be called. Sometimes, they choose ordinary function...
2
by: church7 | last post by:
Hello, I wrote the following class: In this case, the error message was
10
by: randysimes | last post by:
I am trying to pass uid and pwd to the function CheckPW of the class PWServer. I receive the error pwclient.cpp:41: error: cannot call member function âint PWServer::CheckPW(const char*, char*)â...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.