Skip to content
Advertisement

how do I correctly use mysqli_stmt::bindParam()

I am having difficulty understanding how to properly use bindParam();

I have been following the details at the following URL: http://php.net/manual/en/pdo.prepared-statements.php which show the following as one of their examples:

JavaScript

This example is obviously incomplete, however, it shows enough of the details that I should be able reproduce the same results.

I have lifted the code below out of my main program and put it into it’s own file to see if I can isolate the issue, so far, it has. I have replicated a snipped of my input data to recreate the same conditions I am getting with the real data, and well, I got that right because I am getting the same error.

I have been getting the error message: Call to undefined method mysqli_stmt::bindparam() which leads me to believe that something is wrong stmt. So, I have put some debugging code in to see what is inside stmt. It appears to be an object, so, it’s defined, there are no SQL errors thrown up to that point to suggest an SQL syntax error, everything connects, and seems to function properly, and the object appears to me defined, however, the minute it goes to use it, it’s undefined.

I am at a loss, as I followed the example best I could. It seems bindParam() uses references when it sets things up, so I created the variables ahead of time so it has something to work with.

There is something about this that I do not understand and the documentation is not explaining enough for me to get it.

The following is the test script I am using, it is the complete file, minus some obvious stuff.

JavaScript

This is the output page showing the values being spit out.

JavaScript

Advertisement

Answer

First of all the link you gave at the first paragraph belongs to PDO. But in the title you said mysqli and in the code you create mysqli.

So you need to read the documentation here:

http://php.net/manual/en/mysqli-stmt.bind-param.php

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement