Set/Unset SESSION - Pass value to different file
Posted: Sun Mar 27, 2011 3:42 am
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.
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";
}
}
?>