Home Prepared Statements Mysql not working
Reply: 0

Prepared Statements Mysql not working

user933 Published in May 25, 2018, 6:55 pm

I am trying to use prepared statements to select data from a table as the following. This method does not work.

    $sql = "SELECT * FROM `usrs` WHERE `username` = ? ";
    $statement = $this->conn->prepare($sql);
    if (!statement)
        throw new Exception($statement->error);
    $returnValue = $statement->execute();
    return $returnValue;

$sql should be in the following format.

$sql = "SELECT * FROM `usrs` WHERE `username` = 'username' ";

however the above code does not place single quotes ' ' around username

I need to place username between two single quotes ' ' as shown. if I use just

$sql = "SELECT * FROM `usrs` WHERE `username` = username "

it does not work.

any suggesstions how to do that.

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO