MyBB Community Forums
[F] [Solved] Installation Script : DB Host value - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.2.3 (https://community.mybb.com/forum-51.html)
+------ Thread: [F] [Solved] Installation Script : DB Host value (/thread-19181.html)

Pages: 1 2


[F] [Solved] Installation Script : DB Host value - bollmann - 05-13-2007

There seems to be a problem in the install script, when I enter another value than 'localhost' in the DB Host field. Every time, I put an DNS value in the field, the script tells me, that the host cannot be reached.

I've written a short php script to prove, that the DB Hosts (I've tested 3 seperate hosts) are reachable - everyone can be reached from another host (so they are NOT bound to the 'localhost' interface only).

Here are some further Informations :

- The MySQL Hosts are reachable from outside - they are not bound to the 'localhost' interface only.
- I've tested 3 different MySQL hosts : 2 of my webspace providers and one I use for local evaluation and development in my LAN. Same result ...
- I've placed my test script (see below) on the same machine (webspace) as the installation script - the 2 DB servers of my web providers can
be reached from there (the one MySQL server in my LAN is not reachable from the internet).

I was also able to install several other BB Systems on the same Webspace / Database combination without any problems.

FYI : Here is the script, I've tested the connectivity with :

<?PHP

   $host = '<value>';
   $user = '<value>';
   $pass = '<value>';
   $db   = '<value>';
  

   $link = mysql_connect($host, $user, $pass);
   if (!$link) 
   {
      die('Could not connect: ' . mysql_error());
   }
   else
   {
      echo 'Connected to host \''.$host.'\' successfully<br>';
      
   
      $db_selected = mysql_select_db($db, $link);
      
      if (!$db_selected) 
      {
         die ('Can\'t use '.$db.' : ' . mysql_error());
      }
      else
      {
         echo 'Selected database \''.$db.'\' successfully';
      }
   
      mysql_close($link);
   
   }

?>

If you have any further questions - just let me know ...


RE: Installation Script : DB Host value - crsoft - 05-14-2007

well with my host its not localhost its a url and it works for me.


RE: Installation Script : DB Host value - bollmann - 05-14-2007

Found out, that my problem is related to the connection method (especially to the new_link parameter in the mysql_connect() function) :

./inc/db_mysql.php

	function connect($hostname="localhost", $username="root", $password="", $pconnect=0, $newlink=false)
	{
		if($pconnect)
		{
			$this->link = @mysql_pconnect($hostname, $username, $password) or $this->dberror();
		}
		else
		{
			$this->link = @mysql_connect($hostname, $username, $password, $newlink) or $this->dberror();
		}
		return $this->link;
	}

If I remove the $newlink parameter from the @mysql_connect() function, I can connect to the DB without problems.

./inc/db_mysql.php

			$this->link = @mysql_connect($hostname, $username, $password) or $this->dberror();

It works also, if I choose the @mysql_pconnect() function as the default connection type (simply change the $pconnect=0 to $pconnect=1)

./inc/db_mysql.php

	function connect($hostname="localhost", $username="root", $password="", $pconnect=1, $newlink=false)

Maybe there is a developer, who can have a look at this ?!?!?


RE: Installation Script : DB Host value - Ryan Gordon - 05-14-2007

Why would it be a problem with $newlink? http://us2.php.net/mysql_connect It should be fine.


RE: Installation Script : DB Host value - bollmann - 05-15-2007

Hi Tikitiki,

I agree - it should - but I had definitively (reproduceable) problems with that parameter.

I've solved my problems just with removing this parameter and everything seems to be fine for me since that time - but there is at least one other user who runs into the same problem (see this thread).

The only reason, I've posted here, is to report a (possible) bug and prevent other users to run into the same problem.


RE: Installation Script : DB Host value - Ryan Gordon - 05-15-2007

Wouldn't this be a bug that should be reported on bugs.php.net then?

BTW, it might be that it's a bug with your PHP/MySQL version. Which one's are you running?


RE: Installation Script : DB Host value - bollmann - 05-15-2007

Possible, that my version (or better the versions of my 2 web providers) are buggy.

Here are some details :

Provider 1
SunOS
MySQL 4.0.27
PHP 4.1.2

Provider 2
Linux
MySQL 4.1.19
PHP 4.4.4


RE: Installation Script : DB Host value - Ryan Gordon - 05-15-2007

Perhaps it would be wise to upgrade first, just to make sure it isn't a bug already fixed?


RE: Installation Script : DB Host value - bollmann - 05-15-2007

I've just seen, that the parameter 'new_link' is available since PHP version 4.2.0 - so provider 1 cannot work ...

I've tested the connectivity always from the webspace of provider 1 to DB's at both providers - never from the webspace of provider 2.

So I think, that the problem is a too old PHP version !!!


RE: Installation Script : DB Host value - bollmann - 05-15-2007

Ok - tested it once more from webspace of provider 2 and it works without problems ...

So - the problem is definitively the old PHP version.

I'm sorry ....