Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('includes/dbconnection.php');
- $data = 2;
- // Creating A Template
- $sql = "SELECT * FROM users WHERE user_id = ?";
- // Creating a prepared statement
- $stmt = mysqli_stmt_init($conn);
- // Prepare the prepared statement
- if(!mysqli_stmt_prepare($stmt, $sql)) {
- echo 'SQL Statement Failed';
- } else {
- //Bind parameters to the placeholder
- mysqli_stmt_bind_param($stmt, 's', $data);
- // Run Parameters inside database
- mysqli_stmt_execute($stmt);
- $result = mysqli_stmt_get_result($stmt);
- while($row = mysqli_fetch_assoc($result)) {
- echo $row['name'] . '<br />';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment