Jump to content

Binding array values to variables


matt25

Recommended Posts

Hi I am adapting Jeffery Ways Mysql class to accept multiple where statements however I have got stuck on the final hurdle.

It is when I try to do the bind_results() and I pass in the parameter types and the parameters. Here is that part of the code:

 

if ($this->_where)
            $values = array_values($this->_where);

         $str = "'";
             $str .= implode('\', \'', $values);
            $str .= "'";
            // echo $str;
         $count = count($this->_where);

         foreach($this->_where as $key => $value){
             $key = $value;
         }
         $user = 'matt25';
         $pass = '6722853cacc4a9649dc75abc852f23c35b1f75cb';

         $stmt->bind_param($this->_paramTypeList, $user, $pass);
      }

 

It works how it is by setting the parameters as variables, but that obviously isn't practical. as you can see I also tried to make a string with the values from the array which brought up the error:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in C:\wamp\www\trick_tips\admin\includes\MysqlDb.php on line 260,

 

the same as when I try to put the array into there.

 

So I need some way of setting each value in the array as a variable to then put into the function, or another Idea that I have completely missed.

 

Any help would be much appreciated.

 

Cheers,

Matt

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.