无法在IIS6下的php中形成套接字连接 [英] Unable to form socket connection in php under IIS6

查看:79
本文介绍了无法在IIS6下的php中形成套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在配置Windows Server 2003计算机来运行php。该系统目前正在运行IIS 6,并且正在托管几个活动网站。我能够运行php但是当我尝试连接到数据库时,我收到错误无法连接到MySQL:尝试对无法访问的主机进行套接字操作。



任何尝试创建套接字连接都会发生这种情况。我正在使用的代码在另一台服务器上工作,所以我知道我的代码中没有错误。



<?php 
$ debug = true;


函数dbPDOConnect($ dsn,$ dbName){
global $ db,$ debug;
$ db_usernameAdmin = *********;
$ db_passwordAdmin = **********;

if(!$ db)$ db = new PDO($ dsn。$ dbName,$ db_usernameAdmin,$ db_passwordAdmin);
if(!$ db){
返回0;
} else {
返回$ db;
}
}

函数connectPDO($ dsn,$ dbName){
global $ debug;

$ query = NULL;

try {
$ db = dbPDOConnect($ dsn,$ dbName);
if($ debug)print''< p>您已连接到数据库了!< / p>'';
} catch(PDOException $ e){
$ error_message = $ e-> getMessage();
if($ debug)print< p>连接数据库时出错:$ error_message< / p>;
}

}
connectPDO(''mysql:host = webdb.uvm.edu; dbname ='',''LTOPPER_CS148_Final'');

?>





我找不到有关此问题的任何信息。以前有人遇到过这个问题吗?我可以进行任何允许传出连接的更改吗?

解决方案

debug = true;


函数dbPDOConnect(


dsn,


dbName){
global

I am configuring a Windows Server 2003 machine to run php. The system is currently running IIS 6 and is hosting several active websites. I am able to get php to run but when I attempt to connect to a database I receive the error "Failed to connect to MySQL: A socket operation was attempted to an unreachable host. "

This happens with any attempt to create a socket connection. The code I am using works on another server, so I know there are no errors in my code.

<?php
$debug = true;

	
function dbPDOConnect($dsn, $dbName){
    global $db, $debug;
		$db_usernameAdmin = *********;
		$db_passwordAdmin = **********;
   
    if (!$db) $db = new PDO($dsn . $dbName, $db_usernameAdmin, $db_passwordAdmin); 
  if (!$db) {
    return 0;
  } else {
    return $db;
  }
} 

function connectPDO($dsn,$dbName){
		global $debug;		

		$query      = NULL;

try { 
  	  $db=dbPDOConnect($dsn, $dbName);
  	  if($debug) print ''<p>You are connected to the database!</p>'';
		} catch (PDOException $e) {
   		 $error_message = $e->getMessage();
    if($debug) print "<p>An error occurred while connecting to the database: $error_message </p>";
		}

}
connectPDO(''mysql:host=webdb.uvm.edu;dbname='',''LTOPPER_CS148_Final'');

?>



I cannot find any information on this problem. Has anyone encountered this problem before? Are there any changes I can make that will allow outgoing connections?

解决方案

debug = true; function dbPDOConnect(


dsn,


dbName){ global


这篇关于无法在IIS6下的php中形成套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