473,406 Members | 2,894 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,406 software developers and data experts.

Writing the output of a function to another file

28
Hello there,

I used 'header' function to call a php page.The output of this page should be sent to a different directory as a file in the directory.

My code is like this
header('location:full_report_exporting.php?test_ru nid='.$test_runids[$i][0]);

Now full_report_exporting.php generates a xls file which i have to store in a directory(name-xls files).

I'm quite new to php and dont know in depth.Can anybody help me with how to achieve this.

Thanks in advance,
Shara.
Mar 12 '07 #1
4 1472
Hello there,

I used 'header' function to call a php page.The output of this page should be sent to a different directory as a file in the directory.

My code is like this
header('location:full_report_exporting.php?test_ru nid='.$test_runids[$i][0]);

Now full_report_exporting.php generates a xls file which i have to store in a directory(name-xls files).

I'm quite new to php and dont know in depth.Can anybody help me with how to achieve this.

Thanks in advance,
Shara.
I did not get the problem. But here
header('location:full_report_exporting.php?test_ru nid='.$test_runids[$i][0]);
you have space between test_ru and nid. is it ok?
and try using
error_reporting(E_ALL); at top of each page.
Mar 12 '07 #2
shara
28
I did not get the problem. But here
header('location:full_report_exporting.php?test_ru nid='.$test_runids[$i][0]);
you have space between test_ru and nid. is it ok?
and try using
error_reporting(E_ALL); at top of each page.
Hello Satya,

That additional space is not there in actual script.It is given here by mistake.

My problem is that full_report_exporting.php generates an xls file taking test_runid as input.Now i want to direct the generated xls file into a directory as a file,say some_file_name.xls.

I also used
shell_exec("/www/ngnsite/D/FSD_ENS_RnD_TTS/project_report/full_report_exporting.php?test_runid=".$test_runid s[$i][0]." > directory_name/file_name");

But i'm not getting the file into the directory.Can you please help me out.Thanks for responding.

Thanks&Regards,
Shara.
Mar 12 '07 #3
ronverdonk
4,258 Expert 4TB
The problem probably lies in the 'full_report_exporting.php'script. So show the code of that script here. ANd do not forget to show that code within PHP or code tags!!!

Ronald :cool:
Mar 12 '07 #4
shara
28
The problem probably lies in the 'full_report_exporting.php'script. So show the code of that script here. ANd do not forget to show that code within PHP or code tags!!!

Ronald :cool:
Hello Ronald,

full_report_exporting.php is working well coz the else part of the below given code is showing the output perfect.

<?php
ob_start();
session_register("SESSION");

require_once("Worksheet.php");
require_once("Workbook.php");
require("../include/smcconf.php");
require("../include/smclib.php");

$smc = new SMC;
$smc->connect("$SMCUSER@$SMCSERVER", "$SMCPASSWD") or die("Can not connect to database!");

function HeaderingExcel($filename)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename" );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}

if(isset($test_runid))
{
$test_run_name="";
$projectid=$SESSION["projectid"];
$test_runid=$_GET['$test_runid'];
$sql = "select test_run_name
from test_run
where test_runid = (".$test_runid.")";
$smc->query($sql) or die("<h4>Error in selecting feature<br><br>".$sql."</h4>");
$test_run_name= $smc->result;
$project_name=$SESSION["project_name"];
}
else
{
$projectid=$SESSION["projectid"];
$test_runid=$SESSION["test_runid"];
$project_name=$SESSION["project_name"];
$test_run_name=$SESSION["test_run_name"];
}

$filename = "full_report_".$project_name."_".$test_run_nam e;
$filename = str_replace('.', '_', $filename);
$filename = str_replace('/', '_', $filename);
HeaderingExcel($filename.".xls");

$workbook = new Spreadsheet_Excel_Writer_Workbook("-");

$worksheet1 =& $workbook->addWorksheet("Test List");
$worksheet1->setColumn(1, 35, 5);

$worksheet2 =& $workbook->addWorksheet("FAILED TESTS");
$worksheet2->setColumn(1, 25, 5);

$worksheet3 =& $workbook->addWorksheet("DDTS REPORT");
$worksheet3->setColumn(1, 25, 5);

$worksheet4 =& $workbook->addWorksheet("Test Tracking Chart");
$worksheet4->setColumn(0, 0, 25);
$worksheet4->setColumn(1, 100, 6);

$worksheet5 =& $workbook->addWorksheet("Test Statistics");
$worksheet5->setColumn(1, 25, 5);

?>

The whole code is very big stretching to 2000 lines.I think the above part of code is sufficient to find if a problem is existing coz i'm using the variable passed in shell_exec command only in the above part.

Thanks for acknowledging my mail.i will be grateful if you can guide me out through this.

Thanks&Regards,
Shara.
Mar 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: rob | last post by:
hey every1, I've got alot of data to write out to file and it's all just 1's and 0's. It's all stored in 2 dimensional arrays of width 32 and varying height. At the moment it's all just...
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
7
by: happy | last post by:
I will reissue my question . How to form and write string field to a disk file in one statement usinf fprintf? my struct as below : struct record { char customer_name; int customer_no;...
5
by: grinder | last post by:
first off, i am an extreme newbie to C. i am an undergrad research assistant and i have been shifted to a project that involves building a fairly involved c program. The part that i am stuck on now...
2
by: totoro2468 | last post by:
Here is my code and output. Why is it writing to the array incorrectly, when I rewinded the file to the beginning? CODE: void ReadString (char *filename, int *lengthPtr) { FILE *ifp; char...
6
by: uche | last post by:
can someone tell me if this is a correct way to writing a vector of structure to a file... will this write the contents of a vector into the file? bool Cwrite (vector <struct&write, const string...
1
by: Smita Prathyusha | last post by:
I am facing a problem in writing to COM1. I am using a Win 32 Console mode Program in VC++ the following is the code: If anyone can help me out it will be of great help : // SC_Using_Classes.cpp...
4
by: FingerDemon | last post by:
I'm guessing I'm missing something obvious here, but I have searched around and re-read my Python books and references on simple file writing and I can't see the answer. I am running this in Windows...
2
by: mauricesmith42 | last post by:
Sorry i know this is rather large to be posting, but in order to understand the question you have to see all the code //#include <windows.h> //needed for opening folders #include...
0
by: Gabriel Genellina | last post by:
En Tue, 13 May 2008 11:57:03 -0300, Dmitry Teslenko <dteslenko@gmail.com> escribió: Is the code above contained in a function? So all references are released upon function exit? If not, you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.