Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 2nd, 2010, 10:06 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old January 2nd, 2010, 06:59 PM
Authorized User
 
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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..
Reply With Quote
  #3 (permalink)  
Old January 3rd, 2010, 05:40 PM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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..
Reply With Quote
  #4 (permalink)  
Old January 3rd, 2010, 07:13 PM
Authorized User
 
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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..
Reply With Quote
  #5 (permalink)  
Old January 4th, 2010, 09:43 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Smile

Hi s.c.,

I got it this time!

Thanks so much for your help. I learned a lot!

cheers!

mel
Reply With Quote
  #6 (permalink)  
Old January 4th, 2010, 11:33 AM
Authorized User
 
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You're welcome.
Reply With Quote
  #7 (permalink)  
Old February 23rd, 2010, 06:09 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #8 (permalink)  
Old February 23rd, 2010, 11:08 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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';
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP/1.1 500 Internal Server Error Dmitriy General .NET 0 February 26th, 2008 04:50 PM
Http/1.1 500 Internal Server Error abinashpatra ASP.NET 1.0 and 1.1 Basics 17 May 10th, 2007 02:06 AM
HTTP 500: Internal Server Error cyberddindia Classic ASP Databases 4 October 5th, 2006 11:36 PM
HTTP 500 Internal Server Error hosefo81 Beginning PHP 3 October 22nd, 2003 08:24 PM



All times are GMT -4. The time now is 06:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.