Session variable doesn't pass, query error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have this nice bad_orderXL.php  page that works, calls some queries
and prints to the browser:


  $id = 0;

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"){
    $result = SELECT_bad_order(CLM_order_by($order_by));
    $TPL_carnumbers = GetHeaders($id);
    $MSG_carlist = "BAD ORDER CARS ".GetLeaseCompName($id);
    $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'){

  $TPL_carnumbers.= GetNoCarsMsg($th);

  while ($row = mysql_fetch_assoc($result)){


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

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.

  $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

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</
        <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</
        <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><a href='bad_order.php?id=".
        <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.



Re: Session variable doesn't pass, query error

JRough wrote:
Quoted text here. Click to load it

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.

Quoted text here. Click to load it

Why do you think that?

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

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.

Site Timeline