Jump to content

error message


MDanz

Recommended Posts

i'm doing a simple web crawler and i get this error message..

 

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/ustackc1/public_html/crawler.php on line 2

 

Warning: file_get_contents(http://www.realgm.com) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/ustackc1/public_html/crawler.php on line 2

Title:

Head:

 

whats wrong with the code?

 

<?php 
$str = file_get_contents('http://www.realgm.com');
preg_match("/<title>(.*)<\/title>/", $str, $title);
preg_match("/<head>(.*)<\/head>/", $str, $head);
echo "Title: ".htmlentities($title[1])."<br />";
echo "Head: ".htmlentities($head[1]);
?> 

 

 

Link to comment
https://forums.phpfreaks.com/topic/175217-error-message/
Share on other sites

MDanz php.ini is the config file that dictates what intrinsic functions are turned on or off. It works in the similar way of a .ini file in windows for a lot of applications, where you set properties for the application to run with. The same thing with php if you set url_fopen=1 in your php.ini(where your php compiler is installed on the server) it will turn it on. However I personally do not recomend using url_fopen because of security risks. I would suggest using cURL http://us3.php.net/manual/en/curl.examples-basic.php

Link to comment
https://forums.phpfreaks.com/topic/175217-error-message/#findComment-923514
Share on other sites

thx for all the help, how would i change this code just to get header and title of the webpage i've entered?

 

<?php
        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "www.realgm.com");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     
?>

Link to comment
https://forums.phpfreaks.com/topic/175217-error-message/#findComment-923523
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.