• 0

Getting information from a separate page!


Question

Hi guys,

Just wondering if anyone can give me a push in the right direction, I have a sort of bbcode system but as well as generic codes it has what i call system codes.

These codes are stored in a database and relate to a page, so if a system code is found it looks in the data base for the code and find the page it needs to call to get information out of. For example if the system finds %FanName% it knows that this is a system code and the database tells it should go to "/backend/FanName.php", FanName.php calls a class function to return the name from Facebook.

But thats the problem I'm not to sure how without using javascript, to tell it to the system during the execution of php code to look at another page and return the value of that page, can anyone help?

I don't want to use ajax or javascript as all of this is happening inside a class, and hopefully I wont need to reload the page as information at this point has already been generated that is needed later on in the execution schedule.

hope you guys can help thanks matt.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

OH BOWS HEAD IN SHAME :(

I really can't believe it was that, sorry guys just had major dumb ass moment I really should think before typing next time.

Thanks for the information guys, even though was a dumb question in the first place!

May as well ask one more possibly stupid question whilst I'm at it then.

will this still work for multiple occurrences? say if it was in a while loop and each time %FanName% would produce a different result?

Link to comment
Share on other sites

  • 0

Well, if the included file contains functions or classes, including it more than once will result in errors regarding these things being re-declared.

However, you should not have to include it each time to begin with. Rather, include it once before the loop and then call the functions and classes within during the loop.

Something along these lines:

<?php
#this this the FanName.php file.
function fan_name($some_argument) {
	return 'some_name';
}
?>

<?php
#this is the file that needs to use the fan_name() function.
include('FanName.php');
foreach ($fans as $fan) {
	echo fan_name($fan);
}
?>

Link to comment
Share on other sites

  • 0

ok so tried what you said, and I'm nearly there however because I don't know what page thats going to be requested on all system code pages I've created a generic function called getReturn, however because I can call the same function name but from different pages is there a way i can destroy the function every time i enter the while loop?

at the moment I get this error

Fatal error: Cannot redeclare getreturn() (previously declared in /var/sites/u/uni.wee.me.uk/public_html/backend/SystemCodes/getFanName.php:2) in /var/sites/u/uni.wee.me.uk/public_html/backend/SystemCodes/getVoucherCode.php on line 32

and this is my code

                    while ($r3 = mysql_fetch_array($q3))
                    {
                        include($r3["page"]);

                        $this->codes[$r2["code"]] = getReturn($fid);
                    }

in the above example I am passing two system code %FanName% which points to getFanName.php and %voucherCode% which points to getVoucherCode.php and all have getReturn() which always returns a string.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.