+ 1

What's the problem?

What's the problem of the following question? ([sth]: marked as blank) $conn = new PDO("[mysql]:host=localhost;dbname=database", $username, $password); $sql = "SELECT * FROM `table` WHERE id = :id"; $stmt = $conn->prepare($sql); $stmt->bind[Value]("id", 1, PDO::PARAM_INT); $stmt->execute(); $result = $[stmt]->fetch([PDO]::FETCH_ASSOC); /** * @param array $result The result to be used */ Always decline due to the community downvotes. Note: Written in PHP.

13th Aug 2017, 5:39 PM
$machitgarha
$machitgarha - avatar
2 Respostas
+ 2
This line looks like it may have a typo $sql = "SELECT * FROM `table` WHERE id = :id"; Maybe you want something like this: $sql = "SELECT * FROM `table` WHERE id = " . $id . ";"
13th Aug 2017, 6:29 PM
S C
+ 1
@Sam No, it will bind using bindValue() method.
13th Aug 2017, 6:33 PM
$machitgarha
$machitgarha - avatar