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

How to solve a problem with bind_param on a non-object?

I use bind_param() member function in my query, but I got error with my code. This is the piece of my code:
0
votes
4 answers

php mysql bind param parameters

I'm trying out using prepared statements for the first time and running into the following issue with the below code Error : Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given Code : $stmt =…
Xand94
  • 708
  • 1
  • 9
  • 23
0
votes
2 answers

A Possible Bug with PDO's bindParam, bindValue and foreach

I have been getting an error with this code. $Database = new Database('localhost','root','password','Db'); $Statement = $Database->prepare("INSERT INTO User VALUES(:ID,:FirstName,:MiddleName:LastName,:RegisteredDate") $Array_Bind =…
Koofah
  • 79
  • 1
  • 7
0
votes
1 answer

PDO bindparam and bindvalue. Which is the diference?

I've read the manual on PHP PDO and have seen this post: PDO PARAM_STR and length After reading that post I understand that we do not need to specify the length when inserting into DB but specify for outputting. My question is, can I use bindvalue()…
Dr3am3rz
  • 523
  • 1
  • 13
  • 41
0
votes
1 answer

Correct use of bind_param?

I'm working on a login for an application (school work), and I'm learning how to use the mysqli class in a proper way. Below is two methods from my application that's used for checking whether the username and password that the user types in is…
holyredbeard
  • 19,619
  • 32
  • 105
  • 171
-1
votes
1 answer

Concatenate query in MySqli prepared statement PHP

I've a list of item I want to insert in my table with a concetenation of INSERT queries. I'm using MySQL and PHP. I receive list of exercises names with POST (separated by commas), and want to save them in DB, associating them to an ID (i receive…
user1922860
  • 21
  • 1
  • 8
-1
votes
2 answers

Binding an array in MySQLi prepared Insert statement PHP

I tried multiple ways to create a function to bind dynamic array values into the MySQLi prepared statements. But I am getting error 'Uncaught mysqli_sql_exception: No data supplied for parameters in prepared statement' Here is my code: if…
Karthik Malla
  • 5,570
  • 12
  • 46
  • 89
-1
votes
1 answer

Query does not work as expected with bindParam but it does with raw input?

I have a query that should show all content from a specific date, like "show me all articles from 01-01-2020 to now". The date is in unix. And I'm using PHP 7.2. If I use bindParam instead of the real number, it shows content from within that date…
Rosamunda
  • 14,620
  • 10
  • 40
  • 70
-1
votes
1 answer

Can i use both bindValue and bindParam on a single prepared statement?

$nome = 'nome'; $stmt = $db->prepare("SELECT `nome`, `mov`, `gen` FROM table WHERE gen LIKE :gen AND nome = :nome"); $stmt->bindValue(':gen', '%'.$gen.'%', PDO::PARAM_STR); $stmt->bindParam(':nome', $nome, PDO::PARAM_STR); …
mario
  • 367
  • 1
  • 4
  • 17
-1
votes
4 answers

HOW TO LOOP PHP'S PDO BIND PARAM

Im current creating my own query builder now and Im stuck with PDO's prepared statement. Isn't it possible to loop the the PDO's BindParam. I did it using foreach() but it's not working it only on works on the last data that the loop executed. $sql…
EE-SHI-RO
  • 51
  • 1
  • 7
-1
votes
1 answer

How to select table by php var when use in mysqli bind_param?

Normally i use this code, it's work good. prepare($sql); $statement->bind_param('s',…
reswe teryuio
  • 117
  • 1
  • 1
  • 8
-1
votes
1 answer

Does sanitizing input data prevent sql injection?

Well, table and column names cannot be replaced by parameters in PDO. As a requirement, mentioning static column name is not possible here. So, I use santize. Is it enough to prevent sql injection like bind param method. What can be best method…
Dipak
  • 931
  • 14
  • 33
-1
votes
3 answers

How to use PHP prepared statements in OOP

I am saving my data using this code (pasting my code) Connection.php: con = new mysqli(connection…
n00b
  • 192
  • 13
-1
votes
1 answer

Incorrect datetime value: '2018' for column when passing valid date as string

Today i experience a very strange issue. Appearently the date passed is not the same as the one bind_param passes to my query. The database structure: |id varchar(16) autoincrement|date_created datetime|date_updated datetime| Currently the table…
inxomnyaa
  • 99
  • 1
  • 10
-1
votes
1 answer

PHP bind_param not binding parameter

I am trying to search a table for specific items using a prepared statement in PHP. I am getting no errors, but also getting no record. Here is my code: $items = []; $search = "john"; if ($stmt = $this->con->prepare("SELECT * FROM phptest WHERE…