Forum Moderators: coopster

Message Too Old, No Replies

PHP gaming ladder script

PHP gaming ladder script

         

Andy007

4:48 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Can anyone help me please before I throw my PC out of the window.

I have some script for a gaming ladder, I uploaded to my hosting package and imported the sql into the MySQL database using phpMyAdmin, that was the easy bit.

The instructions then say to change relevant values in the config.php file, but when I do this I get an error when I try to load the homepage in my browser.

The error is:

Fatal error: Call to undefined function: main_page() in /homepages/5/d75237652/htdocs/jaw/index.php on line 38

I have looked at line 38 and put the URL of the main page in but still get the error. Excuse my ignorance but I'm new to PHP and SQL could someone take a look and tell me where I'm going wrong?

The config.sql

<?
//////////////////////////////////////////////////
///////////DO NOT EDIT INSIDE THIS BOX////////////
if(!IsSet($indexloaded)){//
header("Location: ./index.php");//
}//
$db="";//
$timeout="";//
$email="";//
$site="";//
$misc="";//
$uinfo="";//
$url="";//
$dir="";//
$file="";//
$out="";//
$plyr="";//
$admn="";//
//////////////////////////////////////////////////
//////////////////////////////////////////////////

// 1=yes blank=no

// Database Information

$db[host]='localhost';
$db[uname]='#*$!xx';
$db[pass]='#*$!xx';
$db[name]='xxxxx';

// Cookie and Session Timeouts (in Seconds - 300 = 5 mins, 1800 = 30 minutes)

$timeout[cookie]='';
$timeout[session]='300';

// Email Server-Account Info

$email[localhost]='yes';
$email[sendaccount]='ladder@xxxxx.com';
$email[genhelp]="$email[sendaccount]";
$email[banhelp]="$email[sendaccount]";
$email[techhelp]="$email[sendaccount]";

// Default Theme Folder Name

$theme[normal]='UGC';
$theme[choices]="UGC,Black,Black2,Black3,Blue";

// Site Information

$site[shortname]='xxxxx';
$site[longname]='xxxxx';
$site[homeurl]='http://www.xxxxx.com';

// Signup Join Age - Leave blank for none

$misc[joinage]='13';

// Allow the same IP to be used on multiple accounts, Not including Unvalidated.

$misc[multipleip]='yes';

//Allow Name Changing

$misc[changeplyrname]='yes';
$misc[changeteamname]='yes';

//Allow Team Deleting

$misc[deleteteam]='yes';

// Allow match comments

$misc[losercomment]='yes';
$misc[winnercomment]='yes';

// Personal User Information

$uinfo[allow]='no';
$uinfo[force]='no';
$uinfo[edit]='no';

// Allow Signup

$misc[newplayer]='yes';
$misc[newsletter]='no';

// Urls, Directorys and File Names

$url[base]="$site[homeurl]";
$url[themes]="$url[base]/themes";

$dir[base]='/home/sites/www.xxxxx.com/web';
$dir[func]="$dir[base]/functions";
$dir[themes]="$dir[base]/themes";

$file[main]='index.php';
$file[stats]='stats.php';
$file[admin]='adminhome.php';
$file[login]='login.php';
$file[game]='game.php';
$file[staff]='staff.php';
$file[rules]='rules.php';
$file[help]='help.php';
$file[join]='join.php';
$file[phome]='playerhome.php';
$file[edit]='edit.php';
$file[players]='players.php';
$file[teams]='teams.php';
$file[match]='match.php';
$file[ladder]='ladder.php';
$file[maps]='maps.php';
$file[search]='search.php';
$file[files]='files.php';
$file[links]='links.php';
$file[company]='company.php';
$file[chat]='chat.php';

// Signup Policys Url - Leave blank for none

$url[policy]="$url[base]/$file[company]";

// Banning and Censoring

$misc[dobans]='yes';
$misc[docensors]='yes';
$misc[censorschar]='*';

// Default Logos

$misc[teamlogo]="$url[themes]/images/defaultteamlogo.jpg";
$misc[playerlogo]="$url[themes]/images/defaultplayerlogo.jpg";
$misc[mapimage]="xxxxx";

//FORUM and NEWS INFO

$misc[gernalforumid]='';
$url[forums]='http://www.xxxxx.com/forums';
$dir[forums]='/home/sites/www.xxxxx.com/web/forums';

