Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php中的mysqli_connect通过http身份验证_Php_Mysql_Http_Authentication - Fatal编程技术网

使用php中的mysqli_connect通过http身份验证

使用php中的mysqli_connect通过http身份验证,php,mysql,http,authentication,Php,Mysql,Http,Authentication,当我试图访问sql数据库的远程服务器(没有本地主机)时,我遇到了一个小问题。通常情况下,我们需要通过http身份验证才能访问mysqladmin页面,但我还是设法用这行代码进入页面:http://user:password@site.net/mysqladm… 它是有效的。 我还为HTTP身份验证禁用了登录确认浏览器。 现在,当我想让它在我的php代码上工作时,它不工作。 在localhost中,它正在工作 这是我在代码上写的内容: mysqli_connect('http://httpuser

当我试图访问sql数据库的远程服务器(没有本地主机)时,我遇到了一个小问题。通常情况下,我们需要通过http身份验证才能访问mysqladmin页面,但我还是设法用这行代码进入页面:
http://user:password@site.net/mysqladm…
它是有效的。 我还为HTTP身份验证禁用了登录确认浏览器。 现在,当我想让它在我的php代码上工作时,它不工作。 在localhost中,它正在工作

这是我在代码上写的内容:

mysqli_connect('http://httpuser:httppassword@site.net/mysqladmin/index.php', 'root', 'password', 'db');
你对我的问题有什么意见吗

将MySQL数据库服务器的主机或IP地址作为第一个参数

而是传递一个http链接
site.net/mysqladmin/index.php
,它只是一个连接到已配置的MySQL服务器的管理后端。您需要确定后端连接到的MySQL服务器的IP。确保防火墙允许在您配置的端口上进行传入连接(默认值:3306)



您的服务器有权访问远程数据库吗?是的,服务器有权访问数据库:)看看@Jojo Hav的答案。这可能是你的解决方案。
<?php
    mysqli_connect('IP or host of the MySQL server', 'root', 'password', 'db');
?>