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 PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 20th, 2009, 07:39 PM
Registered User
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 87

Ok so I am having the same problem as the poster below me

Here is the error i am getting
Quote:
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 'INTERGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_t' at line 7
the code is
Code:
<?php
//database creation and connection.
//connect to the database
$db = mysql_connect('moviesite.mattanders.com', 'bp6amm', 'bp6ampass')or die ('Unable to connect. Check your connection parameters.');

// creates the database if it is not there 
$query = 'CREATE DATABASE IF NOT EXISTS mattanders_movies';
mysql_query($query, $db) or die(mysql_error($db));// these mysql_ variables are inherent to mysql. though it is also being supplied the die variable from the $db variable

//make sure tthe created database is the active one 
mysql_select_db('mattanders_movies', $db) or die(mysql_error($db));

//create the movie table
$query = 'CREATE TABLE movie (movie_id		INTEGER UNSIGNED	NOT NULL AUTO_INCREMENT,
		movie_name  	VARCHAR(255)     	NOT NULL,
		movie_type		TINYINT			 	NOT NULL DEFAULT 0,
		movie_year 		SMALLINT UNSIGNED	NOT NULL DEFAULT 0,
		movie_leadactor	INTEGER UNSIGNED	NOT NULL DEFAULT 0,
		movie_director	INTERGER UNSIGNED	NOT NULL DEFAULT 0,
		
		PRIMARY KEY (movie_id),
		KEY movie_type (movie_type, movie_year)
		)
		ENGINE=MyISAM';
	mysql_query($query, $db)
 or die (mysql_error($db));
 
 // create the movietype table
 $query = 'CREATE TABLE movietype (
 		 movietype_id 	TINYINT UNSIGNED	NOT NULL AUTO_INCREMENT,
		 movietype_label	VARCHAR(100)	NOT NULL,
		 PRIMARY KEY (movietype_id)
	)
	ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));

echo 'Movie database successfully created!';
?>
Whats wrong?

According to the code editor im using that section of code is on line 14.

Last edited by Golarin; September 20th, 2009 at 07:45 PM.. Reason: question
Reply With Quote
  #2 (permalink)  
Old September 21st, 2009, 04:03 PM
Registered User
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changed

I changed the password to 123456
Reply With Quote
  #3 (permalink)  
Old September 21st, 2009, 04:57 PM
Registered User
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well i fixed this error, but now i am having a problem with

Code:
<?php
$db = mysql_connect('moviesite.mattanders.com', 'bp6amm', '123456') or die('Unable to connect. Check your connection parameters.');
mysql_select_db('mattanders_movies', $db) or die(mysql_error($db));

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

// Show the results
echo '<table border="1">';
while ($row = mysql_fetch_assoc($result)) {
	echo '<tr>';
	foreach ($row as $value) {
	    echo '<td>' . $value . '</td>';
	}
	echo '</tr>';
}
echo '</table>';
?>
Nothing shows on the page when i try running it... so i think i messed something up


And i tried it with the code from the book and still got nothing to show on my page

Last edited by Golarin; September 21st, 2009 at 05:00 PM..
Reply With Quote
  #4 (permalink)  
Old September 27th, 2009, 03:58 AM
Registered User
 
Join Date: Aug 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hmmm... according to the problem u state:
Quote:
Nothing shows on the page when i try running it....
This means the browser catch no ERROR on your code? so it might be your DB value which is blank, or your the problem lies with the ECHOs.

To check the Database you can chk with MySQL Query Browser on page:102 they give tips abt it.

for the problem on the echos u might want to try alternatives way to echo out the results:

// Show the results
echo '<table border="1">';
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
extract ($row);
echo '<td>' . $movie_name . '</td>';
echo '<td>' . $movietype_label . '</td>';
echo '</tr>';
}
echo '</table>';
?>

but then again, if you can successfully complete page 96. it means your foreach to create table wasn't wrg.

Another thing you can check is your browser's settings.
Reply With Quote
Reply


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
AddModalErrors and AllCountries page 87 View Data Dictionary barnettrob BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 8 October 21st, 2009 08:07 PM
How to print a web page without title, URL, page #, date and time Mattt C# 2 July 17th, 2009 03:02 AM
Direct Child Selector Question - P86-87 MRoberts BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 May 22nd, 2005 04:48 PM



All times are GMT -4. The time now is 09:19 PM.


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