Crazy truth? Code example:
<?php session_start(); $hostname="samplehost"; $username="sampleuser"; $password="samplepass"; $dbname="sampledb"; $link = mysql_connect($hostname, $username, $password) or die(mysql_error()); mysql_select_db($dbname, $link); ?>
Throws Unknown MySQL server host 'samplehost' (2) . If we delete session_start() or just do session_destroy() before mysql_connect() , it works correctly. Basically, if we have an open session, it as mysql_connect will not resolve the host name. The host name that we use for the server is correctly added to / etc / hosts.
This is a production server with PHP 5.3.2-1ubuntu4.7 - just started today. Does anyone come across this?
edit: should specify, with or without sessions, we can specify the IP address of the database server, and it works correctly.
source share