Php Connecting To Database Error PHP connecting to database error
#1
Posted 23 July 2005 - 07:57 PM
// Hostname or ip of server
$servername="xxxxxxxxxx";
Here is the error I am getting:
Warning: mysql_connect(): Unknown MySQL Server Host 'xxxxxxxxxxxxx'
(1) in /home/xxxxxxx/public_html/sunshop/admin/db_mysql.php on line 44
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/xxxxxxx/public_html/sunshop/admin/db_mysql.php on line 49
Connect Failed: Cant make connection to database.
Error number: Unknown
Error description: None
Please ensure that the database and server is correctly configured and try again.
Any help would be appreciated.
Thanks
#2
Posted 23 July 2005 - 08:12 PM
Assuming you're running the shopping cart on a TCH-hosted account, the proper value for $servername is "localhost".
The Tweezer's Edge v3
#3
Posted 23 July 2005 - 08:22 PM
TCH-David, on Jul 23 2005, 09:12 PM, said:
Assuming you're running the shopping cart on a TCH-hosted account, the proper value for $servername is "localhost".
<{POST_SNAPBACK}>
Thanks for the suggestion, I tried that, too. I am supposed to be on server10. I
tried entering that and did not work either. Any other thoughts?
#4
Posted 23 July 2005 - 08:38 PM
1 - created the database
2 - created a user
3 -added the user to the database
Then to connect to the database in a script use:
host: localhost
database: yourCpanelName_databaseName
user: yourCpanelName_databaseUser
password: mypassword
* Note password is just as the password,
do not add the CpanelName to it.
Forum Moderator
TotalChoice Hosting, L.L.C.
Web Hosting by Total Choice Web Hosting - For Your Family - Web Hosting Family!
Any links or suggestions for third party software/sites should be used at your own risk.
My opinions and recommendations are not necessarily those of TCH and TCH is not responsible.
I am a Forum Moderator and a volunteer. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related questions. Should you need assistance in these areas, please contact our Help Desk.
treasure your pets
The Turtle says "A little knowledge is a dangerous thing,
so keep learning!"
#5
Posted 24 July 2005 - 03:13 PM
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum
I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.
#6
Posted 24 July 2005 - 03:26 PM
Forum Moderator
TotalChoice Hosting, L.L.C.
Any links or suggestions for third party software/sites should be used at your own risk. My opinions and recommendations are not necessary those of TCH and TCH is not responsible.
As a Forum Moderator I can assist in answering many of your hosting related questions. However, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.
Web Hosting by Total Choice Web Hosting - 24/7 Help Desk
#7
Posted 26 July 2005 - 08:54 PM
Thanks for all of the suggestions. I have tried everything I can think of. I will include what I can and see if anyone can make sense of it.
// Hostname or ip of server
$servername="localhost";
// Username and password to log onto db server
$dbusername="XXXXX"; I have tried the database & Cpanel username
$dbpassword="XXXXX"; I have tried the database & Cpanel password
// Name of database
$dbname="sunshop";
// Table prefixes. Do not change the value after the install has been finished!
//$dbprefix="ss_"; // Uncomment this line if this is a new install.
?>
I am getting this error message:
Connect Failed: Unexpected error from the database.
Error number:
Error description:
Please ensure that the database and server is correctly configured and try again
I deleted everything in the MySQL and started over. Any Ideas???
David
#8
Posted 26 July 2005 - 08:59 PM
Its a little unclear how you entered the information (and Don noted this all above)
dbusername would be cpanelusername_databaseusername
dbname would be cpanelusername_databasename
dbpassword would be JUST the password for the database
This post has been edited by GroovyFish: 26 July 2005 - 09:03 PM
#9
Posted 26 July 2005 - 09:35 PM
GroovyFish, on Jul 26 2005, 09:59 PM, said:
Its a little unclear how you entered the information (and Don noted this all above)
dbusername would be cpanelusername_databaseusername
dbname would be cpanelusername_databasename
dbpassword would be JUST the password for the database
<{POST_SNAPBACK}>
Thanks GroovyFish,
I did not combine the cpanel and datbase username & password. I will give that a try.
David
#11
Posted 26 July 2005 - 10:01 PM
Quote
David
<{POST_SNAPBACK}>
David,
I am sure you just typed that wrong, but to be sure, the database password is not a combination, its ONLY the database password. Only the database username and database name are combined with the cpanelusername.
Hope you get it working!
#12
Posted 28 July 2005 - 10:30 AM
I hope I can help. I assume you have a database already created...
In your CPanel, click MySQL Databases. (The attachment shows the lower part of the screen displayed.)
In the Users section, enter a username and password, then click Add User.
When the processing ends, go back to the same screen and select the User and DB from the drop down list (as shown at the top of this attachment), give all privs. For now, all privs is ok for testing, but you may want to change things later on.
Then your SQL code on your page should be something like:
$connection = mysql_pconnect("localhost","USERNAME","PASSWORD")
or die ("Couldn't connect to server.");
$db = mysql_select_db("DATABASE_NAME", $connection)
or die("Couldn't select database.");Ok, note: USERNAME must match the username exactly as it appeared in the drop down lists. It will look something like:
[account]_[usernameyouentered]
as will the DATABASE_NAME:
[account]_[databasename]
So for example:
USERNAME = myweb_cooluser
DATABASE_NAME = myweb_niftydb
I hope this helps some.
They say there is always 1 crazy person on the bus.
I have never met that crazy person.
#13
Posted 28 July 2005 - 08:34 PM
erisande, on Jul 28 2005, 11:30 AM, said:
I hope I can help. I assume you have a database already created...
In your CPanel, click MySQL Databases. (The attachment shows the lower part of the screen displayed.)
In the Users section, enter a username and password, then click Add User.
When the processing ends, go back to the same screen and select the User and DB from the drop down list (as shown at the top of this attachment), give all privs. For now, all privs is ok for testing, but you may want to change things later on.
Then your SQL code on your page should be something like:
$connection = mysql_pconnect("localhost","USERNAME","PASSWORD")
or die ("Couldn't connect to server.");
$db = mysql_select_db("DATABASE_NAME", $connection)
or die("Couldn't select database.");Ok, note: USERNAME must match the username exactly as it appeared in the drop down lists. It will look something like:
[account]_[usernameyouentered]
as will the DATABASE_NAME:
[account]_[databasename]
So for example:
USERNAME = myweb_cooluser
DATABASE_NAME = myweb_niftydb
I hope this helps some.
<{POST_SNAPBACK}>
Thank you for your input. I tried deleating everything and starting over. I still get to the same place. I will give it one more try.
#14
Posted 28 July 2005 - 09:06 PM
Forum Moderator
TotalChoice Hosting, L.L.C.
Web Hosting by Total Choice Web Hosting - For Your Family - Web Hosting Family!
Any links or suggestions for third party software/sites should be used at your own risk.
My opinions and recommendations are not necessarily those of TCH and TCH is not responsible.
I am a Forum Moderator and a volunteer. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related questions. Should you need assistance in these areas, please contact our Help Desk.
treasure your pets
The Turtle says "A little knowledge is a dangerous thing,
so keep learning!"
#15
Posted 28 July 2005 - 11:04 PM
#17
Posted 29 July 2005 - 01:07 AM
Forum Moderator
TotalChoice Hosting, L.L.C.
Web Hosting by Total Choice Web Hosting - For Your Family - Web Hosting Family!
Any links or suggestions for third party software/sites should be used at your own risk.
My opinions and recommendations are not necessarily those of TCH and TCH is not responsible.
I am a Forum Moderator and a volunteer. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related questions. Should you need assistance in these areas, please contact our Help Desk.
treasure your pets
The Turtle says "A little knowledge is a dangerous thing,
so keep learning!"

Help













