php - Select statement PDO error SQLSTATE[42000]: Syntax error or access violation: 1064 -
this question has answer here:
- reference - asked questions pdo 3 answers
$orderby = 'title'; $order = 'asc'; $stmt = $conn->prepare('select f.id, title, description, release_year, first_name, last_name film f, film_actor fa join actor fa.actor_id = a.actor_id , fa.film_id = f.film_id order :orderby :order limit :limit'); $stmt->execute( array( 'order'=>$order, 'orderby'=>$orderby, 'limit'=>$limit ) );
i'm getting error described in title when trying run query. i've tried find way debug output failed. i'll appreciate help. ps: i'm learning sql using pdo in php.
thanks in advance.
you forgot :
here
array( 'order'=>$order, 'orderby'=>$orderby, 'limit'=>$limit )
should be
array( ':order'=>$order, ':orderby'=>$orderby, ':limit'=>$limit )
Comments
Post a Comment