Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 7th, 2012, 07:00 AM
Registered User
 
Join Date: May 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vickykumar
Default Chapter 3- Problem with this code

I have run following code on my desktop. But the output is blank.
Output page is showing nothing.

Please point out my error in this code.


Quote:
<?php
$db = mysql_connect('localhost', 'root', '') or die ('Unable to connect. Check your conneciton parameters.');
mysql_select_db('moviesite', $db) or die(mysql_error($db));

// select the movie titles and thier genre after 1990
$query = 'SELECT
movie_name, movie_type
FROM
movie
WHERE
movie_year > 1990
ORDER BY
movie_type';
$result = mysql_query($query, $db) or die(mysql_error($db));


// show the results as a foreach loop
while ($row = mysql_fetch_array($result))
{
foreach ($row as $value)
{
echo $value . ' ';
}
echo '<br>';
}
?>
 
Old May 7th, 2012, 09:16 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Does the database table 'movie' have any data in it? If it does not then you'll see nothing on the page as there is nothing to show...
 
Old May 7th, 2012, 09:38 AM
Registered User
 
Join Date: May 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vickykumar
Default

yes, table movie have all data in database.
But its show nothing when i run this code.
does i need any mysql setting?
 
Old May 7th, 2012, 04:03 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Try changing this:
Code:
while ($row = mysql_fetch_array($result))
to this:
Code:
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
or this:
Code:
while ($row = mysql_fetch_assoc($result))





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in Chapter 6 code example dannyR BOOK: Professional Test Driven Development with C#: Developing Real World Applications with TDD 3 December 21st, 2014 02:05 PM
chapter 18 code problem hennie7863 BOOK: Professional Microsoft SQL Server 2008 Integration Services ISBN: 978-0-470-24795-2 1 September 9th, 2010 03:33 PM
Problem with code on Chapter 14 aargyri BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 6th, 2006 03:37 PM
Problem with my code chapter 2 ojthecat BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 August 2nd, 2004 04:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.