# PHP class - grabUrl not working suddenly?

**URL:** <https://forum.kirupa.com/t/php-class-graburl-not-working-suddenly/251632>\
**Category:** Uncategorized\
**Created:** [February 11, 2008, 9:50am UTC](https://forum.kirupa.com/t/php-class-graburl-not-working-suddenly/251632 "2008-02-11T09:50:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfree](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@manfree](https://forum.kirupa.com/u/manfree)\
**Post date:** [February 11, 2008, 9:50am UTC](https://forum.kirupa.com/t/php-class-graburl-not-working-suddenly/251632/1 "2008-02-11T09:50:53Z")

</div>

Dear all

I have download a php class (grabUrl.php) which can grab a htm source code  
It works perfectly in last week  
However, it doesn’t work on today… and returns the follow error message …  
[COLOR=Red]\*\*  
Notice\*\*: Undefined variable: data in **C:\Inetpub\wwwroot\P1\grabUrl.php** on line **46** [/COLOR]

Any body can help me please ?? T  
Thanks

The grabUrl.php

```php

<?php
class grabUrl{
    var $toEmail="";
    var $mailSubject="";
    var $mailHeaders="";
    var $addHeaders="";
    var $grabData="";

    function createTo($email){
        $this->toEmail=$email;
    }
    
    function createCC($email){
        $this->mailHeaders.="Cc: $email
";
    }
    
    function createBCC($email){
        $this->mailHeaders.="Bcc: $email
";
    }
    
    function createSubject($sub){
        $this->mailSubject=$sub;
    }
    
    function createFrom($name,$email){
        $this->mailHeaders.="From: '$name' <$email>
";
    }

    function sendMail($charset="iso-8859-1"){
        $this->mailHeaders.="MIME-Version: 1.0
";
        $this->mailHeaders.="Content-type: text/html; charset=$charset
"; // alternate is utf-8
        if(mail($this->toEmail,$this->mailSubject,$this->grabData,$this->mailHeaders)){
            return true;
        }else{
            return false;
        }
    }
    
    function getData($url,$use_include_path=0){
        file = @fopen($url, 'rb', $use_include_path);
        if ($file){
            if ($fsize = @filesize($filename)){
                $data = fread($file, $fsize);
                }else{
                    while (!feof($file)){
                        $data .= fread($file, 1024);
                }
            }
        fclose($file);
        }
        $this->grabData=$data;
    }
    
    function showPage(){
        echo $this->grabData;
    }
    
    function returnData(){
        return $this->grabData;
    }

}

/*
    Sample Usage
*/

/*
$foo=new grabUrl();
$foo->createTo("xxx@xxx.com");
$foo->createCC("xxx@qqq.com");
$foo->createBCC("xxx.www.com");
$foo->createFrom("Vedanta Barooah","xxx***ss.com");
$foo->createSubject("This is a test mail! Please Ignore!");
$foo->getData("http://www.bbc.co.uk");
if($foo->sendMail()){
    echo "Mail Sent!";
}else{
    echo "Error Sending Mail!";
}
*/
?>

```

Here is the test.php

```php
 
<?php
include "class/grabUrl.php";

$obj = new grabUrl();
$obj->getData("http://www.google.com");
$rawdata = $obj->returnData();
?>

```
