PHP/MYSQL Configuration help
First post. I apoligize if this has been answere before please feel free to provide me with the link.
On page 87 of the book where I did this:
<?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!';
?>
I got the error:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\db_ch03-1.php on line 3
When I ran it. I followed all the instructions on the book from page one. But I hit a DEAD END here. Please HELP!
I will appreciate everything. THANK YOU!
|