![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
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. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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).
__________________
|
|
|
|
|
|
#3 |
|
Professional Programmer
|
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. |
|
|
|
|
|
#4 | |
|
Professional Programmer
|
Quote:
|
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
|
#6 | |
|
Professional Programmer
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|