razorsese Posted March 30, 2012 Share Posted March 30, 2012 I can't figure what's wrong whit the following code: I get the following error: Undefined property: PDOStatement::$execute on line 26 public function getbyid($id) { $con = new PDO(DBN,DB_USER,DB_PASS); $sql = "SELECT * FROM articles WHERE id=:id"; $st = $con->prepare($sql); $st->bindValue(":id" , $id, PDO::PARAM_INT); $st->execute; $row=$st->fetch(); $con=null; if( $row ) return new Article ($row); } Quote Link to comment https://forums.phpfreaks.com/topic/260002-pdo-php/ Share on other sites More sharing options...
cpd Posted March 30, 2012 Share Posted March 30, 2012 Your not evaluating it as a function, your evaluating it as a variable (property). $st->execute; Should be $st->execute(); Quote Link to comment https://forums.phpfreaks.com/topic/260002-pdo-php/#findComment-1332652 Share on other sites More sharing options...
razorsese Posted March 30, 2012 Author Share Posted March 30, 2012 aaaaaaaaaaaaaaaaaaaaarGHHHHHHHHHHHHH!!!!1 thx! Quote Link to comment https://forums.phpfreaks.com/topic/260002-pdo-php/#findComment-1332662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.