View previous topic :: View next topic |
Author |
Message |
cypher543 -
Joined: 12 Apr 2006 Posts: 1
|
Posted: Wed Apr 12, 2006 11:12 pm Post subject: PHP ignores my database host address |
|
|
I'm working on a new PHP script, so I am using Abyss as my test server. I have PHP working on it, but i can't connect to MySQL!
It completely ignores my host address in the "mysql_connect()" function and uses localhost instead. My database is hosted on another computer, however.
I've checked my PHP.INI file, but nothing looks out-of-the-ordinary.
Can some tell me what's going on? |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Wed Apr 12, 2006 11:17 pm Post subject: |
|
|
My best guess is that you would have had to install phpBB with the external server originally. I think the mysql_connect might be in another config file also. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Wed Apr 12, 2006 11:45 pm Post subject: |
|
|
Have you structured the mysql_connect properly?
http://uk2.php.net/manual/en/function.mysql-connect.php
Code: | mysql_connect(host, dbUsername, UserPassword, dbName, mysqlPort) or die("can not connect"); |
bellow is an example of how to implement this:
Quote: | //database connection information
$config['db']['user'] = "";
$config['db']['pass'] = "";
$config['db']['name'] = "";
$config['db']['host'] = "127.0.0.1";
$config['db']['port'] = "3306";
//connect to database
$connection = mysqli_connect($config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $config['db']['port'])
or die("error message, or include statment");
//site name
$sql = "you're sql query";
$result = mysqli_query($connection, $sql)
or die(include("dberror.html"));
//process $result bellow |
NB: the port entry is not required (unless you're MySQL install is on a non-standard port) I've included it for convenience. _________________ Olly |
|
Back to top |
|
 |
|