Sessions
Posted: Thu Apr 30, 2009 7:59 am
Hi, I'm new to this Forum and I have a problem with Sessions that I've wrecking my head over for the last day I suppose.
So here it is: Basically, I want to use a Session Variable. I want to use it for submitting Blogs. I have a MYSQL table, which holds a pNO(picture number), userName and uPost (Users Post).
Basically, I have the Sessions working in my Website.
However, I want to read a Session Variable and assign it to a normal variable. I will then use it in a Query for my MYSQL database.
This is the code I came up with:
Ok, thats basically the Just of the Code, I just need to be able to assign a Session Variable to a Normal Variable.
Anyone able to propose a solution!?
Kind Regards,
David Harvey
So here it is: Basically, I want to use a Session Variable. I want to use it for submitting Blogs. I have a MYSQL table, which holds a pNO(picture number), userName and uPost (Users Post).
Basically, I have the Sessions working in my Website.
However, I want to read a Session Variable and assign it to a normal variable. I will then use it in a Query for my MYSQL database.
This is the code I came up with:
Code: Select all
if (session_is_registered('userName')){
/////////////// Get pNumber//////////////////////////////
$Query = "SELECT count(DISTINCT piNO) FROM tbl_Iblog";
$Result = @mysql_query ($Query);
$QueryResult = mysql_fetch_array($Result, MYSQL_NUM);
$pNIncrement = $QueryResult[0] + 1;
$uName = $userName; // <-------------- That is me attempting to use the Session Variable.
/////////////// POST/////////////////////////////////////
$Query = "insert into tbl_Iblog values('$pNIncrement','$uName','$post')";
mysql_query ($Query);
}
Ok, thats basically the Just of the Code, I just need to be able to assign a Session Variable to a Normal Variable.
Anyone able to propose a solution!?
Kind Regards,
David Harvey