Page 1 of 1

Change server host

PostPosted: 25. August 2010 03:50
by unworthyslave
I would like to change an online application form which is written in PHP. Instead of changing it on my client's actual server I'm trying to do it on XAMMP so that their site is not affected. I set up XAMMP and everything installed and is running correctly on XP. I donwloaded all their files from the server and placed them the htdocs folder of XAMMP. I exported their databases using phpMyAdmin and imported to XAMMP's phpMyAdmin. However I keep getting this error and cannot get it resolved:

Code: Select all
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'db1618.perfora.net' (11004) in C:\Documents and Settings\Customer\My Documents\Test Servers\xampp\htdocs\includes\mysql.php on line 6


Here are lines 5-6 of mysql.php:
Code: Select all
  function connect($host, $user, $pass, $db) {
    $this->connection = mysql_connect($host, $user, $pass);
    mysql_select_db($db, $this->connection);
  }


I can't find a config file anywhere either.

Any help would be greatly appreciated!

Kind regards,
Nick

Re: Change server host

PostPosted: 25. August 2010 05:19
by Altrea
You don't need the connect-function itself, you need the place where the connect function is called!
If your Debugger don't trace the calls, you had to search on your own.

- Get an IDE, Editor or other Program which can search for text in files
- Serach for "db1618"

Re: Change server host

PostPosted: 25. August 2010 14:13
by JonB
C:\Documents and Settings\Customer\My Documents\Test Servers\xampp\htdocs\includes\mysql.php


does anyone notice a problem with this path?

I'm pretty sure I am right on this: PHP can't 'see' anything outside the DocumentRoot as its an Apache Module in XAMMP.

Good Luck
:)

Re: Change server host

PostPosted: 25. August 2010 15:11
by Altrea
JonB wrote:
C:\Documents and Settings\Customer\My Documents\Test Servers\xampp\htdocs\includes\mysql.php


does anyone notice a problem with this path?

I'm pretty sure I am right on this: PHP can't 'see' anything outside the DocumentRoot as its an Apache Module in XAMMP.

Good Luck
:)


Oh, wow :D I didn't see this before.
So maybe C:\Documents and Settings\Customer\My Documents\Test Servers\xampp\htdocs\ is his DocumentRoot?

Re: Change server host

PostPosted: 25. August 2010 16:56
by JonB
I donwloaded all their files from the server and placed them the htdocs folder of XAMMP


:idea: I think the include is outside the DocumentRoot - thus it fails

OR

Jeez I really don't know@@@

OR he installed XAMPP in My Documents????

:arrow: :shock: :shock: :shock: :shock: :?: :!:

Re: Change server host

PostPosted: 25. August 2010 18:51
by glitzi85
JonB wrote:
I donwloaded all their files from the server and placed them the htdocs folder of XAMMP


:idea: I think the include is outside the DocumentRoot - thus it fails

OR

Jeez I really don't know@@@

OR he installed XAMPP in My Documents????

:arrow: :shock: :shock: :shock: :shock: :?: :!:

It really looks like he installed XAMPP inside My Documents. Not a good idea, but the setup script should fix that.
DocumentRoot is the path defined in Apache as the lowest via HTTP accessible folder for the respective host/domain. However, PHPs include is NOT working in HTTP (at least not in this case). So also files outside the DocumentRoot are accessible unless you prevent PHP (open_basedir).

@unworthyslave: Could you please tell us what Script that is. Then we can tell you where the configuration file should be located.

glitzi

Re: Change server host

PostPosted: 25. August 2010 18:54
by unworthyslave
Yes, I'm on the laptop now but I'll be able to let you guys know in less than 30 minutes.

Re: Change server host

PostPosted: 25. August 2010 19:12
by unworthyslave
OK so I DID initially install xampp in the "My Documents" HOWEVER the xammp setup command prompt redirects the paths.

@glitzi85 What script? The mysql.php? It is located in the includes folder at C:\Documents and Settings\Customer\My Documents\Test Servers\xampp\htdocs\includes\mysql.php

Here is the mysql.php
Code: Select all
<?php
class mysql {
  var $connection;

  function connect($host, $user, $pass, $db) {
    $this->connection = mysql_connect($host, $user, $pass);
    mysql_select_db($db, $this->connection);
  }

  function query($query) {
    return mysql_query($query, $this->connection);
  }

  function object($resource) { // return an object
    return mysql_fetch_object($resource);
  }

  function associative($resource) { // return an associative array
    return mysql_fetch_assoc($resource);
  }

  function numeric($resource) { // return a numeric array
    return mysql_fetch_row($resource);
  }

  function rows($resource) { // count the number of rows returned
    return mysql_num_rows($resource);
  }

  function string($variable) { // prevent any sql injection
    if (!get_magic_quotes_gpc()) {$variable = mysql_real_escape_string($variable);}
    //$variable = mysql_real_escape_string($variable);
    return $variable;
  }

  function free($resource){
    mysql_free_result($resource);
  }

  function close() {
    mysql_close($this->connection);
  }
}
?>

Re: Change server host

PostPosted: 25. August 2010 19:21
by glitzi85
Did you program that application by yourself? If yes, then you have to know where the configuration is. If not, please tell me the name of the application you are trying to change.

glitzi

Re: Change server host

PostPosted: 25. August 2010 19:26
by BigWetDog
I'd like to ask, upon requesting what page was the original error generated?

Re: Change server host

PostPosted: 25. August 2010 20:54
by unworthyslave
No, someone else programmed it. There is no name as far as I know. It is custom built. It is for applying online for college.

It was generated on: https://localhost

p.s. This forum is awesome! It's good to find a forum where several people actually contribute :D

Re: Change server host

PostPosted: 25. August 2010 22:11
by BigWetDog
I would then check your index.php page (which must include mysql.php) and all the files it includes (listed before it in index.php) for the $host, $user, $pass, $db values.
It basically goes back to altrea's comment, When connect($host, $user, $pass, $db) is called the values that are set somewhere prior to this call are what you are looking for. So do a search for the string 'db1618.perfora.net'

Re: Change server host

PostPosted: 26. August 2010 00:49
by unworthyslave
Ok I found it, changed it, and it's working now :)

I really appreciate your help guys!