Forum Moderators: coopster
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.
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()?
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. :)
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.
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?
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);
?>
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?
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