I am a beginner in php, and for a project I want to connect me with my database but the problem is :
I need 4 variables:
$serveurname
$username
$password
$databasename
When i do :
$link = new mysqli($servername,$username,$password)
There are two errors :
Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/ubuntu/workspace/index.php on line 21
and
Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/ubuntu/workspace/index.php on line 21
I think the problem is : serveurname information is bad but I don't know where can I find it on phpmyadmin?
On phpmyadmin i see :
MySQL
Serveur: info-arie.iut.bx1 via TCP/IP
Version du serveur: 5.5.43-0+deb7u1
Version du protocole: 10
Utilisateur: dfrances@info-morgane.iut.bx1
Jeu de caractères pour MySQL: UTF-8 Unicode (utf8)
but information (at right of the screen on phpmyadmin) seems bad because in my code I have :
$servername = "info-arie.iut.bx1";
$username = "dfrances@info-morgane.iut.bx1";
You can find phpmyadmin mysql connection info in file config.inc.php
inside the phpmyadmin folder. Find entries like the following and use it for your code.
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'someuser';
$cfg['Servers'][$i]['password'] = 'somepass';
根据错误消息,运行PHP脚本的主机无法联系数据库服务器。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.