473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How do I set a $_SESSION variable

This is page is called to delete a row on a table using form input. I
set a session variable based on the result of mysql_query and want to
pass it back to the caller like this.

if (mysql_query($deleteSQL,$emailmanager) &&
mysql_affected_rows()>0) {
$_SESSION["mysql_query_result"] = "Your email address has been
successfully removed";
}else {
$_SESSION["mysql_query_result"] = "Your email address was not
found. Please try again";
}

.....

Here is the return code (generated by Dreamweaver) -

header(sprintf("Location: %s", "http://".$_SERVER['HTTP_HOST'].
$deleteGoTo));

How do I return the session variable to the caller? The $_SESSION
array does not exist on return to the caller. I check it using this
print code -

while ($var = each($_SESSION)) {
printf ("Session key <b>%s</bhas the value of: <b>%s</b><br>",
$var['key'], $var['value']);
}

Aug 13 '07 #1
1 1429
Rik
On Tue, 14 Aug 2007 00:33:48 +0200, Big Moxy <bi*****@gmail.comwrote:
This is page is called to delete a row on a table using form input. I
set a session variable based on the result of mysql_query and want to
pass it back to the caller like this.

if (mysql_query($deleteSQL,$emailmanager) &&
mysql_affected_rows()>0) {
$_SESSION["mysql_query_result"] = "Your email address has been
successfully removed";
}else {
$_SESSION["mysql_query_result"] = "Your email address was not
found. Please try again";
}

....

Here is the return code (generated by Dreamweaver) -

header(sprintf("Location: %s", "http://".$_SERVER['HTTP_HOST'].
$deleteGoTo));

How do I return the session variable to the caller? The $_SESSION
array does not exist on return to the caller. I check it using this
print code -

while ($var = each($_SESSION)) {
printf ("Session key <b>%s</bhas the value of: <b>%s</b><br>",
$var['key'], $var['value']);
}
An foreach loop would be less archaic.

To the point: you have to call session_start() on _every_ page.
--
Rik Wasmus
Aug 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET...
5
by: Ken | last post by:
What am I doing wrong? I set the variable co_name on the first page with an <input.... > and session_start() at the top of both pages. Clicking on a link that takes me to the second page: ...
3
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even...
4
by: comp.lang.php | last post by:
This is an urgent request (as always) generate_admin_customer_position_dropdown($customerResult, $customerResult->id); print_r($_SESSION); This code will generate an HTML dropdown as...
12
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if...
15
by: Evil Otto | last post by:
My page loads, and calls an init() function that returns content to a div on the page, as well as setting a $_SESSION variable. The content it returns includes a link that calls the same variable,...
1
by: bsprogs | last post by:
I am currnetly programming a file hosting website in PHP and I am slowly integrating AJAX into the website. Here is my problem: The user uploads the file. The server processes the file and...
4
by: dpinion | last post by:
Greetings, I am trying to do some simple session stuff. However it does not seem as though the session variable is being created for my site. I am running the latest version of PHP and apache that...
2
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session...
4
TheServant
by: TheServant | last post by:
Hi guys, This is my situation. I have 3 sets of data used on every page of my website. Two of these never change, and the reason they are stored in MySQL and recalled into the $_SESSION variable is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.