-1

I already have made a lot of research before coming to ask for help here, but I seriously cannot handle the problem, so here it goes. So, I made my website with Dreamweaver and XAMPP and it's working fine, but I bought online hosting and already put my MySQL database online, and what I would like to do is stay with the website folder in my computer but get the data from database online where it is hosted.

My connection file is this one:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="false"
$hostname_valesilveira = "mysql.hostinger.pt";
$database_valesilveira = "database";
$username_valesilveira = "username";
$password_valesilveira = "password";
$valesilveira = mysql_pconnect($hostname_valesilveira, $username_valesilveira, $password_valesilveira) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

If I use the localhost as hostname it works pretty fine, but I would like to get the data at mysql.hostinger.pt and it doesn't work, gives this error:

Warning: mysql_pconnect(): in C:\xampp\htdocs\valesilveira\Connections\valesilveira.php on line 9

Warning: mysql_pconnect(): in C:\xampp\htdocs\valesilveira\Connections\valesilveira.php on line 9

Fatal error: php_network_getaddresses: getaddrinfo failed: No such host is known.
Bubletan
  • 3,833
  • 6
  • 25
  • 33
beruty
  • 1
  • `host mysql.hostinger.pt Host mysql.hostinger.pt not found: 3(NXDOMAIN)` -> your hostname is probably wrong – FuzzyTree May 01 '15 at 20:38
  • 1
    @FuzzyTree Gah. Didn't think of spelling mistakes... That's probably more likely than my answer hah. – Mike May 01 '15 at 20:40
  • i already have a website hosted there and hes using another database and the connection is to the same as this one mysql.hostinger.pt and its working pretty well, the website that its hosted is the http://www.hostinger.pt/ – beruty May 01 '15 at 20:41
  • Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 01 '15 at 21:04

1 Answers1

1

You are getting that error because, surprise surprise, No such host is known.

$ host mysql.hostinger.pt
Host mysql.hostinger.pt not found: 3(NXDOMAIN)

What this likely means is that your host manually added this domain name to their DNS records to point to a specific (probably internal) server. If you have shell access to the server try pinging and see what IP responds. If it is a local IP (i.e. starts with 10 or 192.168) you're out of luck. If not, try putting that IP address in the $hostname_valesilveira variable.

Mike
  • 23,542
  • 14
  • 76
  • 87
  • could you tell me how do i do that?! ping mysql.hostinger.pt where should i do that?! – beruty May 01 '15 at 20:50
  • You need command line access, so that would mean connecting using ssh for linux servers, or if you are hosted on a windows server, see [this question](http://serverfault.com/questions/429426/how-can-i-connect-to-a-windows-server-using-a-command-line-interface-cli) for how to execute commands remotely. – Mike May 01 '15 at 21:30
  • ah ok already have access to ssh and now what should i type?! ping mysql.hostinger.pt is not recognized command – beruty May 02 '15 at 00:44