// Url to go to if Dataserver (mysql server) is down.
$url[dserverdownurl]="$url[forums]/index.php";

// Dont edit below here

mysql_connect($db[host], $db[uname], $db[pass]);
@mysql_select_db("$db[name]") or die ("<html><head>
<!--<META HTTP-EQUIV='refresh' content='5;URL=$url[dserverdownurl]'>-->
</head>
<body bgcolor='#000000'><center><font color='#FFFFFF'>
<H2>The Dataserver is Currently Down</H2><br>
We will get it back up as soon as possible.<br><br>
</font></center></html>");

?>

I know what to put under database information but what about the rest.

Oh and here is the index file so you can see what line 36 says:

<?
$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;

//START ADDONS

case "rw":
force_login();
include("$dir[func]/rogerwilco.php");
create_rwilco();
break;

case "rwb":
force_login();
include("$dir[func]/rogerwilco.php");
create_rwilcob($rwc,$rwp);
break;

//END ADDONS - DEFAULT

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

?>

Sorry for the long post but hopefully this is enough information for someone to help me.

Adrian2k4

5:07 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



ok i don't quite understand how the two files stand in relation to eachother but there are following errors in your scripts:

all your array indices are wrong.
instead of
$timeout[session]='300';
it should be
$timeout['session']='300';

$email[genhelp]="$email[sendaccount]";
i think you probably mean:
$email['genhelp'] = $email[sendaccount];


default:
include("$dir[base]/home.php");
main_page();
break;

where did you define the function main_page()?

dreamcatcher

5:11 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Andy007,

Firstly, welcome to Webmaster World.

A call to an undefined function error is because the script is trying to access a function that cannot be found. May be that the path to an include file is wrong. You need to locate where exactly the main_page() function is and find out how the page that is calling it is linking to that file.

It may be that a URL/root path url has been specified incorrectly and this in turn is causing the problem.

Hope that helps. :)

jatar_k

5:36 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Andy007

>> before I throw my PC out of the window.

rolmao, I lose more pc's that way ... ;)

Andy007

6:28 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Well thanks for the warm welcome guys.

To be honest I'm lost with this, I bought the script and was assurred that I needed no previous PHP or SQL knowledge to get it up and running. I know know that they saw me coming! No replies to my emails to the people I bought it from and I'm stuck.

What you've said makes sense but I don;t know how to fix it. I was told I just needed to drop in the database name and password etc + a URL of homepage and away it goes.

I'm willing to email the entire script package to someone if they can get back to me with some simple instructions on what info to drop in where.

I'm sure it's only a 2 minute job for someone who know's what they are doing.

jatar_k

6:38 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well why don't we start by pasting the specific errors and the lines of code those errors are refering to and go from there

it may help to paste the line before the line in the error as well

Andy007

7:58 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Ok thanks that would be useful

jatar_k

8:50 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



let's see

the error seems to be coming from this line

main_page();

the specific error, as dreamcatcher mentioned, means it can't find that specific function.

looking at the source above my guess is that this line contains the include for the global functions

include("$dir[func]/global.php");

now if you open that file I would bet you can locate the function main_page in there

so if that is all true then it is just the path to that included file that is messed up so we need to look at the config file and find the reference to $dir[func]

the lines below are where it is defined

$dir[base]='/home/sites/www.#*$!xx.com/web';
$dir[func]="$dir[base]/functions";

so $dir[base] is the equivalent of $_SERVER['DOCUMENT_ROOT'] which is the full path from the server root to where your web root is located. fine, now let's see where the functions folder should be. It looks like you should have a directory in the root of your web site called 'functions' and in that directory should be found the global.php file.

I am assuming that /home/sites/www.#*$!xx.com/web is not the proper path more often than not the path doesn't have the www. and sometimes has the .com but often it is something like

/home/sites/xxxxx/web

I am not sure which would be correct for your site in particular. I can see the full path from the server root in my ftp program. I also have shell access to my sites and can log in and see the full path there as well.

Do you know the proper path to your web root from the server root?

Andy007

10:15 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Yeah your right it's not the proper root Ithink that was one of the gaps I was supposed to fill in. Trouble is for me not really knowing the language the gaps don't jump out at me immediately.

