douxia5179
2016-02-08 08:39
浏览 88
已采纳

在不同的端口上使用php连接到mysql数据库

my connection string is:

    $connection = mysql_connect("localhost", "root", "") or die("Could Not Connect to DB: ".mysql_error());

but on my computer i have installed IIS server first so localhost:80 is reserved by it so I changed my port to 8080 changing httpd.conf file in apache folder.

Now what should I change in connection string to connect to my database. I am using XAMPP .

should I tried writing these: 1:

  $connection = mysql_connect("localhost:8080", "root", "") or  die("Could Not Connect to DB: ".mysql_error());

2:

$connection = mysql_connect("localhost,8080", "root", "") or    die("Could Not Connect to DB: ".mysql_error());

But Not working Help please. Thank You

图片转代码服务由CSDN问答提供 功能建议

我的连接字符串是:

  $ connection = mysql_connect(  “localhost”,“root”,“”或死(“无法连接到DB:”。mysql_error()); 
   
 
 

但在我的计算机上 已经安装了IIS服务器,所以localhost:80是由它保留的所以我将端口更改为8080更改了apache文件夹中的httpd.conf文件。

现在我应该在连接字符串中更改什么来连接 我正在使用XAMPP。

我应该尝试编写这些文件: 1:

  $ connection = mysql_connect(“  localhost:8080“,”root“,”“或死(”无法连接到DB:“。mysql_error()); 
   
 
 

2:

  $ connection = mysql_connect(“localhost,8080”,“root”,“”)或die(“无法连接到DB:”。mysql_error()); 
 <  / code>  
 
 

但请不要帮助。 谢谢你

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzhong5902 2016-02-08 08:54
    已采纳

    Default port number which Mysql server uses is 3306 Web servers default port is 80

    Web server and Mysql server are independent.

    Do not change your api to connect to your mysql

    点赞 打赏 评论
  • duanqu9292 2016-02-08 09:06

    Why don't you try this: $connection=mysqli_connect('127.0.0.1','root','',database_name)or die('something');

    点赞 打赏 评论

相关推荐 更多相似问题