TotalChoice Hosting Family Forums: Php Connecting To Database Error - TotalChoice Hosting Family Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Php Connecting To Database Error PHP connecting to database error

#1 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 23 July 2005 - 07:57 PM

I am trying to get my new shopping cart on line. I am hitting a wall. Below is the current error. I have tried my domain name, server and I.P address where it asks:

// 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 User is offline   TweezerMan Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 1,767
  • Joined: 26-September 04

Posted 23 July 2005 - 08:12 PM

Welcome to the forums, dchaffey! :thumbup1:

Assuming you're running the shopping cart on a TCH-hosted account, the proper value for $servername is "localhost".
David Phillips (TweezerMan)
The Tweezer's Edge v3

#3 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 23 July 2005 - 08:22 PM

TCH-David, on Jul 23 2005, 09:12 PM, said:

Welcome to the forums, dchaffey!  :thumbup1:

Assuming you're running the shopping cart on a TCH-hosted account, the proper value for $servername is "localhost".


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 User is offline   TCH-Don Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 11,679
  • Joined: 30-November 02

Posted 23 July 2005 - 08:38 PM

Be sure that in MySql you

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.
Don Rosenquist
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 User is online   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,247
  • Joined: 11-August 03

Posted 24 July 2005 - 03:13 PM

Welcome to the forums, dchaffey
Bruce Richards
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 User is offline   TCH-Thomas Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 15,277
  • Joined: 01-May 03

Posted 24 July 2005 - 03:26 PM

Welcome to the forum, dchaffey. :)
Thomas Jikrantz
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 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 26 July 2005 - 08:54 PM

Hi Guys,

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 User is offline   GroovyFish Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 695
  • Joined: 05-August 03

Posted 26 July 2005 - 08:59 PM

Are you sure you added the user to the database?

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 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 26 July 2005 - 09:35 PM

GroovyFish, on Jul 26 2005, 09:59 PM, said:

Are you sure you added the user to the database?

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



Thanks GroovyFish,

I did not combine the cpanel and datbase username & password. I will give that a try.

David

#10 User is offline   TCH-Rob Icon

  • Help Desk Manager
  • PipPipPipPip
  • Group: Members
  • Posts: 7,818
  • Joined: 11-March 03

Posted 26 July 2005 - 09:48 PM

Welcome to the forums, dchaffey

#11 User is offline   GroovyFish Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 695
  • Joined: 05-August 03

Posted 26 July 2005 - 10:01 PM

Quote

I did not combine the cpanel and datbase username & password. I will give that a try.
David


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 User is offline   erisande Icon

  • Distant Family
  • PipPipPip
  • Group: Members
  • Posts: 102
  • Joined: 06-February 04

Posted 28 July 2005 - 10:30 AM

Hello!

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 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 28 July 2005 - 08:34 PM

erisande, on Jul 28 2005, 11:30 AM, said:

Hello!

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.



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 User is offline   TCH-Don Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 11,679
  • Joined: 30-November 02

Posted 28 July 2005 - 09:06 PM

Please look at my post above and tell me at what point it does not work.
Don Rosenquist
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 User is offline   dchaffey Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 23-July 05

Posted 28 July 2005 - 11:04 PM

Thanks for all of your input. I pieced it all together from the input from you-all and re-ran everything. It is working!!!!!!!!

#16 User is offline   TCH-Rob Icon

  • Help Desk Manager
  • PipPipPipPip
  • Group: Members
  • Posts: 7,818
  • Joined: 11-March 03

Posted 28 July 2005 - 11:49 PM

Glad to see you got it going. :thumbup1:

#17 User is offline   TCH-Don Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 11,679
  • Joined: 30-November 02

Posted 29 July 2005 - 01:07 AM

:clapping: Glad to hear. :)
Don Rosenquist
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!"

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users