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 August 20th, 2004, 07:01 PM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Firedrill: Thanks very much for consolidating this process for everyone. It was extremely helpful and saved me quite a bit of frustration!
Quote:
quote:Originally posted by Firedrill
 <--mikep001 said-->
Use the command:
C:\>c:\mysql\bin\mysql mysql -h localhost -u root -p
<--End Quote-->

I was stuck with the ERROR 1044 until I read Mike's post and read through the mysql manual a couple times. Thanks Mike!

I installed MySQL 4_0_20d on my Windows 2000 machine using the corrected install command mentioned by ElizabethN. Thanks Elizabeth.

My install consisted of using the binary installation for windows and the default install location which is c:\mysql. Then I took the steps listed below:

1)Using the Command Prompt for windows (Start/Programs/Accessories/Command Prompt) I typed:
c:\>c:\mysql\bin\mysqld --install

2)To start the mysql server I typed:
c:\>NET START MySQL

3)Created a password (I used the password the book used for convenience. You can choose any password you want but you will have to remember to input your password instead of mysqlpass which is used for the examples in the book). I typed:
c:\>c:\mysql\bin\mysqladmin -u root password mysqlpass

4)Test your new password and login by typing:
c:\>c:\mysql\bin\mysql -h localhost -u root -p
You should see a line similar to:
Enter Password:
Type in your password and hit enter. Once you do this you should see the command prompt switch to mysql>

5)Take a look at your databases by entering the command:
mysql>show databases;
Don't forget the semi-colon at the end!

If you see the mysql and test databases you are good to go.
For more mysql commands, read through the mysql help (located in the Docs Folder -c:\mysql\docs)

Hope this helps save someone the time and trouble.
 
Old August 26th, 2004, 04:05 PM
Authorized User
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To: mikep001:

Again, I would like to thank you for your solution from 7/17/04:
Use the command:

C:\>c:\mysql\bin\mysql mysql -h localhost -u root -p

and press enter when prompted for the root password to access the database.

The authors seem to be assuming that the root username and password are not necessary until after you reset the users.

It worked...and now I can again proceed!

 
Old August 26th, 2004, 07:23 PM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default


saross,
Glad to be of help.
mikep001
 
Old August 26th, 2004, 09:23 PM
Authorized User
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, new problem. This is the error message I am now getting for createmovie.php:

     Can't create database 'wiley'. Database exists

The code follows:

<?php
$connect = mysql_connect("localhost", "root", "car1339") or
    die ("Hey dude, wake up and check your server connection.");

//create the main database
//this change per post of Elizabeth on another thread in the "Beginning PHP..."
//originally book stated:
//mysql_create_db("wiley") or die(mysql_error());
$query = mysql_query("CREATE DATABASE wiley")

    or die(mysql_error());

//make sure our recently created database is the active one

mysql_select_db ("wiley");

//create 'movie" table
$movie = "CREATE TABLE movie (
    movie_id int(11) NOT NULL auto_increment,
    movie_name varchar(255) NOT NULL,
    movie_type tinyint(2) NOT NULL default 0,
    movie_year int(4) NOT NULL default 0,
    movie_leadactor int(11) NOT NULL default 0,
    movie_director int(11) NOT NULL default 0,
    PRIMARY KEY (movie_id),
    KEY movie_type (movie_type,movie_year)
)
TYPE=MyISAM AUTO_INCREMENT=4 ";

$results = mysql_query($movie)
    or die (mysql_error());

//create "movietype" table

$movietype = "CREATE TABLE movietype (
    movietype_id int(11) NOT NULL auto_increment,
    movietype_label varchar(100) NOT NULL,
    PRIMARY KEY (movietype_id),
) TYPE=MyISAM AUTO_INCREMENT=9" ;

//create "people" table
$people = "CREATE TABLE people (
    people_id int(11) NOT NULL auto_increment,
    people_fullname varchar(255) NOT NULL,
    people_isactor tinyint(1) NOT NULL default 0,
    people_isdirector tinyint(1) NOT NULL default 0,
    PRIMARY KEY (people_id),
) TYPE=MyISAM AUTO_INCREMENT=7 ";

$results = mysql_query($people)
    or die (mysql_error());

echo "Movie Database successfully created";

?>



and for moviedata.php:

     Table 'wiley.movie' doesn't exist

The code also follows:

<?php
//connect to MySQL
$connect = mysql_connect("localhost", "root", "car1339") or
    die ("Hey dude, check your server connection");

//make sure we're using the right database

mysql_select_db ("wiley");

//insert data into "movie" table

$insert="INSERT INTO movie (movie_id, movie_name, movie_type, movie_year,

movie_leadactor, movie_director)
     VALUES (1,'Bruce Almighty',5, 2003, 1, 2),
    (2,'Office Space',5, 1999, 5, 6),
    (3,'Grand Canyon',2, 1991, 4, 3)";
$results = mysql_query($insert)
    or die(mysql_error());

//insert data into "movietype" table
$type="INSERT INTO movietype (movietype_id, movietype_label)
    VALUES (1, 'Sci Fi'),
    (2, 'Drama'),
    (3, 'Adventure'),
    (4, 'War'),
    (5, 'Comedy'),
    (6, 'Horror'),
    (7, 'Action'),
    (8, 'Kids')";
