Php OOP how to use bind_param() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

13th Aug 2017, 9:28 PM
ibrahim danjuma
ibrahim danjuma - avatar
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
17th Nov 2017, 2:21 PM
Thomas Meejumlong
Thomas Meejumlong - avatar
0
Thanks Thomas just for answering
29th Nov 2017, 4:38 PM
ibrahim danjuma
ibrahim danjuma - avatar