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

September 20th, 2009, 07:39 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

September 21st, 2009, 04:03 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Changed
I changed the password to 123456
|
|

September 21st, 2009, 04:57 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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..
|
|

September 27th, 2009, 03:58 AM
|
|
Registered User
|
|
Join Date: Aug 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |