Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: IIS6 PHP socket TCP/IP
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?
Posted 15-Apr-13 18:29pm
LT999239

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 15 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100