Help with PHP to mysql connection.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
onedollartotown
Forum Newbie
Posts: 1
Joined: Wed Sep 17, 2008 10:28 pm

Help with PHP to mysql connection.

Post by onedollartotown »

Hi Guys,

I need help on connecting my php website to the mysql database. My mysql database is located on my webhosting server.

First I need to sftp(login) to my web server, followed by ssh(login) to my database server, the ip is 192.168.XXX.XXX. This database is located in /home/mywebsite/

The question is how do I code my php so that I can connect to my server. I cannot get it to work with localhost nor using the ip. The error I get is "Unable to connect to MySQL".

Help greatly appreciated. If I have missed any useful information do let me know.

Thanks,
John
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: Help with PHP to mysql connection.

Post by Bill H »

Code: Select all

 
$Host = "xxxxxx";               // server name
$User = "xxxxxx";              // database param
$Password = "xxxxxx";      // database param
$Link = mysql_connect($Host, $User, $Password);
 
You'll need to get the three parameters from youe webhost.
Post Reply