Jnerocorp Posted October 6, 2009 Share Posted October 6, 2009 this is what I tried: <?php function getText () { $url = "www.tizag.com"; $data = getPage($url); preg_match('#<td class="mainIn"><h1>Welcome to Tizag Tutorials</h1> <p>([a-z0-9,]+)</p><br> </td>#si', $data, $p); } //This is line 11 ?> This will get the main text from the site Tizag.com<br> <br> <?php echo getText(); ?> this is the error I get: Fatal error: Cannot redeclare gettext() in /home/a4428795/public_html/demos/gertpage.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/ Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 gettext is an existing php function. rename your function. Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-931996 Share on other sites More sharing options...
Jnerocorp Posted October 6, 2009 Author Share Posted October 6, 2009 ok now I get this error with this code: Fatal error: Call to undefined function getpage() in /home/a4428795/public_html/demos/gertpage.php on line 8 <?php function getSitetext () { $url = "www.tizag.com"; $data = getPage($url); preg_match('#<td class="mainIn"><h1>Welcome to Tizag Tutorials</h1> <p>([a-z0-9,]+)</p><br> </td>#si', $data, $p); } ?> This will get the main text from the site Tizag.com<br> <br> <?php echo getsitetext(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-931998 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 So, based on the error message, what do you think the problem is? Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932001 Share on other sites More sharing options...
Jnerocorp Posted October 6, 2009 Author Share Posted October 6, 2009 well something is undefined but im not sure what? i have $data = getpage($url) I tried $data = $url->getpage($url) and got this error: Fatal error: Call to a member function getPage() on a non-object in /home/a4428795/public_html/demos/gertpage.php on line 8 Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932006 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 Call to undefined function getpage() You said something is undefined, but you aren't sure what. Well the error message tells you what is undefined. It's telling that you are trying to call a function called "getpage()" but php can't find it. It doesn't exist. It's undefined. No offense, but it's not some deep rocket science mystery of the universe thing.. So, now that you know that php can't find a function called getpage(), what do you think your next step should be? If you couldn't find something, what would you do? Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932009 Share on other sites More sharing options...
Jnerocorp Posted October 6, 2009 Author Share Posted October 6, 2009 ok I altered the code but now I get this error that is almost the same <center> <h1> Get Text From Page </h1> <?php function getSitetext () { $url = "www.tizag.com"; $data = $url->getPage($url); preg_match('#<td class="mainIn"><h1>Welcome to Tizag Tutorials</h1> <p>([a-z0-9,]+)</p><br> </td>#si', $data, $p); return $value; } $results = $data->getSitetext(); ?> This will get the main text from the site Tizag.com<br> <br> <?php echo $results ?> </center> Error: Fatal error: Call to a member function getSitetext() on a non-object in /home/a4428795/public_html/demos/gertpage.php on line 14 Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932012 Share on other sites More sharing options...
akitchin Posted October 7, 2009 Share Posted October 7, 2009 ... and a hush falls upon the crowd. Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932092 Share on other sites More sharing options...
mikesta707 Posted October 7, 2009 Share Posted October 7, 2009 dude... I don't even know where that object you are trying to use is coming from, but your first error explained everything. If you have a function, that you know for a fact is defined, and you are getting an undefined function error, then what could the most likely solution? maybe your using the wrong function name. Just forget about whatever object nonsense your trying to do make sure you are calling the function you defined. Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932098 Share on other sites More sharing options...
448191 Posted October 7, 2009 Share Posted October 7, 2009 *has visions of someone pulling apart a car and randomly chucking the parts back under the hood* Damn, this thing won't start. Stupid piece of Japanese junk.. Caroline, get me that crowbar! Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932198 Share on other sites More sharing options...
KevinM1 Posted October 7, 2009 Share Posted October 7, 2009 Here's a hint, with all the subtlety of a sledgehammer to the forehead: PHP isn't telepathic. Just because you think there should be a function called getPage() in PHP doesn't mean one actually exists. In fact, checking the manual (http://www.php.net/quickref.php ...you did know that there exists an online manual, right?) verifies that there's no built-in getPage() function in the language. What does that mean? It means that you'll need to create the getPage() function yourself. And that means doing more than merely trying to tweak the syntax used to invoke the function. Start there. Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932275 Share on other sites More sharing options...
MadTechie Posted October 7, 2009 Share Posted October 7, 2009 Hi Jnerocorp, Everyone is try to help you workout the problem for yourself, as this will help you more than just giving the answer, Now you know its not a variables and know its a problem with the functions, so are you calling the correct/existing one or not ? or in this case are we being insensitive ? I really hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/176765-trying-to-preg_match-text-from-another-page/#findComment-932296 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.