/    Sign up×
Community /Pin to ProfileBookmark

Program saving bizzare output…

I’ve got couple of programs that are supposed to export to a csv file and they normally work fine. But every once in a while it outputs data that looks like:

[code]ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿR o o t E n t r y ÿÿÿÿÿÿÿÿÿÿÿÿ þÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ þÿÿÿ [/code]

Uh, what? ?
Did I accidentally use a reserved variable or something?
I’m kind of hesitant to give out the code I was working on but I can if nobody here has seen this before.

Thanks.

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsApr 27.2006 — Probably caused by the use of chr() being passed a number larger than 255.
Copy linkTweet thisAlerts:
@gopher292authorApr 27.2006 — No, It doesn't make any chr() calls.

I thought the 'Root Entry' part of the output looked familiar. (Scroll to the right to see it in the first post) It's the first 1536 Bytes of an excel file. Which is even more confusing since my program doesn't do anything with excel files.

So here is the program code:[code=php]<?php

$infile="dump.txt";
$outfile="domains2.csv";
$minalexa=10;

$data=array("");
$alexa=array("");
$page=file_get_contents($infile);
$data=explode("rn", $page);
for($i=0;$i<count($data);$i++) {
echo "Alexa traffic for ".$data[$i].": ";
$page=file_get_contents('http://alexadex.com/ad/url/'.$data[$i]);
if(stristr($page, '$')!=FALSE) {
$page=stristr($page, '$');
$alexa[$i]=substr($page, 0, strpos($page, '<'));
$alexa[$i]=str_replace("$", "", $alexa[$i]);
$alexa[$i]=str_replace(",", "", $alexa[$i]);
echo $alexa[$i]."n";
} else {
echo "0n";
}
}
print_r($alexa);
$output="";
for($i=0;$i<count($data);$i++) {
if($alexa[$i]>=$minalexa) {
$output=$output.$data[$i].",".$alexa[$i]."rn";
}
}
file_put_contents($outfile, $output);

?>[/code]


I'm not positive that it's from an excel file, it might be something in Windows XP since the Word header looks similar too.

...Help?... :p
Copy linkTweet thisAlerts:
@gopher292authorApr 27.2006 — >Bump<

<excuse>I was helping some other people on the board and my message kept getting pushed down.</excuse>

... :p ...
Copy linkTweet thisAlerts:
@fciApr 27.2006 — post some values that would be in the $infile
Copy linkTweet thisAlerts:
@gopher292authorApr 27.2006 — example $infile that makes the program output bad data (at least for me):
http://www.bushwares.com
http://www.majingonline.com
http://www.memoe.com
http://www.nominalemlak.com


Thx for the reply.
Copy linkTweet thisAlerts:
@NogDogApr 27.2006 — Any possibilty the input file could have unicode characters in it?
Copy linkTweet thisAlerts:
@fciApr 27.2006 — I googled the term "R o o t E n t r y" but didn't find anything so I tried MSN's beta search

http://beta.search.msn.co.uk/results.aspx?q=%22R+o+o+t+++E+n+t+r+y%22&FORM=QBRE - notice how it will ist the contents of some windows files containing 'r o o t e n t r y'

my general sense is that it's either reading or writing the file incorrectly.. to avoid it, i would try switch to fsockopen from using file_get_contents on the remote URL and fwrite to write the file.. then if it happens again, you know it wasn't those functions..
Copy linkTweet thisAlerts:
@gopher292authorApr 27.2006 — Allright, I found the problem.

It's a bug in OpenOffice. Whenever OpenOffice Calc opens a blank .csv file, it automatically outputs that garbage to it. I tried it with a file that wasn't output by my program and it happened with that one too. I'm submitting a bug report to them.

I found this while trying to implement your suggestions (Nogdog & fci), and probably wouldn't have figured this out if it hadn't have been for you. Thanks alot to both of you. ?

Topic Resolved.
×

Success!

Help @gopher292 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...