Jump to content

function by reference not executing


phpJoeMo

Recommended Posts

OK, so I have the following file that has database functions:

 

<?php

 

function dbDelete($param){

$conDelete = mysql_connect($url,'username','password',true);

mysql_select_db('my_db',$conDelete);

mysql_query($param,$conDelete);

mysql_close();

if(isset($conDelete)){

mysql_close($conDelete);

}

}

?>

 

I include the above file in a session handling file.  But for some reason the new file can't call the above function as follows:

<?php

include_once 'the above stated file';

function timeOut(){

        dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'");

$_SESSION = array();

setcookie(session_name(),'',time()-4200);

session_destroy();

}

//CHECK FOR TIMEOUT REQUEST

switch($_GET['xyz']){

case 'timeout':

timeOut();

header("Location: /?xyz=timedout");

break;

case 'logout':

timeOut();

header("Location: /?xyz=loggedout");

break;

case 'refresh':

dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'");

break;

}

?>

 

dbDelete isn't being called inside of the TimeOut() function.  The only way it works is by doing the following:

 

<?php

function timeOut(){

$_SESSION = array();

setcookie(session_name(),'',time()-4200);

session_destroy();

}

//CHECK FOR TIMEOUT REQUEST

switch($_GET['xyz']){

case 'timeout':

dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'");

timeOut();

header("Location: /?xyz=timedout");

break;

case 'logout':

dbDelete("DELETE FROM acctussessi WHERE acctussessi_usid = '$sessius[0]'");

timeOut();

header("Location: /?xyz=loggedout");

break;

case 'refresh':

dbUpdate("UPDATE acctussessi SET acctussessi_time = ".time()." WHERE acctussessi_unid ='".$token."'");

break;

}

?>

But this is annoying and repetitive.  What is going on?

 

Thanks in advance.

Link to comment
Share on other sites

Are you including the file using a file system path? That's (generally) the only way to get php code to be included into another file. Given that you didn't post what you were using in the include_once statement, I suspect you are actually using a URL, which won't work.

Link to comment
Share on other sites

I should specify that the issue isn't in the include path.  I gave an arbitrary value.

 

I can call dbDelete() when it is outside of the timeOut() function.  But when I include dbDelete() inside of the timeOut() function and attempt to execture dbDelete() by calling timeOut() nothing happens.

 

My goal here is to include dbDelete() inside of timeOut() so any call to timeOut() takes care of completely destroying the session.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.