trying to limit a PDO Mysql query getting errors.

I want to limit this to 6 but every time I add LIMIT 6 at the end I get this error:

Parse error: syntax error, unexpected T_STRING in /var/www/html/beta/includes/index.php on line 38
It has something to do with the line:
                                                WHERE movie_actor.movie_id = ".$dbh->quote($movie_recent['movie_id'])

I was putting it  right after it but that breaks it.
<?
$movie_actor = $dbh->query("SELECT	act.actor_name
									FROM movie_actor
									LEFT JOIN actor act on act.actor_id = movie_actor.actor_id
									WHERE movie_actor.movie_id = ".$dbh->quote($movie_recent['movie_id'])
									
									);
?>

Open in new window

LVL 3
jbrashear72Asked:
Who is Participating?
 
lashamConnect With a Mentor Commented:
<?
$movie_actor = $dbh->query("SELECT      act.actor_name
                  FROM movie_actor
                  LEFT JOIN actor act on act.actor_id = movie_actor.actor_id
                  WHERE movie_actor.movie_id = ".$dbh->quote($movie_recent['movie_id']) . " LIMIT 0,6"
            
            );
?>
0
 
jbrashear72Author Commented:
It wasn't working till I tried:
<?
$movie_actor = $dbh->query("SELECT      act.actor_name
                  FROM movie_actor
                  LEFT JOIN actor act on act.actor_id = movie_actor.actor_id
                  WHERE movie_actor.movie_id = ".$dbh->quote($movie_recent['movie_id']) . " LIMIT 6"
           
            );
?>
0
 
lashamCommented:
What do you mean "It wasn't working till ...." ?

write what was the result?

1) " LIMIT 0,6 " -  it have to return result with first six rows
2) " LIMIT 6 "    - is the same as (1)


0
 
jbrashear72Author Commented:
It was not returning any records as if the 0    in 0,6 was only being read.

Very strange.
0
 
lashamCommented:
<?
$movie_actor = $dbh->query("SELECT      act.actor_name
                  FROM movie_actor
                  LEFT JOIN actor act on act.actor_id = movie_actor.actor_id
                  WHERE movie_actor.movie_id = ".$dbh->quote($movie_recent['movie_id']) . " LIMIT 1,6"
           
            );
?>

check this and check result again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.