On Thu, 13 Jun 2002, Brad Wright wrote:
> well i got the wav files from the mysql database and can get them to play in
> a web page using the following code:
> 
> ************
> 
> IF ($row = mysql_fetch_array($result))  {
> 
> 
> $data = $row["wavFile"];
>   $name = $row["wav FileName"];
>   $size = $row["wav FileSize"];
>   $type = $row["wav FileType"];
>  header("Content-type: $type");
>   header("Content-length: $size");
>   /header("Content-Disposition: attachment; filename=$name");
>   header("Content-Description: PHP Generated Data");
> echo  $data;
> 
> *************
> 
> 
> BUt the problem I am having is that this code gives me a blank age with a
> Quicktime control bar in the middle of it. The wav file plays fine. Any
> other htm underneath this php script is ignored.
> 
> How can i get the (html) code following this to be output to the webpage????
> All my tags seem correct (ie the <?PHP and ?> tags etc are done correctly).

Think of what a regular HTML page containing an embedded media item looks 
like. 

The embedded media and the HTML were not sent to your browser at the same 
time.

The HTML contains a REFERENCE to the media item.

When you generate content with PHP, you have to follow the same rules - 
the browser doesn't know anything about PHP, it just sees what you send 
and expects it to look like HTML or whatever.

So you need to do two things:

1) Generate the HTML page and send it to the browser. That HTML page can 
contain a reference to the embedded media item (how you do that depends on 
the type of media and it's beyond the scope of this list; I'll just use a 
JPEG image as an example).

2) Generate the media item and send it to the browser, which will request 
it when it has finished parsing the HTML from 1) above.

So, you'd have some PHP like:

<? echo "<img src='anotherPHPfile.php/12/whatever.jpg'>" ?>

And then in anotherPHPfile.php you'd examine PATH_INFO to get that number 
12, look up 12 in your database and retrieve the appropriate content, send 
the headers, then send the data.

Just like a JPEG file can't contain HTML, neither can the WAV file that
you send to the browser. Have you ever seen a WAV file with HTML inside
it?

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to