473,609 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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\module s\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\module s\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 3983
Dormilich
8,658 Recognized Expert Moderator Expert
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
4982
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 signature. When developing this lib, I figured that the pointer-to-member-function, although seemingly an attractive solution, does not work well for us.
2
2403
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
3336
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
5
16492
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 protected the innocent ^_^) <? $db_dsn = "mysql:host=dbHost;dbname=dbName";
18
2855
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 write an ordinary differential equation class that would solve a general equation in the form: dx/dt = f(x,t). The ode class shouldn't know anything about f, except how to call it.
2
22753
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
37235
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
4394
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 pointer array instead of switch. They believe that ordinary function pointer is much faster than switch. Think of one variable called selectFunction. selectFunction variable can be the range of 0 through 1,000 or more. Load selectFunction...
2
4900
by: church7 | last post by:
Hello, I wrote the following class: In this case, the error message was
10
16071
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*)â without object Where am I going wrong? Here is the code in int main(): cout << "User ID: "; cin >> uid; cout << "Password: "; cin >> pwd; PWServer::CheckPW (uid, pwd)
0
8126
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8563
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8524
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8210
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6990
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5507
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2527
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.