Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,679 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,205 people online right now. Registration is fast and FREE... Join Now!




Problems with $_SESSION

 
Reply to this topicStart new topic

Problems with $_SESSION

cemplukcute2003
post 10 Jul, 2007 - 01:11 AM
Post #1


New D.I.C Head

*
Joined: 15 Nov, 2006
Posts: 24



Thanked 1 times
My Contributions


Hello...
I need some help here.
I'm having problem with $_SESSION.
Only in one page suddenly i can't access the session variables.
Can you help me?
CODE

<?php
    include("database_setup.php");

    session_start();

    //Take variable
//    $photoName = $_GET["x1"];
    $photoName = "friend_300.jpg";
    $user = $_SESSION["username"];

    if(strcmp($_GET["x2"], "") == 0) {
        $fileType = "Homepage_Photo";
    }
    else {
        $fileType = "Watermarked_Process";
    }

    if($conn) {
        $query = "SELECT Photo_Location.File_Name, File_Location.File_Location, Photos.Photo_Title ";
        $query .= "FROM Photos, Photo_Location, File_Location ";
        $query .= "WHERE Photo_Location.File_Name = '$photoName' AND Photo_Location.Photo_No = Photos.Photo_No AND ";

        if(strcmp($fileType, "Homepage_Photo") == 0) {
            $query .= "Photos.Username = '$user' AND Photos.Watermark = '0' AND File_Location.File_Type = '$fileType' AND ";
        }
        else {
            $query .= "Photos.Username = '$user' AND Photos.Watermark = '1' AND File_Location.File_Type = '$fileType' AND ";
        }
        $query .= "File_Location.File_Type = Photo_Location.File_Type";

        $queryResult = mysql_query($query);

        if($queryResult) {
            if(mysql_num_rows($queryResult) != 0) {
                $_SESSION["picName"] = mysql_result($queryResult, 0, "File_Name");
                $_SESSION["location"] = mysql_result($queryResult, 0, "File_Location");
                $_SESSION["title"] = mysql_result($queryResult, 0, "Photo_Title");

                session_write_close();
                header("Location: http://www.sig-share.com/site/photo_dl3.php");
            }
            else {
                echo "not found " . $fileType;
            }
        }
    }
?>


Inside photo_dl3.php i can't access all session variables.
I really need help sad.gif
Thanks
User is offlineProfile CardPM

Go to the top of the page

Pradeepk
post 10 Jul, 2007 - 01:40 AM
Post #2


New D.I.C Head

*
Joined: 22 Jun, 2007
Posts: 20


My Contributions


QUOTE(cemplukcute2003 @ 10 Jul, 2007 - 02:11 AM) *

Hello...
I need some help here.
I'm having problem with $_SESSION.
Only in one page suddenly i can't access the session variables.
Can you help me?
CODE

<?php
    include("database_setup.php");

    session_start();

    //Take variable
//    $photoName = $_GET["x1"];
    $photoName = "friend_300.jpg";
    $user = $_SESSION["username"];

    if(strcmp($_GET["x2"], "") == 0) {
        $fileType = "Homepage_Photo";
    }
    else {
        $fileType = "Watermarked_Process";
    }

    if($conn) {
        $query = "SELECT Photo_Location.File_Name, File_Location.File_Location, Photos.Photo_Title ";
        $query .= "FROM Photos, Photo_Location, File_Location ";
        $query .= "WHERE Photo_Location.File_Name = '$photoName' AND Photo_Location.Photo_No = Photos.Photo_No AND ";

        if(strcmp($fileType, "Homepage_Photo") == 0) {
            $query .= "Photos.Username = '$user' AND Photos.Watermark = '0' AND File_Location.File_Type = '$fileType' AND ";
        }
        else {
            $query .= "Photos.Username = '$user' AND Photos.Watermark = '1' AND File_Location.File_Type = '$fileType' AND ";
        }
        $query .= "File_Location.File_Type = Photo_Location.File_Type";

        $queryResult = mysql_query($query);

        if($queryResult) {
            if(mysql_num_rows($queryResult) != 0) {
                $_SESSION["picName"] = mysql_result($queryResult, 0, "File_Name");
                $_SESSION["location"] = mysql_result($queryResult, 0, "File_Location");
                $_SESSION["title"] = mysql_result($queryResult, 0, "Photo_Title");

                session_write_close();
                header("Location: http://www.sig-share.com/site/photo_dl3.php");
            }
            else {
                echo "not found " . $fileType;
            }
        }
    }
?>


Inside photo_dl3.php i can't access all session variables.
I really need help sad.gif
Thanks




I think in this way u have to do...

$a=$_POST['uname'];
$_SESSION['uname']="$a";

now u can use $_SESSION['uname'] in the entire application....

if any wrong plz mail me back...


User is offlineProfile CardPM

Go to the top of the page

cemplukcute2003
post 10 Jul, 2007 - 02:14 AM
Post #3


New D.I.C Head

*
Joined: 15 Nov, 2006
Posts: 24



Thanked 1 times
My Contributions


QUOTE(Pradeepk @ 10 Jul, 2007 - 02:40 AM) *

I think in this way u have to do...

$a=$_POST['uname'];
$_SESSION['uname']="$a";

now u can use $_SESSION['uname'] in the entire application....

if any wrong plz mail me back...


I already did that in the previous pages. That's why i can access $_SESSION["username"]. But funny things, i can't retrieve it.
User is offlineProfile CardPM

Go to the top of the page

Pradeepk
post 10 Jul, 2007 - 02:36 AM
Post #4


New D.I.C Head

*
Joined: 22 Jun, 2007
Posts: 20


My Contributions


QUOTE(cemplukcute2003 @ 10 Jul, 2007 - 03:14 AM) *

QUOTE(Pradeepk @ 10 Jul, 2007 - 02:40 AM) *

I think in this way u have to do...

$a=$_POST['uname'];
$_SESSION['uname']="$a";

now u can use $_SESSION['uname'] in the entire application....

if any wrong plz mail me back...


I already did that in the previous pages. That's why i can access $_SESSION["username"]. But funny things, i can't retrieve it.


did u start the session in the previous page?
User is offlineProfile CardPM

Go to the top of the page

cemplukcute2003
post 10 Jul, 2007 - 04:43 AM
Post #5


New D.I.C Head

*
Joined: 15 Nov, 2006
Posts: 24



Thanked 1 times
My Contributions


QUOTE(Pradeepk @ 10 Jul, 2007 - 03:36 AM) *

QUOTE(cemplukcute2003 @ 10 Jul, 2007 - 03:14 AM) *

QUOTE(Pradeepk @ 10 Jul, 2007 - 02:40 AM) *

I think in this way u have to do...

$a=$_POST['uname'];
$_SESSION['uname']="$a";

now u can use $_SESSION['uname'] in the entire application....

if any wrong plz mail me back...


I already did that in the previous pages. That's why i can access $_SESSION["username"]. But funny things, i can't retrieve it.


did u start the session in the previous page?


Horay, i found out my mistake smile.gif
It's because i put session_unset() in previous page...
Your reply made me go through my code again.
Pradeepk, thanks for your help biggrin.gif
Really thanks..
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:33AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month