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

Multiple Mysqli prepared statements using PHP

I am using Mysqli to display all results on my web page. But now i want to add security so i want to use Mysqli prepared statements to fetch data but i am confused how i can achieve it. My web page URL is…
Ashish
  • 303
  • 5
  • 22
1
vote
1 answer

PDO bind variables to prepared mysql statement and fetch using while loop

I've used several of your guides but I can not get the following to run. If I hardcode the 2 variables in the Select statement it runs fine. I need to use variables, and I can't get the bind statement to work. Plenty of experience with the old…
Werks
  • 49
  • 4
1
vote
1 answer

Inserting Multiple Values with PDO and a Loop

To give you some background, the flow is: Connect to a 3rd party API, pull data stored as json, convert to php and use the data in the below code. I found this work originally but unable to figure out how to modify it to my needs. Perhaps one of…
Granted
  • 53
  • 8
1
vote
1 answer

bindParam doesn't work when foreign key constraint set to cascade

I'm creating a forum site for an assignment and the code worked fine until I changed two things: I changed my database constraints to CASCADE (needs to be like that for the rest of the site) and I changed the query function to prepare, bind and…
KayeeJayee
  • 46
  • 7
1
vote
1 answer

Passing an Array As A Function's Parameters Using (...$array)

I'm trying pass an array as a function's parameters, and am having some trouble. Here's the function. $stmt->bind_param(); I was researching this and found that you can use this: $stmt->bind_param(...$values); This worked well on my developmental…
Blaise
  • 330
  • 1
  • 11
1
vote
2 answers

How to insert a mixed string using mysqli_bind_param prepared statements

I've been searching for an answer for a while now, but can't seem to find anything. I'm looking for a way to use mysqli_bind_param to insert a row into a table, where the param (?) is part of a larger string. This is my code: $query = "INSERT INTO…
SW_Cali
  • 383
  • 2
  • 17
1
vote
2 answers

BindParam() not working properly

In my DB class I have a method query() which takes the SQL statement and the parameters as arguments and runs them in the database. // the parameters are the sql statement and the values, returns the the current object // the result set…
Sayantan Das
  • 1,619
  • 4
  • 24
  • 43
1
vote
3 answers

PHP, MySQL: Issue with bindParam

This is the code I used to far: $stmt = $pdo->prepare('SELECT name, age, something FROM MyTable WHERE MATCH (name, age) AGAINST (:value IN BOOLEAN MODE)'); $stmt->bindParam(':value', $value, PDO::PARAM_STR); $stmt->execute(); $results =…
user6571697
1
vote
1 answer

PDO bindParam for date not working

I am a beginner at PDO, I was making a php function to return search results of flights, this is my code: $db = DB::getConnection(); $stmt = $db->prepare("SELECT * FROM `flights` WHERE `date` BETWEEN :befDate AND :aftDate AND…
Echoes
  • 324
  • 4
  • 14
1
vote
0 answers

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

I am getting this error in PHP Call to a member function bind_param() on a non-object in C:\wamp\www\makePitch\include\DB_Functions.php on line 33 $stmt = $this->conn->prepare("INSERT INTO pitches(image_url,trader_id,product_type,price,location)…
1
vote
1 answer

mysqli_query() expects parameter 2 to be string with bind_param

i am getting the error when i call the archive.php in browser: Warning: mysqli_query() expects parameter 2 to be string, object given in...
rjgodoy
  • 101
  • 4
  • 11
1
vote
2 answers

PDO->bindParam, PDO->bindValue and PDO->closeCursor

So far I have been using PDO->bindParam however while reading the manual I found PDO->bindValue from what I can tell PDO->bindValue passes by value where as PDO->bindParam passes by reference, is this the only difference? $modThread =…
Johnny
  • 1,963
  • 4
  • 21
  • 24
1
vote
1 answer

bindParam literate through private member variable of a class

I create a class called User with only private member variables and getter/setter functions class User { private $m_id; private $m_firstname; private $m_lastname; public function get_firstname() { return $this->m_firstnmae; } public…
yangsunny
  • 656
  • 5
  • 13
  • 32
1
vote
2 answers

bind_param(): Number of variables doesn't match number of parameters in prepared statement

Basically the problem is I have a column of dates in my database table and I want to count the number of each particular date and have it stored in an array.I've busted my head around this problem for a week and so far I've come up with this. …
Saeesh
  • 15
  • 3
1
vote
1 answer

bind_param Error 500

I have the following script called via javascript POST $target = $_POST['id']; $sid = $_POST['sid']; $sql = 'DELETE FROM `subusers` WHERE `subusers.uid`=?'; $stmt = $conn->prepare($sql); if($stmt === false) { trigger_error('Wrong SQL: ' . $sql .…
Cârnăciov
  • 1,169
  • 1
  • 12
  • 24