Click here to get back home

Session variable doesn't pass, query error

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Session variable doesn't pass, query error JRough 07-25-2008
Get Chitika Premium
Posted by JRough on July 25, 2008, 3:00 pm
Please log in for more thread options
I have this nice bad_orderXL.php page that works, calls some queries
and prints to the browser:
---------------

Validate_login("bad_order.php");

if($_SESSION["LMS_USER_DESC"]=='customer'){
$id = $_SESSION["LMS_LOGGED_IN"];
}elseif(empty($id)){
$id = 0;
}


# GET CARS FOR GIVEN PARAMETER?
if($_SESSION["LMS_USER_DESC"] == "customer"){
$result = SELECT_bad_orderCustomer($id,CLM_order_by($order_by));
$TPL_carnumbers = GetHeaders($id);
$MSG_carlist = "BAD ORDER CARS";
}elseif($_SESSION["LMS_USER_DESC"] == "internal"){
if($id){
$result = SELECT_bad_order(CLM_order_by($order_by));
$TPL_carnumbers = GetHeaders($id);
$MSG_carlist = "BAD ORDER CARS ".GetLeaseCompName($id);
}else{
$result = SELECT_bad_orderLeased($id,CLM_order_by($order_by));
$TPL_carnumbers = GetRouteHeaders($id);
$MSG_carlist = "BAD ORDER CARS";
}
}
if ($_POST['assign']!='Open in Excel'){

if(mysql_numrows($result)==0){
$TPL_carnumbers.= GetNoCarsMsg($th);

}else{
while ($row = mysql_fetch_assoc($result)){
$TPL_carnumbers.=MakeSighting($id,$row);
}
}

$TPL_carnumbers.="</table>";

include "header.php";
include $template_path."template_carlist.html";
include "footer.php";
}elseif ($_POST['assign']=='Open in Excel'){
        Header("Location: bad_orderXL.php");
exit;
}

The problem is here at the botton with the post to Excel. If the user
choses he can open it in Excel. It redirects to the bad_orderXL.php
page. On this page I get this error:

"Fatal error: Cannot redeclare getheaders() (previously declared in /
home/dhandler/public_html/fakerockridge/bad_orderXL.php:123) in /home/
dhandler/public_html/fakerockridge/bad_orderXL.php on line 207"

Line 123 doesn't have the getheaders query by the way.

I think it is not getting the parameter $id. I think All I need is
the variable $id from the preivous page for this to work on the excel
page. I have the same code on the bad_orderXL.php page as the
bad_order.php page. I did put session_start() at the top.

How to get the $id to the second page? since this code is repeated
shouldn't it get the right info the second time?
It would be better if I could just pass the $id in that post
statement but I just want to get the page to open in Excel I don't
care how at this point.

if($_SESSION["LMS_USER_DESC"]=='customer'){
$id = $_SESSION["LMS_LOGGED_IN"];
}elseif(empty($id)){
$id = 0;
}

The id does not seem to pass to the query here and I think that is why
I get an error but I can't figure out why except maybe it is a 2nd
instance of $id and doesn't know which one it is but I am re-checking
the Session variable and restating it so it should work on the next
page???

function GetHeaders($id){
return "<table>
                <th><a href='bad_order.php?id=".$id."&order_by=l_e'>L_E</a></th>
                <th><a href='bad_order.php?id=".$id."'>Carnumber</a></th>
                <th><a href='bad_order.php?id=".$id."&order_by=location'>Location</
a></th>
                <th><a href='bad_order.php?id=".
$id."&order_by=sighting_date'>Sighting Date</a></th>
                <th><a href='bad_order.php?id=".$id."&order_by=classification'>Code</
a></th>
                <th><a href='bad_order.php?id=".$id."&order_by=railroad'>RR</a></th>
                <th><a href='bad_order.php?id=".$id."&order_by=origin'>Origin</a></
th>
                <th><a href='bad_order.php?id=".
$id."&order_by=destination'>Destination</a></th>
                <th width='15%'>ETA</th>";
}

If you could tell me how to pass $id or if you could tell me why I
shouldn't repeat the code twice?
I need answers. Is there any rudimentary trouble shooting I can use.
I don't have Zend configured with my server yet.

thanks,

Janis

Posted by Jerry Stuckle on July 25, 2008, 11:01 pm
Please log in for more thread options
JRough wrote:
> I have this nice bad_orderXL.php page that works, calls some queries
> and prints to the browser:
> ---------------
>
> Validate_login("bad_order.php");
>
> if($_SESSION["LMS_USER_DESC"]=='customer'){
> $id = $_SESSION["LMS_LOGGED_IN"];
> }elseif(empty($id)){
> $id = 0;
> }
>
>
> # GET CARS FOR GIVEN PARAMETER?
> if($_SESSION["LMS_USER_DESC"] == "customer"){
> $result = SELECT_bad_orderCustomer($id,CLM_order_by($order_by));
> $TPL_carnumbers = GetHeaders($id);
> $MSG_carlist = "BAD ORDER CARS";
> }elseif($_SESSION["LMS_USER_DESC"] == "internal"){
> if($id){
> $result = SELECT_bad_order(CLM_order_by($order_by));
> $TPL_carnumbers = GetHeaders($id);
> $MSG_carlist = "BAD ORDER CARS ".GetLeaseCompName($id);
> }else{
> $result = SELECT_bad_orderLeased($id,CLM_order_by($order_by));
> $TPL_carnumbers = GetRouteHeaders($id);
> $MSG_carlist = "BAD ORDER CARS";
> }
> }
> if ($_POST['assign']!='Open in Excel'){
>
> if(mysql_numrows($result)==0){
> $TPL_carnumbers.= GetNoCarsMsg($th);
>
> }else{
> while ($row = mysql_fetch_assoc($result)){
> $TPL_carnumbers.=MakeSighting($id,$row);
> }
> }
>
> $TPL_carnumbers.="</table>";
>
> include "header.php";
> include $template_path."template_carlist.html";
> include "footer.php";
> }elseif ($_POST['assign']=='Open in Excel'){
>         Header("Location: bad_orderXL.php");
> exit;
> }
>
> The problem is here at the botton with the post to Excel. If the user
> choses he can open it in Excel. It redirects to the bad_orderXL.php
> page. On this page I get this error:
>
> "Fatal error: Cannot redeclare getheaders() (previously declared in /
> home/dhandler/public_html/fakerockridge/bad_orderXL.php:123) in /home/
> dhandler/public_html/fakerockridge/bad_orderXL.php on line 207"
>
> Line 123 doesn't have the getheaders query by the way.
>

What is on line 123 of your source code? And are you *sure* you're
looking at the correct file? I've never seen this have the wrong line
number (although I suppose it is possible).

Are you maybe including a file twice? Use include_once or require_once
instead of include or require.

> I think it is not getting the parameter $id. I think All I need is
> the variable $id from the preivous page for this to work on the excel
> page. I have the same code on the bad_orderXL.php page as the
> bad_order.php page. I did put session_start() at the top.
>

Why do you think that?

> How to get the $id to the second page? since this code is repeated
> shouldn't it get the right info the second time?
> It would be better if I could just pass the $id in that post
> statement but I just want to get the page to open in Excel I don't
> care how at this point.
>

Not necessarily. You store it in the $_SESSION array and later retrieve it.

But you never showed us how you stored the value in the $_SESSION array,
so it's impossible to tell.

> if($_SESSION["LMS_USER_DESC"]=='customer'){
> $id = $_SESSION["LMS_LOGGED_IN"];
> }elseif(empty($id)){
> $id = 0;
> }
>
> The id does not seem to pass to the query here and I think that is why
> I get an error but I can't figure out why except maybe it is a 2nd
> instance of $id and doesn't know which one it is but I am re-checking
> the Session variable and restating it so it should work on the next
> page???
>
> function GetHeaders($id){
> return "<table>
>                 <th><a href='bad_order.php?id=".$id."&order_by=l_e'>L_E</a></th>
>                 <th><a href='bad_order.php?id=".$id."'>Carnumber</a></th>
>                 <th><a href='bad_order.php?id=".$id."&order_by=location'>Location</
> a></th>
>                 <th><a href='bad_order.php?id=".
> $id."&order_by=sighting_date'>Sighting Date</a></th>
>                 <th><a href='bad_order.php?id=".$id."&order_by=classification'>Code</
> a></th>
>                 <th><a href='bad_order.php?id=".$id."&order_by=railroad'>RR</a></th>
>                 <th><a href='bad_order.php?id=".$id."&order_by=origin'>Origin</a></
> th>
>                 <th><a href='bad_order.php?id=".
> $id."&order_by=destination'>Destination</a></th>
>                 <th width='15%'>ETA</th>";
> }
>
> If you could tell me how to pass $id or if you could tell me why I
> shouldn't repeat the code twice?
> I need answers. Is there any rudimentary trouble shooting I can use.
> I don't have Zend configured with my server yet.
>
> thanks,
>
> Janis
>

I don't understand why you are repeating code anyway. If it's going to
be used in multiple files, put it in a function in its own file, then
include that file where appropriate.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Similar ThreadsPosted
Fatal error: Session variable IsAdminLoggedIn is not globally defined December 5, 2004, 1:39 am
cannot pass query string (GET) vars October 25, 2007, 1:26 pm
Pass By Ref Error August 24, 2005, 2:45 pm
pass variable to xpath? February 1, 2005, 5:23 pm
To pass a PHP variable to javascript January 29, 2006, 8:48 am
Pass Variable to another script June 5, 2006, 10:02 am
Pass by reference via 'return' a variable... October 10, 2006, 1:48 pm
how to pass the javascript array value to for the php variable. September 11, 2007, 1:30 am
Using header("Location:...". How to pass over array variable? February 2, 2005, 1:48 am
how to pass form imput as variable to mysql? June 13, 2005, 9:55 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap