 |
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 2nd, 2010, 10:06 AM
|
|
Registered User
|
|
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
chapter 3 page 89: HTTP 500 internal server error
Hi,
I run db_ch03-1.php and db_ch03-2.php from the browser but it returned HTTP 500 internal server error. I opened the log and this is the message
[Sat Jan 02 13:58:26 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/db_ch03-1
[Sat Jan 02 13:58:40 2010] [error] [client 127.0.0.1] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htdocs\\db_ch03-1.php on line 3
[Sat Jan 02 13:58:40 2010] [error] [client 127.0.0.1] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htdocs\\db_ch03-1.php on line 3
Please help!
I'm using localhost:8080 port, so I changed the code to:
$db = mysql_connect('localhost:8080', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
Is this right?
Following is my entire code for db_ch03-1.php:
<?php
//connect to MySQL
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
//make sure you're using the correct database
mysql_select_db('moviesite', $db) or die(mysql_error($db));
//insert data into the movie table
$query = '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)';
mysql_query($query, $db) or die(mysql_error($db));
//insert data into the movietype table
$query = '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")';
mysql_query($query, $db) or die(mysql_error($db));
//insert data into the people table
$query = 'INSERT INTO people
(people_id, people_fullname, people_isactor, people_isdirector)
VALUES
(1, "Jim Carey", 1, 0),
(2, "Tom Shadyac", 0, 1),
(3, "Lawrence Kasdan", 0, 1),
(4, "Kevin Kline", 1, 0),
(5, "Ron Livingstone", 1, 0),
(6, "Mike Judge", 0, 1)';
mysql_query($query, $db) or die(mysql_error($db));
echo 'Data inserted successfully!';
?>
Thanks very much
mel
|
|

January 2nd, 2010, 06:59 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Hi Mel,
You reference localhost:8080, is this for Apache or MySQL?
Assuming port 8080 is for Apache, and MySQL is installed on the same machine listening on the default port:
This should be the correct syntax:
Code:
//connect to MySQL
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
mysql_connect('localhost' = location of the MySQL server. If you have MySQL installed elsewhere, 'localhost' needs to be changed to reflect the location. i.e. mysql_connect('192.168.1.100', or mysql_connect('mysql-svr.sampledomain.com',
Did you save db_ch03-1.php to the following directory?
C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/
According to this entry in the log, Apache could not find the file...
[Sat Jan 02 13:58:26 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/db_ch03-1
Finally, still using the assumption that Apache is listening on port 8080, when you open your web browser, are you using this url?
-http://localhost:8080/db_ch03-1.php
Hope this helps...
Last edited by s.c.; January 2nd, 2010 at 07:04 PM..
|
|

January 3rd, 2010, 05:40 PM
|
|
Registered User
|
|
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi s.c.,
I appreciate your response to my post.
Yes, localhost:8080 is for Apache. MySQL is installed on the same machine listening on the default port.
Yes, I saved the file in the directory:
C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/
I did the correct syntax as you suggested:
Code:
//connect to MySQL
$db = mysql_connect('localhost', 'bp6am', 'bp6ampass') or
die ('Unable to connect. Check your connection parameters.');
Yes, when I open my browser I use this URL :
http://localhost:8080/db_ch03-1.php
The message now from the browser is:
Unable to connect. Check your connection parameters.
What do you think seems to be the problem?
Please help.
Thanks so much.
mel
Last edited by igtoroy; January 3rd, 2010 at 05:43 PM..
|
|

January 3rd, 2010, 07:13 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Hi Mel,
Quote:
The message now from the browser is:
Unable to connect. Check your connection parameters.
|
This states that the connection to MySQL failed and therefore called this part of the code:
"die ('Unable to connect. Check your connection parameters.');"
This could be due to a couple of reasons:
1. Is MySQL running?
2. Have you created the user bp6am with the password bp6ampass in
MySQL?
Please refer to pages 15-17...
I would suggest logging into the MySQL console, then use the "SELECT user, host FROM mysql.user;" command.
This will confirm both 1 & 2 above. The console will not start if MySQL is not running and the output will tell you if the user has been added.
If the user bp6am is not listed:
Code:
GRANT ALL *.*
TO bp6am@localhost
IDENTIFIED BY "bp6ampass";
You will want to use GRANT ALL instead of (SELECT, INSERT, UPDATE) for now, otherwise in one of the later scripts user bp6am will not have the proper access.
When you learn more about MySQL, you will want to try modifying the access for the user.
Hang in there and Good luck!
Last edited by s.c.; January 3rd, 2010 at 07:18 PM..
|
|

January 4th, 2010, 09:43 AM
|
|
Registered User
|
|
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi s.c.,
I got it this time!
Thanks so much for your help. I learned a lot!
cheers!
mel
|
|

January 4th, 2010, 11:33 AM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
You're welcome. 
|
|

February 23rd, 2010, 06:09 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi,
i faced an error when i try the following code in mysql console:
Code:
grant all *.*
to bp6am@localhost
identified by "bp6ampass";
it stated that:
error 1064<42000>:you have an error in yout sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near 'to bp6am@localhost identified by "by6ampass" at line 1.
**remark** i am currently using a wamp server 2.0 which mysql version is 5.1.36
anyone can help me, i am a newbie & have no idea how to make the code works. thnks
|
|

February 23rd, 2010, 11:08 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i have found the solution.
i just create a user at 1st, & followed by grant the user privileges, then the codes can be run.
create a user:
Code:
create user 'bp6am'@'localhost'
identified by 'bp6ampass';
grant all priviledges on *.*
to 'bp6am'@'localhost'
identified by 'bp6ampass';
|
|
 |