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
1 answer

How to create a Php multi insertion?

I am trying to prepare an insertion inside the database with php, but i can't find any suggestions on how to use the syntax, this is what I've got so far, could someone help me with this please? $last_id = mysqli_insert_id($conn); $query =…
0
votes
1 answer

Can PDO bindParam() or bindValue() make the db does soft parsing?

With PHP, I am trying to execute many queries with PDO in for loop and I want to make the DB optimizer does the soft parsing. I am binding parameters now but I am not sure if the optimizer really uses the soft parsing. The sample query select * from…
체라치에
  • 173
  • 1
  • 16
0
votes
1 answer

data not storing in database

I am developing a small form in which the user can register using PayPal payment. but the problem is the user information is not storing in the database after the successful payment. Here is the code for insert $db = new mysqli($dbConfig['host'],…
jaiswal
  • 1
  • 2
0
votes
1 answer

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ID' cannot be null

I am trying to create a user registration form. However, when testing it on local machine, I get an error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ID' cannot be null. I'm running it on AMPPS Apache, PHP 7.1 / MySQL. My OS…
Alice Rivers
  • 1
  • 1
  • 3
0
votes
0 answers

PDO not correlating parameters set with bindParam() and in method using $args returns an empty array

What I am trying to achieve: Explanation: I am constructing a simple process where my class 'Content' will convert an array into objects and print them out on my webpage as they are called. Expected Outcome: $stmt PDO will bind parameters using…
Wes Henderson
  • 117
  • 1
  • 7
0
votes
1 answer

mySQLi bind_param not working as expected

I have the following query:- SELECT make_ID, mileage FROM cars WHERE make_ID = ? ORDER BY ? The query works fine, except for the parameter binding. This is my prepared statement code:- $stmt = sqli::$link->prepare($sql); $make_filter =…
0
votes
1 answer

Dynamic parameter binding using prepared statements

In building prepared statements for my site, I found that a lot of redundant code could be iterated over. mysqli::prepare was a pretty straight forward one to iterate, but when I got to mysqli::bind_param and mysqli::bind_result, I ran into the…
Evan Hendler
  • 342
  • 1
  • 12
0
votes
1 answer

How can I use the bind_param() with multiple params

So I have a table with the colums title,description,created, fk_u. Then I have this statement: $stmt = $conn->prepare( "insert into blogs1(title,description,created,fk_u) values(?,?,?,?)"); Afterwards I try to bind the parameters with…
samuel gast
  • 331
  • 4
  • 17
0
votes
0 answers

I am trying to run this query in PHP: INSERT INTO SET

This is the code which I'm trying to use for the query: $data=[ 'e_id' => $eid, 'e_name' => $ename, 'e_deptid' => $edid, 'e_sal' => $esal, ]; foreach($data as $keys=>$values){ if($key==0){ $fields .= $keys . "=?"; } else { …
0
votes
0 answers

PHP variables not keeping any data, and not inserting into Mysql Database using MySQLI Bindparams

So i am very new to Mysqli and have this code (see below) and i think it's all done correctly but for some reason it's not inserting anything into the database and i can't figure out why. I've followed tutorials online and read examples online but i…
Ben Smith
  • 31
  • 4
0
votes
1 answer

How to use while in mysqli bind_param (not working on my code)?

Why i select incorrecr row mysqli php ? Table : test https://i.imgur.com/vM9Uy7P.jpg This is my old code, it's work good.
reswe teryuio
  • 117
  • 1
  • 1
  • 8
0
votes
0 answers

MySqli Prepared Statements - execute() returns false

CODE: public function addVendorForm($data,$db){ $date = date('Y-m-d'); $q = $db->prepare('INSERT INTO…
Silambarasan R
  • 1,346
  • 15
  • 22
0
votes
1 answer

SQLSRV Parametrized query taking forever in a GROUP BY clause

I'm using the SQLSRV 4.3 PDO with PHP 7.1. I've already tested it on SQLSRV 3.2 with PHP 5.6 too. So, I have the following query: $sql = "select [ID], [Year], [Month], sum(Value) as Value, MIN(FirstDateTime) as FirstDateTime, MAX(SecondDateTime) as…
0
votes
1 answer

PDO bindParam not working in loop

I am having trouble getting bindParam to work inside of a foreach loop. If I use bindParam outside of a loop or hardcode the values into the sql query everything works perfectly. According to this page it is suggested to use bindValue instead.…
kojow7
  • 10,308
  • 17
  • 80
  • 135
0
votes
0 answers

PDO binding multiples strings using bindParam() and an IN() condition

The trouble I am having is that I am getting no response when I try to pass the variable binded into the query (stored in a variable $searchString). The variable $searchString = 'extreme', 'water' My PDO/MySQL statement: $sql = "SELECT * …
Lachie
  • 1,321
  • 1
  • 10
  • 26