Calendar Awards Members List FAQ
Notices

Reply
$ LinkBack Thread Tools
 
  #1   [ ]
Old 10-29-2003, 04:02 PM
sea sea is offline
Join Date: Feb 2003
Location: Toronto
View Posts: 17,296
[Tech](php help)Random file .php troubles

Not sure if this is the greatest place to put this, as it isn't schoolwork-related, but whatever. I need some help. I'm using a random file .php for my signature, which works fine. However, I'm trying to get it to play random music when it is clicked on. It was working a day or so ago, but now I am prompted to download a file, which displays random gibberish (well, to me, anyways ). The code is as follows:

Quote:

<?php

$st= $_REQUEST['st'];
$fn= $_REQUEST['fn'];
$et= $_REQUEST['et'];

$st='0';

$fn='4';

$et='mid';

readfile(rand($st,$fn) . '.' . $et);
?>


I don't really know any php, I just got this stuff from Yoshi 15. Maybe I should be asking him...well, whatever.

I'm using the url "http://acious.50free.net/music.php", minus the quotes, of course. It was working fine before (opened up Windows Media Player, started playing song), but now it asks me to download an html file, which doesn't make sense to me, considering that it worked before. All the files are in the folder.
Reply With Quote
  #2   [ ]
Old 10-31-2003, 06:57 PM
Captain Tact
Send a message via ICQ to Dryth Send a message via AIM to Dryth
Join Date: May 2003
Location: Palo Alto, California
View Posts: 2,001
Re: [Tech](php help)Random file .php troubles

Sorry for replying a bit late.... I don't read this section often.

What you're seeing or being made to download is the actual "code" of the image that you're supposed to be viewing. The reason you're seeing this is Yoshi 15's method basically takes the code of the image on the server, and throws it at your browser, assuming it'll sort everything else out on its own.

Why do some browsers handle it properly, and some don't? Or different servers produce different results? Most of the time when files are sent to your web browser, they're sent with a header that tells your browser how it should handle the image. Using Yoshi 15's method, the wrong information is sent in this header. Again, some browsers and webservers will deal with it better than others.

Try using the second method suggested by Mercutio, or the method I suggest, over in Signature Chit-Chat.

How are these methods different? Instead of sending a raw image, they send just header code. This header code basically points your browser to another file somewhere on a webserver, which it downloads just as it would any other normal image, letting the server and browser handle the images the way they're used to.

Sorry if I've provided a bit too much unnecessary information. Worth being educational, though.
__________________
dobs.org E3 News Feed
Reply With Quote
Sponsored Links
  #3   [ ]
Old 10-31-2003, 07:01 PM
sea sea is offline
Join Date: Feb 2003
Location: Toronto
View Posts: 17,296
Re: [Tech](php help)Random file .php troubles

Erm...I don't know if youn interpreted that correctly. I'm talking about problems while playing the random songs, not the images themselves.

It seems that Windows Media Player can sort it out properly, though. Once I reinstalled it, it started working again.
Reply With Quote
  #4   [ ]
Old 10-31-2003, 07:06 PM
Captain Tact
Send a message via ICQ to Dryth Send a message via AIM to Dryth
Join Date: May 2003
Location: Palo Alto, California
View Posts: 2,001
Re: [Tech](php help)Random file .php troubles

Oh, well that works then.

It applies for pretty much all cases where you're pointing something to a randomizer file on a webserver, that you should be using the alternate methods. It'll always ensure that your browser and whatever you're viewing with know exactly how to handle the content they receive.
__________________
dobs.org E3 News Feed
Reply With Quote
Sponsored Links
  #5   [ ]
Old 10-31-2003, 07:15 PM
sea sea is offline
Join Date: Feb 2003
Location: Toronto
View Posts: 17,296
Re: [Tech](php help)Random file .php troubles

Alright, I'll try switching over to it. We'll see how it works.

By the way, just wondering...exactly how many signatures do you actually have?
Reply With Quote
  #6   [ ]
Old 10-31-2003, 07:16 PM
I'm so unactive
Send a message via AIM to Yoshi Send a message via MSN to Yoshi
Join Date: Nov 2002
Location: West Milford, NJ
View Posts: 1,060
Re: [Tech](php help)Random file .php troubles

Try this code for your problem:

<?php

$st= $_REQUEST['st'];
$fn= $_REQUEST['fn'];
$et= $_REQUEST['et'];

$st='0';

$fn='4';

$et='mid';

header('Location: ' . rand($st,$fn) . '.' . $et);
?>
__________________

Currently Under Construction
Reply With Quote
Sponsored Links
  #7   [ ]
Old 10-31-2003, 07:25 PM
sea sea is offline
Join Date: Feb 2003
Location: Toronto
View Posts: 17,296
Re: [Tech](php help)Random file .php troubles

Yoshi: Well, now it's using Quicktime, but that's fine. I'll ask OKO or someone if they're still having problems.
Reply With Quote
  #8   [ ]
Old 10-31-2003, 08:06 PM
Captain Tact
Send a message via ICQ to Dryth Send a message via AIM to Dryth
Join Date: May 2003
Location: Palo Alto, California
View Posts: 2,001
Re: [Tech](php help)Random file .php troubles

Yoshi's latest alteration should make things a lot happier.

Currently I have 23 random signature images on rotation here at ZU. I have another 10 completed signature images that I use on various other forums, and roughly 30 half-complete signature images that I keep around either for use in my own signatures one day, or in case people start requesting.
__________________
dobs.org E3 News Feed
Reply With Quote
Sponsored Links
  #9   [ ]
Old 10-31-2003, 08:14 PM
sea sea is offline
Join Date: Feb 2003
Location: Toronto
View Posts: 17,296
Re: [Tech](php help)Random file .php troubles

Wow, and I thought that my 15 were alot. I've been thinking about breaking from the continuous theme I have right now (same layout, etc.), but I'm not sure...the others wouldn't match if I were to do that. I think I'm going to add some more soon.

Bleh, this is getting kinda OT, so maybe we should quit it.

...

Gah, couldn't help but ask: do you draw anything that is featured in your signatures?
Reply With Quote
  #10   [ ]
Old 10-31-2003, 08:58 PM
Captain Tact
Send a message via ICQ to Dryth Send a message via AIM to Dryth
Join Date: May 2003
Location: Palo Alto, California
View Posts: 2,001
Re: [Tech](php help)Random file .php troubles

Quote:
Gah, couldn't help but ask: do you draw anything that is featured in your signatures?
Not any of the ones featured here at ZU, although a few of the older ones making their rounds on other forums contain bits and pieces of my own artwork.

And with that, may this tangent meet its demise!
__________________
dobs.org E3 News Feed
Reply With Quote
Sponsored Links
Reply

Tags
file, helprandom, php, techphp, troubles

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 05:35 PM.

Contact Us - Zelda Universe - Archive - Privacy Statement - Top