alright :)
my cron job run a php script every 10 minutes
this php script has 3 calls to functions in another page
I have few tables already in my database
a call to remove database table -- (i have to do that)
a call to create table in my database
a call to read a table in text format (url) -- and insert this data into my database table
-----------
...
User Profile
Collapse
-
Running cronjob on php script -> constantly running out of disk space
Hi
I'm trying to run a cronjob on a php script
everything is working fine, but I'm getting my server disk space fulled up - so what's wrong here ???
how can I fix this problem ? -
alright, I've replied to your PM... please read it
I think there's just a little thing that is wrong with my codes !Leave a comment:
-
hmmm.. see this...
i try it - it's not working... kinda missing something !
in the page that should have the specified sql with a link to excel[php]
$result = mysql_query($_G ET['sql']);
generateLink($r esult);
function generateLink($r esult)
{
$rand = rand();
echo"
<a href=\"excel.ph p?result=$resul t&rand=$rand\"> download</a>...Leave a comment:
-
Alright,
when I've used your first way:
I got a new file for each call to the function
and that's not what I want because that will make many many files
as I need to use one file only
I tried to use the second way you've suggested
but !!! I was getting the data displayed in the browser as text
what I need is to get a box where it allows the user to OPEN/SAVE...Leave a comment:
-
Okay I guess I didn't explain well what's going on...
I have several wepages
each have different SQL statement
each call exportToExcel function
each after calling, they have a link to the excelFile.xls
so when user click on this link - a save/open box of an excelFile.xls pop up
so i need to use fopen/fwrite/fclose, right !
here's a sample SQL page:
[php]
...Leave a comment:
-
I'm still getting the problem :(
here's my code:
[php]
$filename = "excelFile.xls" ;
$sql = ".............. .....";
$sqlRes = mysql_query($sq l) or die(mysql_error ());
if(file_exists( $filename))
{
unlink($filenam e);
}
$fp = fopen($filename ,'w');
while($line = mysql_fetch_ass oc($sqlRes))
{
...Leave a comment:
-
I've used the second code
but
same problem !
when i use 2 or 3 different sql using the exportToExcel function, while i'm still in the same window(browser) / i always get the first sql excel file as a result
now when i look inside my directory.. i see that the content of the excel file has been changed
and when i open a new window(browser) for each sql , i get their correct...Leave a comment:
-
alright, there's something strange here !
I have something wrong with memories ! or cookies !
if i run this exportToExcel function on SQL_1
i get a result ---- great !
but when i change SQL_1 to SQL_2
and run the function
i get the same file of SQL_1 !!!!!
i don't get the SQL_2 file until i delete manually the excelFile.xls
-----------...Leave a comment:
-
it was just... a mistake
wrong: [php]fwrite($fp,impl ode("\t", array_keys($lin e)))."\n";[/php]
correct: [php]fwrite($fp,impl ode("\t", array_keys($lin e))."\n");[/php]
do you know how to change colors of the text and size... bold the fields name... etc ... in php .. that reflex EXCEL file !!...Leave a comment:
-
I got it working :D
as simple as this:
[php]
$sql="....";
$result = mysql_query($sq l);
$fp = fopen("file.xls ",'w');
$result = mysql_query($sq l);
while($line = mysql_fetch_ass oc($result))
{
if(empty($cols) )
{
fwrite($fp,impl ode("\t", array_keys($lin e))."\n");
...Leave a comment:
-
PBmods, I've tried the last code in your previous post -- it didn't work !
instead i did this:
[php]
$sql="........" ;
$result = mysql_query($sq l);
$fp = fopen("file.xls ",'w');
$result = mysql_query($sq l);
while($line = mysql_fetch_ass oc($result))
{
if(empty($cols) )
{
fwrite($fp,impl ode("\t", array_keys($lin e)))."\n";...Leave a comment:
-
-
thanks :)
the fields i'm using doesn't have commas.. although it didn't work with a coma ------ it was showing in excel column A this: a,3
anyway.. when I've used a tab ... THINGS WORKED .......that's because it considered it as text... when u have a table inside a text saparated by tabs and return charachters, and change the extension to xls... you'll find the table inserted perfectly inside excel
I...Leave a comment:
-
i did that
no commas show up .. and same output ( fields saparated by a tab inside one excel column)
[php]
<?
$sql = "SELECT field1,field2 FROM MyTable Where field2>1";
$result = mysql_query($sq l) or die(mysql_error ());
$fp = fopen('file.xls ', 'w');
while($line = mysql_fetch_row ($result))
{
foreach($line as $column)...Leave a comment:
-
lloolllz long discusion :)
okay with this code:
[php]
<?
$sql = "SELECT field1,field2 FROM MyTable Where field2>1";
$result = mysql_query($sq l) or die(mysql_error ());
$fp = fopen('file.xls ', 'w');
while($line = mysql_fetch_row ($result))
{
foreach($line as $column)
{
fputcsv($fp,...Leave a comment:
-
and when I've tried to open file.xls itself from the browswer
www.websiteName .com/file.xls
I have the box to open or save this file
and when i've opened it !!! i got it empty !!!!Leave a comment:
-
and I found a file in my directory called "file.xls"
but it's empty !!!
(i'm sure sql query have data in it !! )Leave a comment:
-
I did ------------ got nothing displayed and no box poped up asking me if i wonna open or save the file :(
[php]
$sql = "SELECT field1,field2,f ield3 FROM MyTable WHERE field3='3'";
$result = mysql_query($sq l) or die(mysql_error ());
$fp = fopen('file.xls ', 'w');
foreach ($result as $line)
{
fputcsv($fp, split('\t', $line));
}
fclose($fp);...Leave a comment:
-
oh okay ! ... does that look better?
[php]
<?
$sql = "SELECT field1,field2,f ield3 FROM MyTable WHERE field3='3'";
$result = mysql_query($sq l) or die(mysql_error ());
$fp = fopen('file.xls ', 'w');
foreach ($result as $line)
{
fputcsv($fp, split('\t', $line));
}
fclose($fp);
header("Content-type: application/x-msdownload");...Leave a comment:
No activity results to display
Show More
Leave a comment: