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

Why MySQLi prepared statement doesn't work if I pass parameter by array index?

Why does this return no MySQL rows: $sql = $conn -> prepare("select * from table where id = ?"); $sql -> bind_param('i', $array[0]); $array = array(1); $sql -> execute(); But when I put the array before bind_param it's working. It works like…
1
vote
1 answer

PHP -> How to bindParam multiple values in a registration query?

There are several other questions like that, but I didn't understand them correctly, and also don't know how to copy&change the code to work for me. I got it working, to check, if an user already exists, but if he does, the user should get inserted,…
Jimmy
  • 39
  • 6
1
vote
1 answer

Why does this UPDATE prepared statement doesn't work, but works when used in SQL db

I have the following statement: $stmt = $con->prepare("UPDATE accounts SET loggedin = ? WHERE TIMESTAMPDIFF(SECOND,lastcheck, NOW()) >= ? AND loggedin = ?"); $stmt->bind_param('iii', 0, 61, 0); And it gives 500 internal server error. When I tried…
1
vote
2 answers

How to bind params to multiple values without parameter repetition

My prepared statement looks something like this: $stmt20 = $conexao->prepare(" INSERT INTO esc_usuarios_pgtoparcelas (parcela_codigo_plano, parcela_mes, parcela_valorBonificacao, parcela_situacao) VALUES (LAST_INSERT_ID(), ?,…
1
vote
0 answers

PHP Sqlite script fails on bindparam instruction

I have been looking through similar questions which I have a learnt a thing or two from but I don't seem to be able to make any progress with my problem. I suspect I might be iniating the DB wrong or something like that. My script gets values from…
wayjo
  • 11
  • 2
1
vote
0 answers

Mysqli bind_param for column name in update query

Is it possible to use bind_param in update query where column's name can dynamically changes? for example sql='update table_1 set ? = ? where id=?' In the query above, I want to set the column name also by bind_param, but it causes error.
Art Croix
  • 43
  • 1
  • 6
1
vote
3 answers

PHP/MySQL Dynamically create prepare query

I am trying to pass a list of input field's ID that have been modified so I can create a UPDATE query in MySQL only for the modified data. Here is what I have so far.. In jQuery I have the following code that makes a JSON list of all the id's that…
Bijan
  • 7,737
  • 18
  • 89
  • 149
1
vote
0 answers

bindParam in a loop always writes the last value

I am having trouble updating an array of data in nested foreach loops. I have read many similar issues on SO but non using a nested foreach (see my array schema) and the answer seems to be using the 'by reference' operator '&' on the value - but…
Flim Flam
  • 197
  • 4
  • 15
1
vote
1 answer

SQL bindParam not Working

I have problem with my code, I can't show data from my database I am using bindParam() and bindValue() it's still not working. This is my code: $id = $_GET['id']; try{ $database = new Connection(); $db = $database->openConnection(); …
1
vote
2 answers

Inserting BIT(M) Column Values to MySQL5.7 with PHP7 MySQLi Prepared Statements

When trying to insert values into a BIT(64) column using MySQLi prepared statements, I am receiving the error (on execute): Data too long for column 'bits64' at row 1 Here's my code: if ($Segments[0] == 'yes') {$bitmask = '1';}else{$bitmask =…
Justin
  • 663
  • 7
  • 19
1
vote
3 answers

Data not inserted but have no error PHP using bind_param

i have a simple code to input data to my database using prepare and bind_param there is no error but my data are not inputted into database $stmt1 = $mysqli -> prepare ("INSERT INTO equipment(eqp_type, eqp_name, eqp_qty, eqp_usd, $eqp_idr)…
1
vote
1 answer

Having trouble getting search to pick up OR statement in PHP MySQL Query

Currently building a CRUD system to keep track of product numbers. In the query I've set up for the search, it doesn't seem to pick up anything but 'p.name', but doesn't pick up anything else, whether I put it first or second in the WHERE statement…
1
vote
2 answers

SELECT Prepared statement

I've tried everything that I found on this community and other sites. But I'm still failing to complete my objective. What I want to achieve: On one page I have a input box with a button. When I fill in de ID number I want to get all the information…
WouterS
  • 139
  • 3
  • 16
1
vote
1 answer

Can't get bind_param() working correctly

I'm trying to do a simple insert on my database after retrieving a value from it, I'm following the same procedure to retrieve a value from my database as to insert values in it, but I get the following error: Fatal error: Uncaught Error: Call to a…
Fer Cervantes
  • 225
  • 2
  • 6
1
vote
1 answer

PHP PDO returning null column names

I am developing SOAP service in PHP. Recently I have came across an issue when retrieving results from MySQL. Problem When retrieving results I get more columns than specified in my SQL statement. This is affecting my code when processing retrieved…
XAMlMAX
  • 2,268
  • 1
  • 14
  • 23