$results = mysql_query($type)
    or die(mysql_error());

//insert data into "people" table

$people="INSERT INTO people (people_id, people_fullname, people_isactor,

people_isdirector)
    VALUES (1, 'Jim Carrey', 1, 0),
    (2, 'Tom Shadyac', 0, 1),
    (3, 'Lawrence Kasdan', 1, 0),
    (4, 'Kevin Kline', 1, 0),
    (5, 'Ron Livingston', 1, 0),
    (5, 'Mike Judge', 0, 1)";
$results = mysql_query($people)
    or die(mysql_error());

echo "Data inserted successfully!";
?>

When I look at the db tables in the server I can see wiley is there...
what is happening...what do I do to correct this?
Many thanks in advance
steve

 
Old August 27th, 2004, 08:14 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just eliminate the lines that create the wiley database and you should be fine.


Christian

 
Old August 28th, 2004, 02:19 PM
Authorized User
 
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh boy...
I have gone through this code with a fine tooth comb...and here is the error I am generating now:

     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 ') TYPE=MyISAM AUTO_INCREMENT=7' at line 7

the applicable code follows:

mysql_select_db ("wiley");

//create 'movie" table
$movie = "CREATE TABLE movie (
    movie_id int(11) NOT NULL auto_increment,
    movie_name varchar(255) NOT NULL,
    movie_type tinyint(2) NOT NULL default 0,
    movie_year int(4) NOT NULL default 0,
    movie_leadactor int(11) NOT NULL default 0,
    movie_director int(11) NOT NULL default 0,
    PRIMARY KEY (movie_id),
    KEY movie_type (movie_type,movie_year)
) TYPE=MyISAM AUTO_INCREMENT=4 ";

$results = mysql_query($movie)
    or die (mysql_error());

//create "movietype" table

$movietype = "CREATE TABLE movietype (
    movietype_id int(11) NOT NULL auto_increment,
    movietype_label varchar(100) NOT NULL,
    PRIMARY KEY (movietype_id)
) TYPE=MyISAM AUTO_INCREMENT=9" ;

$results = mysql_query($movietype)
    or die(mysql_error());

//create "people" table
$people = "CREATE TABLE people (
    people_id int(11) NOT NULL auto_increment,
    people_fullname varchar(255) NOT NULL,
    people_isactor tinyint(1) NOT NULL default 0,
    people_isdirector tinyint(1) NOT NULL default 0,
    PRIMARY KEY (people_id)
) TYPE=MyISAM AUTO_INCREMENT=7";

$results = mysql_query($people)
    or die (mysql_error());

echo "Movie Database successfully created";

?>
I have gone over what the book says, and what I have entered is exactly as presented by the book, so why the error?
Again, thanks in advance,
Steve

 
Old August 30th, 2004, 03:21 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just run the code as you posted it and I did not have any problems. If you run this you shouldn't have any problem. Let me know if you do.
Code:
<?php
mysql_connect('username','password');
mysql_query("DROP DATABASE IF EXISTS wiley");
mysql_query("CREATE DATABASE wiley");
mysql_select_db ("wiley");

//create 'movie" table
$movie = "CREATE TABLE movie (
    movie_id int(11) NOT NULL auto_increment,
    movie_name varchar(255) NOT NULL,
    movie_type tinyint(2) NOT NULL default 0,
    movie_year int(4) NOT NULL default 0,
    movie_leadactor int(11) NOT NULL default 0,
    movie_director int(11) NOT NULL default 0,
    PRIMARY KEY (movie_id),
    KEY movie_type (movie_type,movie_year)
) TYPE=MyISAM AUTO_INCREMENT=4 ";

$results = mysql_query($movie)
    or die (mysql_error());

//create "movietype" table

$movietype = "CREATE TABLE movietype (
    movietype_id int(11) NOT NULL auto_increment,
    movietype_label varchar(100) NOT NULL,
    PRIMARY KEY (movietype_id)
) TYPE=MyISAM AUTO_INCREMENT=9" ;

$results = mysql_query($movietype)
    or die(mysql_error());

//create "people" table
$people = "CREATE TABLE people (
    people_id int(11) NOT NULL auto_increment,
    people_fullname varchar(255) NOT NULL,
    people_isactor tinyint(1) NOT NULL default 0,
    people_isdirector tinyint(1) NOT NULL default 0,
    PRIMARY KEY (people_id)
) TYPE=MyISAM AUTO_INCREMENT=7";

$results = mysql_query($people)
    or die (mysql_error());

echo "Movie Database successfully created";

?>
 
Old November 23rd, 2005, 10:05 AM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, Ive read the fixe to the "Error 1064" message it all sounds great if you can find the my.ini file, what happens if you dont have the my.ini file?

or have I missed something





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why not MySQL ??? mysticav BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 August 18th, 2006 04:32 PM
MySQL 5.0 dparsons MySQL 0 May 11th, 2006 08:32 AM
mysql help benzspida MySQL 1 April 6th, 2006 04:31 AM
MYSQL hkurtulus BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 November 23rd, 2005 05:59 PM
MySQL 4.0 or 4.1 allang MySQL 1 January 10th, 2004 10:12 AM





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