-5

i have a pdo statement for select all rows for row count.... i keep getting this error "Call to member function execute() on Boolean" ...i have tripple checked my statement and database table but cant find anything wrong

$stmt = $connection->prepare("SELECT * FROM users_profile WHERE email=:email");
            var_dump($connection->error);
            $stmt->execute(":email",$email);
            $count = $stmt->rowCount();

Var dump error says there is a syntax error here " :email" ..but i cant seem to see it...and its doing this through out my PDO code

codex
  • 1
  • 5
  • There is no `PDOStatement::error` (that's `mysqli_`, not PDO), it's `PDOStatement::errorInfo()`. And you'd get a syntax-error with the placeholder `:email` if you're using `mysqli_` as the connection. So that begs the question - what are you connecting with? – Qirel Nov 24 '16 at 17:16
  • @Qirel which is what I wrote/asked similarly earlier but they just upped and left the question so I said to myself: *"Pfffft..., fine."* so I deleted my comment. – Funk Forty Niner Nov 24 '16 at 17:18
  • 1
    Possible duplicate of [Can I mix MySQL APIs in PHP?](http://stackoverflow.com/questions/17498216/can-i-mix-mysql-apis-in-php) – Funk Forty Niner Nov 24 '16 at 17:19
  • ^ I voted to soon. Had I know that from that comment below, I would have closed this. – Funk Forty Niner Nov 24 '16 at 17:19

1 Answers1

2

The execute function of PDO expect to get array of parameters

public bool PDOStatement::execute ([ array $input_parameters ] )

This is how you should use it in your code:

$stmt->execute( [":email" => $email] );
Dekel
  • 60,707
  • 10
  • 101
  • 129
  • thanks but its not working...i even tried a different binding syntax "bind_param (":email",$email") " but still it says the error is in the statement – codex Nov 24 '16 at 17:18
  • without the error you get it's impossible to help – Dekel Nov 24 '16 at 17:19
  • `bind_param` gave it away, you're connecting with `mysqli_connect()` aren't you? @codex – Qirel Nov 24 '16 at 17:19
  • @Derek ooow yes how could i be blind sided...you right Derek it worked...changed the db connection to PDO thanks again – codex Nov 24 '16 at 17:50