Sessions question
Posted: Thu Sep 13, 2007 12:15 am
I know I'm asking a lot of problems but this is the first time I've done something with mysql so I'm kinda learning as I go.
Making the session isnt the problem, its calling it later. My
Statement seems to me that if $_SESSION had a value of $j (in this case any number between the first and last row of my mysql table) it should echo the row count. At first I had assumed it wasn't creating the sessions but then I experimented and just tried echo $_SESSION['1']; and it echo'ed the correct value of 1. so why isnt the $_SESSION['$j'] working? It doesn't seem to want to save the session information over to delete.php either, even when i tried sticking in
after the while loop. The delete.php page just comes up blank.
delete.php
Could someone enlighten with your grand knowledge of mysql so I can fix this mess 
Code: Select all
$b = 0;
if (!isset($_SESSION['login']))
{
header("Location:login.php");
}
if(isset($_SESSION['login']))
{
$query = "SELECT * FROM newsart GROUP BY count ORDER BY count desc";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$b++;
if($_POST['checked_'. $row['count'] .''] == $row['count'])
{
$_SESSION[''.$row['count'].''] = $row['count'];
}
}
for($j = 1; $j <= $b; $j++)
{
if(isset($_SESSION['$j']))
{
session_write_close();
header('location:delete.php');
}Code: Select all
if(isset($_SESSION['$j']))
{
session_write_close();
header('location:delete.php');
}Code: Select all
if(isset($_SESSION['1']))
{
session_write_close();
header('location:delete.php');
}delete.php
Code: Select all
<?php
session_start();
include '*****';
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
if (!isset($_SESSION['login']))
{
header('Location: index.php');
}
else if(isset($_SESSION['login']))
{
echo $_SESSION['1']; //testing purposes only
$query = "SELECT * FROM newsart GROUP BY count ORDER BY count desc";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo $_SESSION[''. $row['count'] .''];
}
}
?>