php - Select statement PDO error SQLSTATE[42000]: Syntax error or access violation: 1064 -


this question has answer here:

$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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -