|
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
==================
|