PHP file reading error in Vista

I recently encountered this problem on Vista running localhost with XAMPP 1.7
I had this calendar script that loads a template from a given path, but it gives me a timeout error. It was previously running smoothly on an XP machine. After further checking, I found out that the problem was something related to the PHP function file_get_contents, for sure this was not the problem as it is running okay on XP.

Here’s part of the script:

function getCalendarTemplate($strPath)
{
    $content = file_get_contents($strPath);
    return $content;
}

After browsing and searching for some clue, I found with this forum that using IP address instead of “localhost” on the path solved the problem. I’ve added extra line prior to file_get_content that replace the “localhost” into 127.0.01

Here’s the script now:

function getCalendarTemplate($strPath)
{
    $strPath = str_replace('localhost', '127.0.0.1', $strPath);
    $content = file_get_contents($strPath);
    return $content;
}
Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*