I know the correct path though.

I found the global.php file, here it is...

<?

//PLAYER LOGIN CHECK

$cplyrid=$HTTP_COOKIE_VARS["PID"];
$cplyrpw=$HTTP_COOKIE_VARS["PPW"];
$cplyrpw=base64_decode($cplyrpw);

//CHECK FOR COOKIE
if(($cplyrid) && ($cplyrpw)){
$userinfo=mysql_query("SELECT id,alias,pass FROM users WHERE id='$cplyrid' AND pass='$cplyrpw'");
$user=mysql_fetch_array($userinfo);
$plyr[id]=$user[id];
$plyr[pass]=$user[pass];
$plyr[alias]=$user[alias];
}

//ADMIN LOGIN CHECK

$cadmnid=$HTTP_COOKIE_VARS["AID"];
$cadmnpw=$HTTP_COOKIE_VARS["APW"];
$cadmnpw=base64_decode($cadmnpw);

//CHECK FOR COOKIE
if(($cadmnid) && ($cadmnpw)){
$admininfo=mysql_query("SELECT id,displayname,pass,access FROM staff WHERE id='$cadmnid' AND pass='$cadmnpw'");
$ainfo=mysql_fetch_array($admininfo);
$admn[id]=$ainfo[id];
$admn[pass]=$ainfo[pass];
$admn[alias]=$ainfo[displayname];
$admn[access]=$ainfo[access];
}

//START ONLINE SESSIONS

include("$dir[func]/sessions.php");

// START THEME VARIABLES
$sitetheme=$HTTP_COOKIE_VARS["THEME"];

// CHECK SITETHEME EXIST HERE
if($sitetheme){
$usertheme="$dir[themes]/$sitetheme/html.inc";
if(file_exists($usertheme)){
$sitethemeok=1;
}
}


if($sitethemeok){
$theme[current]="$sitetheme";
}else{
$theme[current]="$theme[normal]";
}

$url[curtheme]="$url[themes]/$theme[current]";
$dir[curthemeroot]="$dir[themes]/$theme[current]";
$dir[curtheme]="$dir[themes]/$theme[current]/html.inc";

//START SITE BLOCKS

include("$dir[func]/siteblocks.php");

include("$dir[func]/banner.php");
$out[banner]=get_the_banner(random);

?>

jatar_k

10:30 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did you fix the path and see if it that fixed the error?

dreamcatcher

10:48 pm on Oct 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Andy007, as previously mentioned, this may be just a path problem.

Where exactly is the main_page() function in your script? In your config file, what relation to the file that holds this function, does the config file have?

Once we sort this out, you will be up and running. :)

Andy007

11:56 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



The main_page() line is in a file called index.php in the main directory of the package.

I did try adding the path but I get an error saying 'unexpected parse (/)' or something like that. Just clarify for me, if the 'main page' or 'index' to the site is in a directory called 'ladder' in the Root then is the path simply /ladder?

jatar_k

1:11 am on Oct 31, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what is the exact error and on what line in which file?

Andy007

4:12 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



Firstly am I right about the path?

If the site index / main page is in the a folder called 'Ladder' in the 'Root' is the path /ladder?

kumarsena

5:16 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



no offence Andy, but maybe u shoudl try and be abit more polite...u sound a bit upset...maybe im worng here but...

as a general rule, taking the time to explain and answer any questions u get back is always good...
once again, no offence..

kumar

Andy007

5:32 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



Sorry man my last post came across wrong.

I was just wanting to confirm that I understood what was meant by full path in case it was as simple as me geting that bit right.

jatar_k

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

WebmasterWorld Administrator 10+ Year Member



>> if the 'main page' or 'index' to the site is in a directory called 'ladder' in the Root then is the path simply /ladder?

no, that would be the DOCUMENT_ROOT or web root of the site. For php includes they use the filesystem and know nothing about the actual web root.

it would be something like

/home/user/www/ladder/

I mad that up but it would be from the root of the actual server, not of only the website

Andy007

6:54 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



Well guys I think finding the correct path fixed it the site seems to be working.

I figured it was a simple problem but my simple brain just coudldn't figure it out.

Thank you everyone for all your help.

jatar_k

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

WebmasterWorld Administrator 10+ Year Member



glad you got it sorted Andy007