PHP ignores my database host address

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cypher543
-


Joined: 12 Apr 2006
Posts: 1

PostPosted: Wed Apr 12, 2006 11:12 pm    Post subject: PHP ignores my database host address Reply with quote

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 View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed Apr 12, 2006 11:17 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Wed Apr 12, 2006 11:45 pm    Post subject: Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group