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
0
votes
0 answers

SQL - WHERE LIKE OR with bindParam

I'm trying to do an SQL search from a multiple checkbox with three options : Basico Avancado Interm When the two first options are selected I suppose i'll have something like this : SELECT * FROM candidates WHERE catiav4 LIKE %Avançado% OR…
Lasz
  • 1
0
votes
0 answers

How to use array for MySQLi->bind_param()?

So, say I have an array of values, set by a user somewhere: $array = array("test0", "test1", "test2"); From that, I automatically prepare a mysqli statement: $statement = "SELECT * FROM x_table WHERE x = ? AND y = ? AND z = ?"; $s = "sss"; How,…
Kyron
  • 64
  • 9
0
votes
1 answer

mysqli bind_param not returning correct data but the query is correct

I have this small piece of code. echo $token; $selstmt=$conn->Prepare("SELECT UserID FROM USER WHERE Token LIKE ?"); $selstmt->bind_param('s', $token); echo…
Mukul
  • 1
  • 1
0
votes
1 answer

mysqli error - bind_param: number of variables doesn't match

I am getting the following error but I have counted things over and over again and everything appears to be fine. Anyone have any ideas on it ? Error: Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match…
James
  • 1,668
  • 19
  • 50
0
votes
1 answer

PDO :: bind variable with LIKE

Can anyone help me This works fine :: $stmt = $this->conn->prepare("SHOW TABLES FROM db LIKE 'xyz'"); //tablename hardcoded $stmt->execute(); $rows = $stmt->fetch(PDO::FETCH_ASSOC); //fetchAll …
Hytool
  • 1,358
  • 1
  • 7
  • 22
0
votes
3 answers

How can I call a function with a dynamic amount of arguments?

I have an array and I need to pass each element of the array as parameters to a function. Say: $var = array("var2","var3","var4"); //Pass each element as a new parameter to a function call_to_function ($var2, $var3, $var4); //However, if the number…
Veer Shrivastav
  • 5,434
  • 11
  • 53
  • 83
0
votes
1 answer

PDO bindParam with unknown number of parameters

I would like to run an update query for every row with a specific ID: e.g. $ids = array(111, 112, 113); $query = "UPDATE mytable SET columnName = 'Y' WHERE id = :id1 or id = :id2 or id = :id3"; $stmt->bindParam(':id1', $ids[0],…
user1480951
  • 143
  • 2
  • 13
0
votes
1 answer

PDO bindParam using an array, not working as assumed

I have the following code... $statement = $conn->prepare("insert into logtest (course, date, time, distance, actualstarttime, finishtime, fav, favtotalmatched, favwma, 2ndfav, 2ndfavtotalmatched, 2ndfavwma, 3rdfav, 3rdfavtotalmatched,…
MrVimes
  • 3,212
  • 10
  • 39
  • 57
0
votes
2 answers

PHP PDO bindParam doesn't modify the query

I have the following code: if(isset($_GET['q'])){ $sql = "SELECT klantnr, persnr, naam, voornaam FROM gegevens WHERE voornaam LIKE % :voorwaarde % OR naam LIKE % :voorwaarde %"; $stmt = $db->prepare($sql); …
0
votes
0 answers

Why can't I insert data from a form into my Database with PDO bind_param

First here is my code: database.php (established connection so I can use with require)
Lucas Santos
  • 1,359
  • 3
  • 24
  • 43
0
votes
1 answer

PHP Bind_param fetch data

Guys im using Bind_param in php to retrieve Username and password from Login table. my question is how can i fetch all the info of user, and pass it to variable as an object? please see my code below require 'dbc.php'; require…
Nixxx
  • 133
  • 2
  • 10
0
votes
3 answers

Insert a lot of record using single arguments and using bindParam

I have some method to insert some data into a database like this: public function register($username, $email, $hashedPassword, $activationCode) { try { $conn = Database::getConnection(); // Connect and create the…
Ying
  • 1,282
  • 4
  • 19
  • 34
0
votes
1 answer

PHP: undefined variable & Call to a member function bindParam() on a non-object

$conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " .…
0
votes
0 answers

trying to insert data into PDO but getting error: Indirect modification of overloaded property has no effect

I'm using a form to read the $_POST values $s=new Student(); $s->Name=$_POST['name']; $s->Email=$_POST['email']; $s->Education=$_POST['education']; $s->Save(); ... public function…
0
votes
2 answers

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:
Quade2002
  • 615
  • 2
  • 7
  • 23