douxu4610 2014-07-27 19:25
浏览 21
已采纳

使用在线PHP文件设置对DB的本地调用 - 连接时出现问题

Trying to figure out how to connect to a local SQL Server with an online PHP file. However I am getting connection errors.

Warning: mysql_connect() [function.mysql-connect]: [2002] No connection could be made because the target machine actively refused it. (trying to connect via tcp://localhost:xxxx) in E:\web\example.com\uploadseadDB.php on line 8

In particular I am having trouble trying to specify if, and where, I do the connection to the PC and then to the database with any associated passwords.

My current connection looks like this

 mysql_connect("localhost","the_sql_server_name\SQLEXPRESS","mysql"); 
 mysql_select_db("ACME") or die(mysql_error()); 
 $data = mysql_query("SELECT * FROM TradingAccount") 
 or die(mysql_error()); 

My server is run locally (sql server studio management 2012), and I am trying to connect to its specific DB called ACME, from the table TradingAccount.

Can someone show me how to connect to this local table successfully with PHP? I use Windows Authentication at the moment when I run the server as well, in case that matters.

I haven't been able to find any useful resources, and I have only ever used PHP to connect to online DB's as well, nothing locally before.

  • 写回答

1条回答 默认 最新

  • dsh125986083 2014-07-27 19:33
    关注

    Your Problem is in this line:

    mysql_connect("localhost","the_sql_server_name\SQLEXPRESS","mysql"); 
    

    You wrote the_sql_server_name\SQLEXPRESS there. I don't understand why. The syntax of the method is:

    mysql_connect("hostname", "username", "password");
    

    For more information, visit the PHP manual entry for mysql_connect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样