Questions tagged [bindparam]

In PHP, binds a variable to a corresponding named or question mark parameter in the SQL statement that was used to prepare the statement.

Binds a PHP variable to a corresponding named or question mark parameter in the SQL statement that was used to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement::execute() is called.

public bool PDOStatement::bindParam ( mixed $parameter , mixed &$variable [, int $data_type = PDO::PARAM_STR [, int $length [, mixed $driver_options ]]] )

Reference

PHP Documentation

267 questions
1
vote
1 answer

Bind parameters dynamically to a mysqli statement

I am trying to build a dynamic prepared statement but I am stuck at the bind_param part. I tried to read other answers referring to call_user_func_array but I couldn't figure out how to adapt it here: //connecting $connection = new mysqli(DB_SERVER,…
Mihai
  • 2,807
  • 4
  • 28
  • 53
1
vote
1 answer

MySQLi bind_param() not working

I have a rather odd issue with the PHP bind_param function for MySQLi. I create the query with ?'s where the parameters will be bound, I prepare the statement, I bind the parameters and then I execute the statement. For some reason it is not…
willcaddy
  • 33
  • 7
1
vote
0 answers

PHP PDO statement not working

I'm having a problem with my PDO statement. I have an in active pipe tail -f /var/log/apache2/error.log watching for errors and nothing is coming in, I even piped my mysql.log file no errors there either. if i echo $_POST['sfl'] it will print an…
Jordan Davis
  • 1,485
  • 7
  • 21
  • 40
1
vote
2 answers

PHP bind_param not defined

I am working in MAMP trying to make a login function. My connection code is: $servername = "localhost"; $username = "root"; $password = "root"; $db = "world"; $mysqli = new mysqli($servername, $username, $password,…
1
vote
2 answers

Dynamically bind params in $bind_param(); Mysqli

I have DB class which is dealing all queries will be made to database I have mysqli prepare working fine. bind_param is also working fine but the problem is I want to define variable type dynamically. here is my code public function query($sql,…
Saeed Ansari
  • 455
  • 8
  • 16
1
vote
1 answer

bindValue / bindParam vs array performance

I have always passed an array of my values into execute as it seemed easier to read imo. I was recently working on a script and noticed it was using bindParam and later came to find out how this passes the variable reference (I never knew). With…
user756659
  • 3,372
  • 13
  • 55
  • 110
1
vote
0 answers

Fatal error: Call to a member function bindParam() on a null

I need some help. I have some nested SELECT statements that get the user's ID then use that ID to search another table in MySQL. I have a foreach() loop that uses the user_id from the first query to create a folder for the user if there isn't one in…
Drew
  • 358
  • 3
  • 9
1
vote
1 answer

Mysqli error with bind_param(): Number of elements in type definition string doesn't match number of bind variables

I tried what I could to solve this error without any success. I'm trying to dynamically build a select query with prepared statement : I've got this code $gm = $_GET['gm']; $ct = $_GET['ct']; $query = 'SELECT * FROM fchar'; $cond =…
1
vote
2 answers

Database class, OOP - connect to mysql

This is database class: DB.php
Tov
  • 23
  • 5
1
vote
1 answer

Error in php sql statement ($stmt2 is returning false but I dont know why)

I am getting this error (Call to a member function bind_param() on a non-object ) for my prepared statement as below which I know means that there is some error in the sql statement but I cannot see any error at all. I have been staring at this for…
kabeersvohra
  • 1,049
  • 1
  • 14
  • 31
1
vote
1 answer

PHP Session with MySQL Insert Into using bind_parm

I am simply trying to insert the variable from a session into a MySQL database and it causes it to fail. var_dump shows SESSIONS all there. No problem there. Why doesn't this work? $job = $_SESSION['job']; $user_id = '1'; $name = 'allie'; $stmt =…
looloobs
  • 761
  • 2
  • 11
  • 24
1
vote
0 answers

PHP/MySQL: bind_param malfunction when using mysql function inside prepared statement

I'm having trouble encrypting a password when adding an entry into mysql using php bound parameters. Everything works just fine with 2 bound parameters ($username and $password) being inserted directly into the username and password field. But, when…
Andrew
  • 56
  • 6
1
vote
0 answers

How to properly pass and return by reference between function inside a class

I create a class that hold mysqli object link with a private function to generate params that needed by bind_params function which then will be used by this function: call_user_func_array(array($stmt, 'bind_param'), $params); Since, bind_param need…
Mas Bagol
  • 4,377
  • 10
  • 44
  • 72
1
vote
0 answers

Syntax error when binding table name as SQL parameter

my table is like below CREATE TABLE IF NOT EXISTS BID_1s ( secId varchar(6) NOT NULL UNIQUE, fhigh float, flow float, fopen float, fclose float, fdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(secId) )…
shahab
  • 171
  • 2
  • 11
0
votes
0 answers

PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

I'm new in Stackoverflow and I'm sorry if I might not be clear with my question. I don't understand what's wrong in my code and I would like to have your help. This is the php code snippet: $giorno = "2023-06-12"; $arraySezioni = [1,4,7,9]; //PRIMO…
Dany
  • 1