Page 1 of 1

Set/Unset SESSION - Pass value to different file

Posted: Sun Mar 27, 2011 3:42 am
by kumarrana
Idea is to have one main file and execute multiple file based on the parameters obtained on it. Let me briefly describe what I am trying to accomplish;
I am querying a database and retrieve a two variables; $IP and $descripton. Based on the description, I would pass IP to relevant files. Problem I am having is, it will execute once and stops. It makes me think that loop stops after fist execution and SESSION hangs up on one IP. I would think I need to clear SESSION somewhere. Please advice, here is my code.

Code: Select all

<?php
session_start();
include('MySQLLogIn.php');
$query_IP = mysql_query("SELECT * FROM host");
if(!$query_IP)
	{
		die('Error: '.myql_error());
	}
while ($host_row = mysql_fetch_array($query_IP))
{
echo $IP = $host_row['hostname'];
$description = $host_row['description'];
		if (preg_match("/625/i", "$description"))  
                    {
                     $_SESSION['modemIP625'] = $IP;
		echo "<br> <b>". $IP . " belong to : Comtech 625 </b><br>"; 
		include('availabilityFirstRun625.php');
		unset($_SESSION['modemIP625']);
		
		} else if(preg_match("/QX/i", "$description"))
		{
		$_SESSION['modemIPQX'] = $IP;
		echo "<br> <b> ". $IP . "belong to : Comtech QX </b><br>";
		include('availabilityFirstRunQX.php');
		unset($_SESSION['modemIPQX']);
		} else
		{
		echo "<br> <b> No modem can be located";
		}
}
?>

Re: Set/Unset SESSION - Pass value to different file

Posted: Sun Mar 27, 2011 5:14 am
by dgreenhouse
My question is what are availabilityFirstRun625.php and availabilityFirstRunQX.php are doing?

I assume that they start with a session_start() command.

Re: Set/Unset SESSION - Pass value to different file

Posted: Tue Mar 29, 2011 4:24 pm
by kumarrana
Both availabilityFirstRun625.php and availabilityFirstRunQX.php has program that calculates the availability of particular modem. They both start with session_start().

Re: Set/Unset SESSION - Pass value to different file

Posted: Wed Mar 30, 2011 2:19 am
by kumarrana
Anybody has any thought on this? I will be happy to provide more information if you need.