Change server host

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Change server host

Postby unworthyslave » 25. August 2010 03:50

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
unworthyslave
 
Posts: 5
Joined: 25. August 2010 03:11

Re: Change server host

Postby Altrea » 25. August 2010 05:19

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"
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Change server host

Postby JonB » 25. August 2010 14:13

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
:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Change server host

Postby Altrea » 25. August 2010 15:11

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?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Change server host

Postby JonB » 25. August 2010 16:56

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: :?: :!:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Change server host

Postby glitzi85 » 25. August 2010 18:51

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
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Change server host

Postby unworthyslave » 25. August 2010 18:54

Yes, I'm on the laptop now but I'll be able to let you guys know in less than 30 minutes.
unworthyslave
 
Posts: 5
Joined: 25. August 2010 03:11

Re: Change server host

Postby unworthyslave » 25. August 2010 19:12

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);
  }
}
?>
unworthyslave
 
Posts: 5
Joined: 25. August 2010 03:11

Re: Change server host

Postby glitzi85 » 25. August 2010 19:21

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
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Change server host

Postby BigWetDog » 25. August 2010 19:26

I'd like to ask, upon requesting what page was the original error generated?
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Change server host

Postby unworthyslave » 25. August 2010 20:54

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
unworthyslave
 
Posts: 5
Joined: 25. August 2010 03:11

Re: Change server host

Postby BigWetDog » 25. August 2010 22:11

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'
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Change server host

Postby unworthyslave » 26. August 2010 00:49

Ok I found it, changed it, and it's working now :)

I really appreciate your help guys!
unworthyslave
 
Posts: 5
Joined: 25. August 2010 03:11


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 84 guests