Home get results of query using prepared statements mysqli
Reply: 0

get results of query using prepared statements mysqli

user699
1#
user699 Published in August 15, 2018, 9:02 am

I would like to get the results of a query using prepared statements but I don't get anything.

The problem is I'm not able to fetch my results. Can some one show an example how to get results of query using prepared statements?

Here is my code:

    $sql = "SELECT `username` FROM `usrs` WHERE `username` = ? ";
    $statement = $this->conn->prepare($sql);

    if (!statement)
    {
        throw new Exception($statement->error);
    }

    $statement->bind_param("s",$username);
    $statement->execute();
    $statement->bind_result($user);
    while ($statement->fetch()) 
    {
        printf("%s", $user);
    }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.335271 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO