Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 1st, 2005, 6:43 PM   #1
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
PHP Help, Please look

<?php
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "userdb";

/*---------------------------------------------
Connect to MySQL with the above
credentials
----------------------------------------------*/
$db = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect to the MySQL server");
mysql_select_db($db_name);

?>




Ok, i have set my username and pass word correctly, but whn i trun the script i get the "Could not connect to MySQL server."

And Also, i have made the Databse named userdb, put the table in it and uploaded the sql code which was.-

CREATE TABLE `userdb` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
);




I dont know what could be wrong, doiesnt this create the table or do i still have to create that, please any help is apprecatied.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain

Destruction leads to a very rough road, but it also breeds creation.
bigguy is offline   Reply With Quote
Old Dec 1st, 2005, 9:14 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
A table and a database are two different things, a database is a collection of tables...

Your MySQL server isn't running at localhost, allowing connectsion from root@localhost in the users table in the MySQL databse , or there is some type of routing problem to it (hosts file || firewall).
__________________

tempest is offline   Reply With Quote
Old Dec 1st, 2005, 11:00 PM   #3
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
Yeah i got it worked out, Yahoo names their databses mysql instead of localhost, lol, I got it all sorted out go here so now it works. Thanks for the help.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain

Destruction leads to a very rough road, but it also breeds creation.
bigguy is offline   Reply With Quote
Old Dec 1st, 2005, 11:43 PM   #4
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by bigguy
Yeah i got it worked out, Yahoo names their databses mysql instead of localhost, lol, I got it all sorted out go here so now it works. Thanks for the help.
That doesn't exactly make sense on my end, but as long as you got it working I guess it's all good.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Dec 2nd, 2005, 11:53 PM   #5
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 218
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
Yea each host has their own way they deal with mysql. Most use host "localhost", others have different mysql hosts. I know godaddy has seperate mysql servers.

this just a suggestion, but change
or die("Could not connect to the MySQL server");

to
or die("Could not connect to the MySQL server- " . mysql_error());

I use mysql_error in all my database validation because it will print out the specific error returned by mysql. This way you'd know if it was connecting, or if the user information is wrong or what
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Old Dec 2nd, 2005, 11:55 PM   #6
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by Mocker
Yea each host has their own way they deal with mysql. Most use host "localhost", others have different mysql hosts. I know godaddy has seperate mysql servers.
I guess it was his wording that confused me. He said they don't name the databases localhost, I'm guessing he means the SQL server.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC