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

January 30th, 2010, 09:26 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 13
Thanks: 2
Thanked 1 Time in 1 Post
|
|
Chapter 3 Beg PHP6 etc..error statement
I have checked and double checked and cannot find the error. Here's the error message = Fatal error: Call to undefined function mysql_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\db_ch03-1.php on line 4
Here's the code for db_ch03-1.php (I get the same error on db_ch03-2.php)
Code:
<?php
//connect to MySQL
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass')
or die ('Unable to connect. Check your connection parameters.');
//create the main database if it doesn't already exist
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query, $db) or die(mysql_error($db));
//make sure our recently created database is the active one
mysql_select_db('moviesite', $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 INTEGER 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));
//create the people table
$query = 'CREATE TABLE people (
people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
people_fullname VARCHAR(255) NOT NULL,
people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (people_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
echo 'Movie database successfully created!';
?>
Last edited by drgnhiker; January 31st, 2010 at 03:25 PM..
|
|

January 31st, 2010, 05:36 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
|
|
Hi
Your code looks correct - this looks more like a setup issue with using PHP with MySQL.
Have you managed to connect to MySQL at all with PHP? If not, look back at the configuration steps in Chapter 1 and make sure you've done everything there, in particular page 11.
Phil
|
|

February 1st, 2010, 02:06 AM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 25
Thanks: 1
Thanked 4 Times in 4 Posts
|
|
I don't want to disagree with Phil's post. He knows more about it than I do.
But in the event that that doesn't work, you might try these alternatives:
1. Check out Nurul's post just above this, and find a package that does all of the AMP installations for you. Or,
2. Do like I did and just download Apache, MySql, and PHP individually paying close attention to the instructions for each. When I did this, a lot of my configuration issues went away. I particularly recommend the windows installer for PHP, and make sure you select MySql as an addition in the install wizard. I did this and it took care of all my initial configuration problems between PHP and MySql.
One word of warning, if you follow the instructions on page 11, be careful of the continuation on page 12. That is for PHP6 which hasn't been released yet. So following it exactly will lead to trouble.
BTW, don't be dismayed by the initial configuration issues. Everyone is having them. But once you get past it and get everything up and running together, the book is excellent from then on.
Best of luck,
Boz
|
|

February 1st, 2010, 01:43 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 13
Thanks: 2
Thanked 1 Time in 1 Post
|
|
Thanks
My thanks for the answers....glad to see it wasn't just me and my typing....and am going to reload and reconfigure this morning...thanks again
|
|

February 1st, 2010, 03:50 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 13
Thanks: 2
Thanked 1 Time in 1 Post
|
|
WAMPserver
worked beautifully.....took 5 minutes to clean up all the old stuff and 5 min to restart and get it done right.....this may be a good suggestion for the book.
Thanks
|
|
 |