im trying to get the rows from database with mysqli prepare statments and display them in echo like <?php echo $username; ?>
but don't know how to get them , wasted 4 hours no success , help would be greate
php
<?php
include("secure/functions.php");
session_start();
$stmt = $mysqli->prepare("SELECT * FROM members WHERE username = ?");
$stmt->bind_param('s', $_SESSION['username']); // Bind "$username" to parameter.
$stmt->execute(); // Execute the prepared query.
$stmt->store_result();
if($stmt->num_rows == 1) {
$stmt->bind_result($id,$username); // get variables from result.
$stmt->fetch();
}
?>
You initially used $session_start();
where it should be session_start();
no dollar sign.
Try to check existence of session_start();
at begin of your script.
And, you can check which value sets to prepared statement - before binding of parameter $_SESSION['username']
, try to display this value with echo
or print
.