error with retrieving cookie data

I’m working on doing a conversion from asp to php for a site I’m kind of co-founding /refounding. We currently have the asp one up and running. It a was discussed that php is the way they are wanting to go so I’m kind of spearheading this in my free time. Currently I’m having an issue with a logon check page. For some reason I’m getting :
[center] Fatal error: Function name must be a string in C:\xampp\htdocs\frstoryforge\subs\inc_logon_chk.php on line 62[/center]

The section that I am getting that on I don’t believe it is supposed to be a function. It’s placing some cookie information into a variable.

Here’s the code:
[php]<?php
session_start();
function session_register($fruz_mem_alias_session,$fruz_mem_pid_session,$fruz_mem_tz_session,$fruz_mem_adm_session,$fruz_mem_name_session,$fruz_mem_lld_session,$fruz_pid_session){};
?>

<?php include './subs_main.php' ?> <?php include './inc_level.php' ?> <?php //include './inc_password_encrypt.php' ?> <?php $Daylight_Savings=false; // change this as BST = TRUE else FALSE $insertCSS=''; $your_PTS=0; $your_EXP=0; $your_PID=-1; $is_MEMBER=false; $page_url_data=''; function chkLogon() { extract($GLOBALS); $is_MEMBER=false; $site_CUSTOM=0; // ------------------- // we will store view page with stamp (stamp_page = TRUE) // ------------------- if (($page_title.'')=='') { $page_title_data='Unknown'; } else { $page_title_data=$page_title; } if (strlen($page_title_data)>100) { $page_title_data=substr($page_title_data,0,80); } $page_title_data=reqChk($page_title_data); if (($page_url_data.'')=='') { $page_url_data=$_SERVER['SCRIPT_NAME']; if (($page_url_data.'')=='') { $page_url_data='Unknown'; } } $page_url_data_data=reqChk($page_url_data); $cookIP=$_SERVER['REMOTE_ADDR']; // --------------------------- // read from cookie, if one exists, // player Alias and encrypted Password // --------------------------- $cookPassword = $_COOKIE('cookSession'); $cookAlias = $_COOKIE('cookAlias'); if (($cookAlias.'')=='') { $cookAliasData=''; } else { $cookAliasData=reqChk($cookAlias); } $session_check=$_SESSION['fruz_mem_alias']; if (($session_check.'')=='') { $session_check="-noname-"; } if ((($session_check.'')==$cookAlias)) { $your_PID=$_SESSION['fruz_mem_pid']; $your_TIMEZONE=$_SESSION['fruz_mem_tz']; $you_ADMIN=$_SESSION['fruz_mem_adm']; $your_NAME=$_SESSION['fruz_mem_name']; $player_last_login_date=$_SESSION['fruz_mem_lld']; $is_MEMBER=true; } else { if (!(($cookPassword."")=="")) { openConn(); $exeRS=$pConn->execute; if (!$exeRS->EOF) { $dbPassword=$exeRS[0]; $dbPassword_encrypted=sha256($dbPassword); if (strlen($cookPassword)==70) { $cookPassword=substr($cookPassword,4,64); } if (strtoupper($dbPassword_encrypted)==strtoupper($cookPassword)) { $is_MEMBER=true; } } if ($is_MEMBER==true) { $your_PID=$exeRS[1]; $your_TIMEZONE=$exeRS[2]; $you_ADMIN=$exeRS[3]; $your_NAME=$exeRS[4]; $player_last_login_date=$exeRS[5]; $_SESSION['fruz_mem_pid']=$your_PID; $_SESSION['fruz_mem_tz']=$your_TIMEZONE; $_SESSION['fruz_mem_adm']=$you_ADMIN; $_SESSION['fruz_mem_name']=$your_NAME; $_SESSION['fruz_mem_lld']=$player_last_login_date; $_SESSION['fruz_mem_alias']=$cookAlias; } $exeRS->close; $exeRS=null; closeConn(); } } if ($is_MEMBER==true) { if (($player_last_login_date."")=="") { $player_last_login_date="01/01/2000"; } openConn(); if (!($CDATE[$player_last_login_date]==$CDATE[time])) { $your_PTS=20; $exeSQL="UPDATE player SET "; if ($stamp_page==true) { $exeSQL=$exeSQL."player_visit_page_url='".$page_url_data_data."', player_visit_stamp = CAST(CONCAT(CURRENT_DATE(), ' ', CURRENT_TIME()) AS DATETIME), player_visit_page='".$page_title_data."', "; } $exeSQL=$exeSQL.'player_last_login_date='.format_mySQLDate(strftime('%m/%d/%Y %H:%M:%S %p')).', player_ip='.$cookIP.' WHERE player_id = '.$your_PID; $_SESSION['fruz_mem_lld']=time(); $pConn->execute($exeSQL); } else { $pConn->execute('UPDATE player SET player_visit_page_url='.$page_url_data_data.", player_visit_stamp = CAST(CONCAT(CURRENT_DATE(), ' ', CURRENT_TIME()) AS DATETIME), player_visit_page=".$page_title_data.', player_ip='.$cookIP.'WHERE player_id = '.$your_PID); } saveEXP($your_PID,$your_PTS,1); closeConn(); } else { $your_TIMEZONE=-5; $your_EXP=20; $your_PID=-1; $your_NAME="Guest"; $you_ADMIN="N"; if ((($_SESSION['fruz_pid'].'')=='')) { // --------------------------- // ip banning check for guest per session // --------------------------- $banSQL="SELECT ip_block_id FROM ip_block ". "WHERE (ip_block_ip = '".$cookIP."' AND ip_block_init='E' AND ip_block_flag='Y') OR ". "(INSTR('".$cookIP."', ip_block_ip) AND ip_block_init='L' AND ip_block_flag='Y')"; openConn(); $banRS=$pConn->execute; $banSQL; if (!$banRS->EOF) { $banRS->close; $banRS=null; closeConn(); header('Location: '.'err_ban.php'); } $banRS->close; $banRS=null; $exeRS=$pConn->execute; $cookIP."'"; if ($exeRS->EOF) { if ($stamp_page==false) { if (($page_url_data_data."")=="") { $page_url_data_data="index.php"; } if (($page_title_data."")=="") { $page_title_data="Welcome to FR Story Forge"; } } $exeSQL="INSERT INTO `guest` (guest_ip, guest_date, guest_page_url, guest_page) ". "VALUES ('".$cookIP."', CAST(CONCAT(CURRENT_DATE(), ' ', CURRENT_TIME()) AS DATETIME), ". "'".$page_url_data_data."', '".$page_title_data."')"; $pConn->execute($exeSQL); } else { $exeSQL="UPDATE `guest` SET guest_date = CAST(CONCAT(CURRENT_DATE(), ' ', CURRENT_TIME()) AS DATETIME)"; if ($stamp_page==true) { $exeSQL=$exeSQL.", guest_page_url='".$page_url_data_data."', guest_page='".$page_title_data."'"; } $exeSQL=$exeSQL." WHERE guest_ip = '".$cookIP."'"; $pConn->execute($exeSQL); } $exeRS->close; $exeRS=null; closeConn(); $_SESSION['fruz_pid']=1; } else { $exeSQL="UPDATE `guest` SET guest_date = CAST(CONCAT(CURRENT_DATE(), ' ', CURRENT_TIME()) AS DATETIME)"; if ($stamp_page==true) { $exeSQL=$exeSQL.", guest_page_url='".$page_url_data_data."', guest_page='".$page_title_data."'"; } $exeSQL=$exeSQL." WHERE guest_ip = '".$cookIP."'"; openConn(); $pConn->execute($exeSQL); closeConn(); } } return $function_ret; } ?>

