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

mysqli_stmt::bind_param() - specify another data type than "s" for each parameter

A mysqli_stmt does not have a query_params() function, I had to write my own. The parameter arry is bound to the statement with bind_param(). I need to specify the variable types dynamically. I could do that with something like: $sType = ''; foreach…
Code4R7
  • 2,600
  • 1
  • 19
  • 42
2
votes
2 answers

Can you pass multiple params using OR to an SQL/PHP single bind statement?

I have a search bar that passes data to the server. I am taking the sentence sent and breaking it into individual words. I am then comparing a column against each word in the sentence. $term = filter_var($input['term'],…
seamus
  • 2,681
  • 7
  • 26
  • 49
2
votes
1 answer

MySQL Insert Double Quotes PHP

I am using the below-prepared statement to insert into MySQL. If I try and insert something with $descrip containing a " (double quote) the insert stops at this point. Example: Trying to insert 16" Solid Steel Tube The entry into the table row only…
RonnieT
  • 2,193
  • 4
  • 32
  • 43
2
votes
2 answers

showing data from database using bindParam

i want to try to showing my data from database using bindParam but i get some error. Recoverable fatal error: Object of class PDOStatement could not be converted to string in C:\xampp\htdocs\piratefiles\search.php on line 15 here my code $category…
jazuly aja
  • 89
  • 10
2
votes
1 answer

code to search for a constant value by posting the column name is not working need some correction

I am trying to retrieve user data from a database ... value is constant ("t") and i have so many columns to search in so i have decided to post the column name using post method and look for the constant value("t" in my case). I have created this…
Sumit Pal
  • 235
  • 1
  • 3
  • 13
2
votes
3 answers

How can I write less code with bindParam?

I am using PDO to insert data into a table. The problem is, there's a lot of columns, meaning the query is very long. This is the code I have currently: $stmt = $con->prepare("INSERT INTO table (crips, biscuits, chocolate, cakes, smarties, yogurts,…
The Codesee
  • 3,714
  • 5
  • 38
  • 78
2
votes
2 answers

PHP bind_param with arrays

Is it possible to use bind_param() with arrays? For example $stmt->bind_param('iss', Array(101, 'SomeString 1', 'Some string 2')); // OR $stmt->bind_param(Array('iss'), Array(101, 'String1', 'String2')); // OR $stmt->bind_param(Array( Array('i',…
user7106750
2
votes
1 answer

Passed-in parameter used in GROUP BY still returns 1 row?

I stumbled on this behavior and now I'm curious what's actually going on. If I try to bind a parameter to a column name in the GROUP BY clause, data is actually returned, but only one row. I know you're not allowed to use table or column names as…
LinkDinkin
  • 35
  • 4
2
votes
1 answer

Bind_param with value 0

When I execute: $stmt = $mysqli->prepare('SELECT * FROM TableName WHERE ColumnName = ?'); $tmp = 0; $stmt->bind_param('i', $tmp); I receive the error: No data supplied for parameters in prepared statement I have to do the following to make it…
Atomico
  • 453
  • 1
  • 6
  • 26
2
votes
1 answer

Why bindValue or BindParam doesn't modify the prepared statement?

Using latest php in order to create a function that adds a row to table user. class targil_db { private $_pdo; public function __construct() { // username: root password: database: targil $this->_pdo = new PDO( …
ufk
  • 30,912
  • 70
  • 235
  • 386
2
votes
1 answer

How to use Reflection to insert data with mysqli by bind_param method? what is difference of these two arrays?

As bind_param($types, $var1, $var2, $var3,..) method of mysqli_stmt class it gets just a series of $variables after second parameter (I want to pass array there), and the number of $variables is unknown in my case, I want to use Reflection in my…
juma
  • 31
  • 5
2
votes
1 answer

Errno(0) when attempting log in with OO statement

I am attempting to make a more secure log in system. My registration is working fine so its not a connection issue. Just needing a fresh pair of eyes to see if there are any errors that I may be missing, can anyone help please?…
Zach Hall
  • 27
  • 1
  • 1
  • 8
2
votes
2 answers

bind_param() only necessary on user-inputted values or all?

I've been reading up on SQL injections and I couldn't find an answer to this question. I understand if I a query like this prepare("SELECT id, foo, bar FROM table WHERE username = ?"); Then I should use bind_param('s', $username) to avoid SQL…
Muhammad Ali
  • 668
  • 1
  • 9
  • 24
2
votes
1 answer

PDO bindParam variable datatype from array

I have an array which relates mysql-colums to PDO datatypes: $imp->datafields=array( "id" => "PARAM_INT", "name" => "PARAM_STR", "cookieLength" => "PARAM_INT" ); I want to bind these parameters using…
Dong3000
  • 566
  • 2
  • 7
  • 24
2
votes
1 answer

PDO Bind Params depending on whether they exists in the query

Lets say I have a mysql query which gets built depending on certain conditions: example $query = "SELECT * from `usertable` where users_active=:users_active"; if($mode=="archived") { $query .= " AND archived=:archived"; } $stmt =…
James Stoddern
  • 397
  • 1
  • 5
  • 19
1 2
3
17 18