Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 24th, 2008, 05:00 PM
Registered User
Join Date: Nov 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3, Page 110

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:
//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

$query="SELECT movie_name, movie_year
        FROM movie
        ORDER BY movie_name
        LIMIT $offset,1";
  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.
Reply With Quote
  #2 (permalink)   Spam!  
Old March 2nd, 2011, 10:06 AM
Posts: n/a
Lightbulb Solution Chapter 3 exercise 3

I solved the solution on the following way.
I first made a new page (try1.php) with code:
<a href='select2.php?offset=0'>Page 1 </a><br/>
<a href='select2.php?offset=1'>Page 2 </a><br/>
<a href='select2.php?offset=2'>Page 3 </a><br/>
and then the solution of exersice3 in the page select2:
//connect to MySQL
$connect =mysql_connect($host, $user, $pass) or 
	die ("Hey loser, check your server connection.");

//makes the database moviesite the active database.

//get our starting point for the query through the URL variable "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>";
while ($row = mysql_fetch_assoc($results)) {
	echo "<tr>";
	foreach ($row as $val) {
		echo "<td>";		
		echo $val;
		echo "</td>";
	echo "</tr><br/>";
echo "</table>";

echo "<a href='select2.php?offset=0'>Page 1 </a><br/>";
echo "<a href='select2.php?offset=1'>Page 2 </a><br/>";
echo "<a href='select2.php?offset=2'>Page 3 </a><br/>";

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 - page 212 asplundo BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 February 2nd, 2008 06:56 AM
Chapter 5 Page 151 angelojr BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 2 June 12th, 2007 08:15 AM
Chapter 7 Try It Out page 218 drumdiva BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 3 March 19th, 2007 08:35 PM
Chapter 5 page 151 aztek BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 July 27th, 2006 06:38 PM

All times are GMT -4. The time now is 12:59 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.