Set/Unset SESSION - Pass value to different file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kumarrana
Forum Commoner
Posts: 26
Joined: Sat Sep 01, 2007 12:55 pm

Set/Unset SESSION - Pass value to different file

Post 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";
		}
}
?>
dgreenhouse
Forum Newbie
Posts: 20
Joined: Tue Mar 10, 2009 5:13 am

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

Post by dgreenhouse »

My question is what are availabilityFirstRun625.php and availabilityFirstRunQX.php are doing?

I assume that they start with a session_start() command.
kumarrana
Forum Commoner
Posts: 26
Joined: Sat Sep 01, 2007 12:55 pm

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

Post by kumarrana »

Both availabilityFirstRun625.php and availabilityFirstRunQX.php has program that calculates the availability of particular modem. They both start with session_start().
kumarrana
Forum Commoner
Posts: 26
Joined: Sat Sep 01, 2007 12:55 pm

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

Post by kumarrana »

Anybody has any thought on this? I will be happy to provide more information if you need.
Post Reply