[/php]

Well, on line 62, it is loading a previously defined cookie variable.
In PHP, cookies must be created in a special way… This is the format:

setcookie(name, value, expiration):

Note that the name would be your ‘cookSession’, the value whatever you want and you must put in
an expiration time. I think if you leave that out, the cookies stays until the browser cleans out cookies.

My guess is that the cookie was not set up correctly when you originally created it.
If a cookie is not created in the correct manner, it does not exist. In PHP, you should test to see if the
cookie parm exists before you use it or load it into a variable. Below is a nice tutorial on how to do all
of this. Note in the tutorial where they read the cookie back, they check to see if it exists first. You
must remember to do this because the user can clear his/her cookies by using the browser’s clean-up.

Hope this helps… http://www.tizag.com/phpT/phpcookies.php

I almost missed it but the error is cause you have the wrong brackets for the cookie
These
[php]
$cookPassword = $_COOKIE(‘cookSession’);
$cookAlias = $_COOKIE(‘cookAlias’);
[/php]
Need to be these
[php]
$cookPassword = $_COOKIE[‘cookSession’];
$cookAlias = $_COOKIE[‘cookAlias’];
[/php]
Also this if() makes no sense as to why you are doing it this way.
[php]if (($cookAlias.’’)==’’)[/php]
It should just be
[php]if ($cookAlias==’’)[/php]
But now I see you have that for many if(), why in the world would you do that?

Sponsor our Newsletter | Privacy Policy | Terms of Service