Forum Moderators: coopster

Message Too Old, No Replies

Php Ladder Script - undefined function error

         

TGL_Phantom

1:20 am on Nov 7, 2004 (gmt 0)

10+ Year Member



every time when i go to the my ladder site it gives me this error: Fatal error: Call to undefined function: main_page() in /data/members/free/tripod/nl/p/h/a/phantom112/htdocs/index.php on line 24

Please help me

mincklerstraat

1:39 am on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmasterworld, [webmasterworld.com] TGL Phantom.

a 'Call to undefined function' means your script is trying to call a function (do what the lines of code in this function stipulate) which hasn't been defined - nowhere has it been stated what this function should do. You've got basically two kinds of functions - those which are already pre-defined and ready-to-use in php (the ones outlined in the manual), and the ones your script has defined. These always look like:


function whatever_you_call_it($somevariable, $anothervariable){
(various lines of code here)
}

the above 'defines' the function
whatever_you_call_it()
.

Your particular error means that on line 24, there's a line something like:

main_page()

but nowhere in that index.php is there to be found the declaration:

function main_page($somevariable){
do_this_and_that();
}

This function that needs to be declared could also be supposed to be found in a file that is included or required (basically, a file that sort of continues providing code to your file
index.php
), but maybe your script can't find this file. Your script might be put in some odd place where, relatively speaking, the places it looks don't correspond to the place where that file actually is. Look and see if there aren't other errors about 'stream couldn't be opened, included file not found' or something like that and see if it isn't possible to put that file in a place where it can be found, taking those error notices as clues.

TGL_Phantom

1:49 am on Nov 7, 2004 (gmt 0)

10+ Year Member



Can u fix that for me? or can anyone added that for me?

ergophobe

4:31 am on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Since the name of the function is "main_page", I think asking someone to fix it for you would be the equivalent to asking someone to write the main page output script for you. In order to do so, we would need to know what you are trying to achieve and how far you have gotten so far (but no code dumps [webmasterworld.com] please).

That said, you might want to do a search in all script files for "function main" and see if perhaps the function exists in your script and is named "mainPage" or something like that (if, for example, you are modifying a script that you downloaded).

Cheers,

Tom

mincklerstraat

12:53 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If searching your files and repairing that way, a last possibility would be to simply re-download your ladder script, ftp the ladder script files that are there to a copy on your own hard drive for reference, and upload the files of the ladder script not including any special 'install' files.

TGL_Phantom

1:09 pm on Nov 7, 2004 (gmt 0)

10+ Year Member



Oke i will test that

TY

mincklerstraat

2:42 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Robin.

Probably one of the best things you can do now is to get a 'local' install of PHP. This will make your own PC be able to function as a server, with PHP, database, and all. Go to [apachefriends.org...] , d/l, clickety click and bingo, you've got your own server functionality on your own PC.

Just put your script in the 'web root' directory and surf to localhost (type [localhost...] in your address bar).

You can try out stuff on your own computer then to see what works - and once it does work, you can upload it to the server. When I first got my own install of PHP, mysql, and apache on my computer, it made me feel like a six-year-old on Christmas morning.

Apart from this, there's not much more I can say than the advice ergophobe and I gave you already.

Hope you get your script working.

Met vriendelijke groeten,
minck

[edited by: ergophobe at 4:53 pm (utc) on Nov. 7, 2004]

TGL_Phantom

3:23 pm on Nov 7, 2004 (gmt 0)

10+ Year Member



I did this but i still got the error.

Robin Peters

mincklerstraat

3:40 pm on Nov 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, this will give you a few basic notions of php debugging for this kind of issue, but it probably won't solve your problem; you'll probably need to get into touch personally with someone who knows php and can look over your code.

at the top of your script somewhere that's on your local computer, after the <?php, add this line:
error_reporting(E_ALL);
look through index.php and see if there are any lines with the words include, include_once, require, or require_once like
include thisfile.php;
if so, thisfile.php is also one of the files that's supposed to have information needed for running that page. There may be more than one. If any of these files 'can't be found' by the server, it might be the file that's supposed to contain that function.
Run your script again by pointing your browser to it.
You may see some kind of error warning that a file couldn't be included, a stream couldn't be opened, etc. This could give you a clue about which file is supposed to be opened that isn't working.

Otherwise, look through all the php files in the script and see if you can find lines like the one I mentioned in the other thread:

fuction mainpage($maybesomevariableshere){
/*something here*/
}

If so, put a line in index.php like
include 'path/to/filewiththisfunction.php';

and see if that might work.

Otherwise, it's possible that your script is just plain buggy. Sometimes re-downloading it from the source you got it from can correct possible file corruptions; but if you already did this, you might try to find a more reliable script.

TGL_Phantom

5:42 pm on Nov 8, 2004 (gmt 0)

10+ Year Member



Hey guys, i still cant get it work, maybe this will help here are the files :

INDEX.PHP

<?
$indexloaded=1;
include("config/config.php");
include("$dir[func]/global.php");
include("$dir[func]/loginforms.php");

switch($action){

//PLAYER
case "join":
include("$dir[func]/player_new.php");
form_join();
break;

//END ADDONS - DEFAULT
default:
include("$dir[base]/home.php");
main_page();
break;
}

//FIND AND DELETE/AWARD WINS FOR UNRESPONDED CHALLENGES
include("$dir[func]/challengeforfeit.php");
check_unrespondedchallenges();
?>

HOME.PHP

<?
if(!$indexloaded){
header("Location: ./index.php");
}

function main_page(){
global $dir, $url, $file, $out, $misc;

etc, etc <jatar_k>

[edited by: jatar_k at 10:55 pm (utc) on Nov. 8, 2004]
[edit reason] removed code dump [/edit]

TGL_Phantom

5:56 pm on Nov 8, 2004 (gmt 0)

10+ Year Member



Does anyone know what i need to change in the files to get it worked?

Robin Peters

TGL_Phantom

6:18 pm on Nov 8, 2004 (gmt 0)

10+ Year Member



please reply fast

Robin Peters

jatar_k

10:58 pm on Nov 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think this thread will highlight the problem

PHP gaming ladder script [webmasterworld.com] msg 8 in particular

it even smells like the same script ;)

I am sure it is just the include path in the config file