problème connexion distante mysql, d'un autre domaine
22 messages • Page 1 sur 2 • 1, 2
Consultez la formation au référencement naturel Google de WebRankInfo / Ranking Metrics
problème connexion distante mysql, d'un autre domaine
j'ai 2 noms de domaines:
domaine1 et domaine2
- le 1er (domaine1) possède une bdd mysql et fonctionne correctement, la connexion passe très bien.
- le 2e (domaine2) ne possède pas de bdd et dois se connecter sur celle du 1er.
cependant le script de connexion ne passe pas quand la page est hébergée dans le hosting de domaine2:
$serveur = "mysql.netfirms.com";
$login_serv = "ulogin";
$pwd_serv = "68pwd";
mysql_connect ($serveur,$login_serv,$pwd_serv) or die ('ERREUR '.mysql_error());
mysql_close();
cependant ce script marche à partis de easyphp en local.
domaine1 et domaine2
- le 1er (domaine1) possède une bdd mysql et fonctionne correctement, la connexion passe très bien.
- le 2e (domaine2) ne possède pas de bdd et dois se connecter sur celle du 1er.
cependant le script de connexion ne passe pas quand la page est hébergée dans le hosting de domaine2:
$serveur = "mysql.netfirms.com";
$login_serv = "ulogin";
$pwd_serv = "68pwd";
mysql_connect ($serveur,$login_serv,$pwd_serv) or die ('ERREUR '.mysql_error());
mysql_close();
cependant ce script marche à partis de easyphp en local.
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '127.0.0.1' (13) in /mnt/w0508/d37/s15/b02f6f44/www/senlist.com/script-de-connexion-mysqlhost-netfirms.php on line 15
ERREUR Can't connect to MySQL server on '127.0.0.1' (13)
ERREUR Can't connect to MySQL server on '127.0.0.1' (13)
Attention si tu cherches à te connecter à une base mysql située sur un serveur distant. Tu dois autoriser sur ce serveur distant (mysql.netfirms.com) l'adresse IP de l'autre domaine à se connecter. En effet, mysql tourne par défaut en localhost et n'autorise que des connexion de celui-ci pour des raisons de sécurité.
aide que me propose mon hébergeur:
How do I connect to a mySQL database using PHP?
To connect to a database via PHP, you must be familiar with PHP scripting as well as MySQL commands.
Below is a sample program using PHP to interact with a MySQL database, which has been commented to explain each function (where username is the database username, password is the database password and and dbid is the database id for the database you wish to connect to):
<?
$hostname = "mysqlhost";
$username= "username";
$password= "password";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL
";
mysql_close($link);
?>
NOTE: The mysql password should be no more than 8 alpha-numeric characters. To identify the database username, password and dbid, click here for further instructions.
For remote connections:
<?
$hostname = "mysqlhost.netfirms.com:3306";
$username= "username";
$password= "password";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL
";
mysql_close($link);
?>
For remote connections where the database is residing on a different/separate Netfirms hosting account:
A. Identify the NF_MYSQL_HOST address for the account where the database resides:
1. Login to the Netfirms Members Control Panel at https://controlpanel.netfirms.com
2. Click Site Tools
3. Click Environment
4. Refer to the NF_MYSQL_HOST line entry and jot down the value indicate (eg. It will look similar to: NF_MYSQL_HOST=10.8.12.2:3306 but the IP address may be different for your acocunt)
B. Code your PHP script on the account that needs to make the remote database connection
1. The first line of your PHP script that will make a remote connection to your database residing on Netfirms should look similar to:
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
Below is a sample code:
<?
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
$hostname = "mysqlhost.netfirms.com:3306";
$username= "dbUsername";
$password= "dbPassword";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL";
mysql_close($link);
?>
How do I connect to a mySQL database using PHP?
To connect to a database via PHP, you must be familiar with PHP scripting as well as MySQL commands.
Below is a sample program using PHP to interact with a MySQL database, which has been commented to explain each function (where username is the database username, password is the database password and and dbid is the database id for the database you wish to connect to):
<?
$hostname = "mysqlhost";
$username= "username";
$password= "password";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL
";
mysql_close($link);
?>
NOTE: The mysql password should be no more than 8 alpha-numeric characters. To identify the database username, password and dbid, click here for further instructions.
For remote connections:
<?
$hostname = "mysqlhost.netfirms.com:3306";
$username= "username";
$password= "password";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL
";
mysql_close($link);
?>
For remote connections where the database is residing on a different/separate Netfirms hosting account:
A. Identify the NF_MYSQL_HOST address for the account where the database resides:
1. Login to the Netfirms Members Control Panel at https://controlpanel.netfirms.com
2. Click Site Tools
3. Click Environment
4. Refer to the NF_MYSQL_HOST line entry and jot down the value indicate (eg. It will look similar to: NF_MYSQL_HOST=10.8.12.2:3306 but the IP address may be different for your acocunt)
B. Code your PHP script on the account that needs to make the remote database connection
1. The first line of your PHP script that will make a remote connection to your database residing on Netfirms should look similar to:
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
Below is a sample code:
<?
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
$hostname = "mysqlhost.netfirms.com:3306";
$username= "dbUsername";
$password= "dbPassword";
$dbid="dbid";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL";
mysql_close($link);
?>
j'ai repris à l'identique le dernier script.
résultat :
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'u7....'@'cgihost' (using password: YES) in /mnt/w0508/d37/s15/b02f6f44/www/senlist.com/script-de-connexion-mysqlhost-netfirms.php on line 25
Connected to MySQL
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /mnt/w0508/d37/s15/b02f6f44/www/senlist.com/script-de-connexion-mysqlhost-netfirms.php on line 28
résultat :
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'u7....'@'cgihost' (using password: YES) in /mnt/w0508/d37/s15/b02f6f44/www/senlist.com/script-de-connexion-mysqlhost-netfirms.php on line 25
Connected to MySQL
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /mnt/w0508/d37/s15/b02f6f44/www/senlist.com/script-de-connexion-mysqlhost-netfirms.php on line 28
yes j'ai mis exactement :
<?php
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
$hostname = "mysqlhost.netfirms.com:3306";
$username= "u7.....";
$password= "...";
$dbid=".....";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL";
mysql_close($link);
?>
<?php
putenv("NF_MYSQL_HOST=10.8.12.2:3306");
$hostname = "mysqlhost.netfirms.com:3306";
$username= "u7.....";
$password= "...";
$dbid=".....";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die ("Unable to connect to MySQL");
print "Connected to MySQL";
mysql_close($link);
?>
22 messages • Page 1 sur 2 • 1, 2
Formation recommandée sur ce thème :
Formation Référencement naturel Google : apprenez une méthode efficace pour optimiser à fond le référencement naturel dans Google de façon durable... Formation animée par Olivier Duffez et Fabien Facériès, experts en référencement naturel.
Tous les détails sur le site Ranking Metrics : programme, prix, dates et lieux, inscription en ligne.
Lectures recommandées sur ce thème :
- Gestion des langues et des sessions en PHP / MySQL
- AdSense Tracking : statistiques détaillées sur les clics AdSense
- Comment éviter les contenus dupliqués (avec/sans le www)
- Honda va inclure Google Earth dans son système de navigation par satellite
- Comment éviter de se faire voler son nom de domaine...
- Le Netbook Google arrive ! Asus et Google Androïd...
- Domaine favori - URL canonique
- Google Apps Edition Premium : une suite bureautique en ligne professionnelle
- Passage à l'heure d'été/hiver sur un forum phpBB
- WebRankInfo lance un forum sur les noms de domaine
Consultez la description détaillée des produits ou services de Google suivants : Google Apps Edition Premium
- Les sous-domaines d'un site
Cet outil vous permet de trouver la liste des sous-domaines (indexés) d'un site.
Qui est en ligne
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités




le forum