Tag Archives: function

【ERROR_2】Call to a member function bind_param() on a non-object

When I was using MySQli prepared today, I encountered the following error:
 
 
 
Fatal error: Call to a member function bind_param() on a non-object in …
 
The error statement for the report is:
$prepareQuery-> bind_param(“sssd”,$isbn,$author,$title,$price);
 
— Error reasons:
$query=”insert into boks values(?,?,?,?) “;
$prepareQuery=$db-> prepare($query);
$prepareQuery-> bind_param(“sssd”,$isbn,$author,$title,$price);
 
The name of the table Boks is wrong. It should be books
 
So: when encountering an error like this, you should double-check your SQL!

Python – get the information of calling function from called function

in a function

def fun():pass

How does the function

know who called it?In a C language, it seems difficult. But in python it’s very simple

import traceback
def fun():
      s =  traceback.extract_stack()
      print '%s Invoked me!'%s[-2][2]

the fun function will tell you who called it and print it out, so let’s try it:

>>> def a():fun()
>>> def b():fun()
>>> a()
a Invoked me!
>>> b()
b Invoked me!
>>>