I am working on exercise 3 of Chapter 3 on page 110 and am having some trouble. When I run the program I encounter the following error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 4"
The script looks something like this:
Code:
<?php
//connect to MySQL
$connect = mysql_connect("mysql", "username", "password")
or die("Hey loser, check your server connection.");
//make sure we're using the right database
mysql_select_db("moviesite");
$offset=$_REQUEST['offset'];
$query="SELECT movie_name, movie_year
FROM movie
ORDER BY movie_name
LIMIT $offset,1";
$results=mysql_query($query)
or die(mysql_error());
echo "<table>\n";
while ($rows=mysql_fetch_assoc($results)) {
echo "<tr>\n";
foreach($rows as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
echo "</tr><br />\n";
}
echo "</table>\n";
echo "<a href='page.php?offset=0'>Page1</a><br />";
echo "<a href='page.php?offset=1'>Page2</a><br />";
echo "<a href='page.php?offset=2'>Page3</a><br />";
?>
Perhaps someone can find the problem and help me out. Of course I changed the login information for this post. As a note... Everything else I have done up to this point has worked wonderfully.