Put URL and garbage in result from PHP

Michael Kann mikekann at yahoo.com
Mon Oct 8 22:59:42 EDT 2012


Mark,

The filler "1f41" is the hex number for 8001 decimal, which is the number of bytes of real data that is coming next. It looks like it is telling you how many bytes you are going to get (in hex), then giving you the bytes you want. The "1e7d" at the end might be the number of data bytes left over that don't fill out the last chunk of 8001.

Why it does that I don't know.

Mike



--- On Mon, 10/8/12, Mark Schonewille <m.schonewille at economy-x-talk.com> wrote:

From: Mark Schonewille <m.schonewille at economy-x-talk.com>
Subject: Put URL and garbage in result from PHP
To: "How to use LiveCode" <use-livecode at lists.runrev.com>
Date: Monday, October 8, 2012, 9:58 AM

Hi,

I'm downloading a list of words of 9 characters from a MySQL database using a PHP script and a put URL command in a LiveCode script. Altogether, there are approximately 10000 lines in my list, with one word on each line.

Both the PHP script and the LiveCode script run on Mac OS X. I use a put URL command in my LiveCode script, such as

put url "http://localhost/~user/list.php"

The relevant part of the PHP script is:

$q="SELECT xword FROM ydatabase";
$r=mysql_query($q);
if (!$r) {
    echo 'An error occurred: '.mysql_error();
}
else {
    while ($row = mysql_fetch_array($r)) {
        echo "$row[0]\n";
    }
}

Exactly every 8001 bytes (or 889 words, which are all different), I get some garbage:

1f41
AAAAAAAAA
AAAAAAAAB
[889 times]
AAAAAAAAC
1f41
AAAAAAAAP
AAAAAAAAQ
[889 times]
AAAAAAAAR
etc etc etc
BBBBBBBBX
1e7d

The garbage is often the same but not always and it appears before the first line and after the last line. I have tried several combinations of the content-type and content-transfer-encoding headers in PHP. I have also tried changing the encoding of the PHP script itself.

If I call the same URL from CURL and pipe the output to a text file or if I open the URL in a browser, I don't see any garbage:

AAAAAAAAA
AAAAAAAAB
[889 times]
AAAAAAAAC
AAAAAAAAP
AAAAAAAAQ
[889 times]
AAAAAAAAR
etc etc etc
BBBBBBBBX

Does anyone have an idea what causes LiveCode to add garbage to my list?

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour spaces. http://www.color-converter.com




_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list