Forum Moderators: coopster
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration
I called my host up and they said that it is a coding error, not a security or server error,
Here is the code:
<?php
$address = "http://www.example.com";
echo htmlspecialchars(file_get_contents($address));
?>
maybe try a phpinfo [php.net] file and see the setting of allow_url_open [php.net]
What I am trying to do is extract XML values using PHP. I can use the file_get_contents() function in a regular .php file yet when I combine that with a SimpleXMLElement function in a .php5 script, I get the previously mentioned error.
Here is my nightmare:
file1.php
<?php
$address = "http://www.address.to/xmlfile";
$page = htmlspecialchars(file_get_contents($address));
echo $page;
?> This gives me a page with all the xml file info, though it isn't a properly formatted xml page, it just looks like text, is that what should have happened?
Anyway, I know that file_get_contents works just fine with php4, but that SimpleXMLElement is only in PHP5, so I created another file:
file2.php5
<?php
include 'file1.php';
$xml = new SimpleXMLElement($page);
?> This is what gives me the error I mentioned before, the:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration
Why is the file_get_contents function screwing up file2.php5?