PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 31st, 2004, 09:08 AM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Connecting to MySQL is not showing up in php file

Okay, you all have probably got this question a million times, but I am a Newbie, sorry. When I try to create a database in MySQL via PHP, the browserpage to view it comes up so slow that it actually just sits there not coming up at all. The bar on the bottom of the browser go one bar every somany minutes and even after an hour, nothing changed. I use IE 6.0

I have EasyPHP installed and I went to PhpMyAdmin and the database was created. I set the password and host and user all to 'any' hoping that would work (I read that in another post) but it didn't work. I don't have an internal firewall installed. I am on a corporate network. I can view any php file I created in the browser using http://localhost/nameoffile.php and it works.

I am following the "Try It Out-Creating a Database" from Ch3 in the book "Using PHP with MySQL" and I have the complete script pasted from the book. It also seems strange that the database was created, the script just won't let me see that I did it. Any idea what I can do to fix it?

Thanks,

Patricia

Reply With Quote
  #2  
Old January 2nd, 2005, 12:01 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
The first step is to post a relevant and comprehensive portion of your code that is problematic, then we can take it from there.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old January 3rd, 2005, 08:22 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Find the source of the problem
do other PHP scripts work? ones without database connectivity? how about ones WITH database connectivity?

If yes, then it must be your script:
is your query correct? often a page will hang when its waiting for the database to return something.
it may be caused by an infinite loop.

If no, then it must be your server:
check any server logs. try rebooting the server... try reinstalling PHP... try reinstalling the server.

Reply With Quote
  #4  
Old January 3rd, 2005, 02:36 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The funny thing is everything works like a charm and the database is created. When doing pages to pull data from the database, then it also works. It just will not display the "Movie Database successfully created!"; instead it just hangs up. I also tried viewing it from within PHP Expert Editor and it just shows a blank page. In IE is shows the moving bar on the bottom but gets stuck after three bars. This is the code:
PHP Code:
<?php
//connect to MySQL; note we've used our own parameters- you should use
//your own for hostname, user, and password
$connect mysql_connect("localhost""root""")
or die (
"Sorry, please check your server connection.");
 
//create the main database
mysql_create_db("wiley")
or die(
mysql_error());
//make sure our recently created database is the active one
mysql_select_db ("wiley")
or die (
"Could not select database");
//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!";
?>

Reply With Quote
  #5  
Old January 3rd, 2005, 02:52 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
User overview

This is from phpMyAdmin:

User overview
User Host Password Global privileges Grant
Any % No ALL PRIVLEGES Yes
root localhost No ALL PRIVLEGES Yes

I hope that also helps.

Reply With Quote
  #6  
Old January 4th, 2005, 08:31 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
For the record, I suggest you password ALL accounts...
*especially* ones with external access (where host is %)

Also, *never* present your password [or lack of] to a forum...
Its just something to be cautious of, I see people do it all the time.

It's courteous, fun, and more readable if you post your code with [php][/php] tags surrounding it.

As for a possible solution... um... try putting echo messages after every query statement... or run the SQL statements directly on the database...

Reply With Quote
  #7  
Old January 4th, 2005, 09:34 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Try this:

comment out this section:
//mysql_create_db("wiley") or die(mysql_error());

create the database manually

now run the script... see if it creates the tables?

Reply With Quote
  #8  
Old January 5th, 2005, 02:52 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question It does create the tables ...

It does create the tables and will work with them afterwards. It just doesn't give me the "Movie Database successfully created!" at the end, instead, it hangs up. I realize this is strange...

Reply With Quote
  #9  
Old January 5th, 2005, 05:49 PM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
Faylaricia,
could you please edit post no. 4 (when logged in click on edit) and put the [ php ] [ /php ] tags around your php code, it adds syntax highlighting which is a quick way to spot some of the more common mistakes.
__________________
http://www.phptutorials.cjb.net. go on, give it a click!

Reply With Quote
  #10  
Old January 6th, 2005, 08:48 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
If it's hanging, it would have to be hanging on the line $results = mysql_query($people) or die(mysql_error());

but you're positive the PEOPLE table is being created?

Reply With Quote
  #11  
Old January 6th, 2005, 01:23 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by mattp23
Faylaricia,
could you please edit post no. 4 (when logged in click on edit) and put the [ php ] [ /php ] tags around your php code, it adds syntax highlighting which is a quick way to spot some of the more common mistakes.

Done. I wondered how everyone did it!

Reply With Quote
  #12  
Old January 6th, 2005, 01:25 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by MadCowDzz
If it's hanging, it would have to be hanging on the line $results = mysql_query($people) or die(mysql_error());

but you're positive the PEOPLE table is being created?

Yes, I have three tables: Movie, Movietype and People within wiley

Reply With Quote
  #13  
Old January 7th, 2005, 09:43 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
perhaps put a mysql_close() before your 'success' statement?
[this is usually not necessary as PHP will close it by default]

Try putting echo statements after each query call...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Connecting to MySQL is not showing up in php file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |