0
Php OOP how to use bind_param()
Apart from this ($stmt->bind_param) which i have used, using OOP how else can be done cos using the above gives an error message
2 Answers
0
When you want to use bind_param you need to add in your Statement a "?".
Then you add after that...
$stmt->bind_param(1, $your_variable);
(Which Parameter you want to Setup 1(First), 2(Second)... and the other one is the Variable or the Value you want to put in).
Example:
We have 3 Variables $username, $password, $email.
$stmt = $mysqli->prepare("INSERT INTO Users VALUES (?, ?, ?)");
$stmt->bind_param(1, $username);
$stmt->bind_param(2, $password);
$stmt->bind_param(3, $email);
or smaller:
$stmt = $mysqli->prepare("INSERT INTO Users VALUES (?, ?, ?)");
$stmt->bind_param('sss', $username, $password, $email);
"sss" stands for (String String String)
Example from http://php.net/manual/de/mysqli-stmt.bind-param.php
0
Thanks Thomas just for answering