Problem phrasing the question.

This is a discussion on "Problem phrasing the question." within the PHP Forum section. This forum, and the thread "Problem phrasing the question. are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old May 10th, 2007, 16:17
Junior Member
Join Date: May 2007
Location: London
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Problem phrasing the question.

I can usually fix computer problems myself using manuals, Google or searching forums. But for this problem I'm not sure where to look, or of the terminology to even phrase the question - or even if I'm in the right forum.
I'm a home user leaning LAMP so I can eventually brighten up my web site. I've been doing an exercise in PHP
The code generates the page OK ( a table filled with links to playlists of my music ) but when I click the links nothing happens.
If I copy the code of the page from the browser and save it as a HTML it all works OK. The playback program (WinAmp in this case) runs with the correct playlist loaded and plays the tracks.
Now I'm sure this is a security related question of some type in that Apache or PHP is stopping the generated web page from executing the program and there's some way to authorize it. Should I be looking into the httpd file, php.ini, .htaccess or somewhere else?
Apache and PHP are running on the same machine that holds the music files.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 10th, 2007, 18:56
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 245
Thanks: 6
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

First of all, it would be really helpful to see the code.

Where are you saving that html file to? And when you open it in a browser (and the links work), are you simply opening it as an html file within your directory structure? Or are you saving it within httpdocs and opening it as a http://localhost/yourpage.html? Also, where are the playlist files saved and how exactly are you referencing them in your links?

My guess is that there's a path issue. If you're saving the html file to the same directory as the php file and accessing it via http via your local host apache server, there's no reason for it to behave any differently as an html file vice a php file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 10th, 2007, 19:41
Junior Member
Join Date: May 2007
Location: London
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

You've helped narrow down the problem already. I hadn't thought of making Apache serve the .htm file. If I put in the browser 'file:///D:/WebDev/Apache/htdocs/local/test.htm' the music links work OK, if I put http://localhost/local/test.htm they don't. That proves the problem is Apache's not something in php. Thanks. Ahh, but how to fix it?...
The playlists and the music files are on my NAS device. The script goes to the playlist directory, lists all the files and sets them up in a table with html links to them. But I have copied one playlist and the directory for that playlists' songs into my D:/WebDev/Apache/htdocs/local/ directory and that doesn't work either. I've included the full code below...
Quote:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My Music</title>

<?php
# User Defined Variables
$background_loc='images/christina_aguilera.jpg'; # background picture for the web page (when I put in the full path it wouldn't work in the browser?)
$target_dir='F:\My Documents\My Music\Playlists'; # The top level directory to be listed
$collection_title="My Music"; # Collection title will appear at the top of the page
# subdirectory titles take their names from the directory itself
$file_extn=".m3u"; # file extensions to strip out
$font_colour="black"; # main font colour
$title_font_colour="red"; # title font colour
$link_colour="yellow"; # link colour in format FFFF66 or red yellow
# Other variables
$array_number=0; # used to count the number of elements in the file array
$count=0; # General counter inside loops
$temp=""; # General temporary string variable
$file_count=0; # Number of files being processed
$loop_count=0; # General counter for loops
$filelist_a=$artist_a=$title_a=""; # Arrays for filename, artist and title
echo '<style type="text/css">
body {font-family:Addled; color:',$font_colour,';}
</style>
</head>';

echo '<body background="',$background_loc,'" style="background-attachment: fixed">';
echo '<font color="',$title_font_colour,'"><h1>&nbsp;&nbsp;&nb sp;',$collection_title,'...</font></h1>';

# Read all files in the current directory (striping out . and ..) into an array
$count=-1; # Set count to -1 so the count increments in step with the array that starts at 0
if ($handle = opendir($target_dir))
{ while (false !== ($file = readdir($handle)))
{ if ($file != "." && $file != "..")
{
$count++;
$filelist_a[]=$file;
}
}
}
closedir($handle);
sort($filelist_a);
$file_count=$count+1; # count+1 because array (and therefore count) starts at 0($filelist_a[$count], "-");
$count=0;
while ($count<>$file_count)
{
$pos = strpos($filelist_a[$count], "-");
# Test to make sure '-' is in the filename
# Note our use of ===. Good practise in case the search character is the first (position 0) which would return a false false
if ($pos === false)
{
$title_a[]="Dash not in filename.";
$artist_a[]=$filelist_a[$count];
}
else
{
# Split the filename in two, trim off trailing spaces and the file extension
$artist_a[]=trim(substr($filelist_a[$count],0,$pos-1));
$title_a[]=trim(substr($filelist_a[$count],$pos+1),$file_extn);
# Constuct the path to the file
$temp='file:///'.$target_dir.'/'.$filelist_a[$count];
$filelist_a[$count]=str_replace(' ','%20',$temp);
}
$count++;
}

echo '<font color="',$title_font_colour,'"><h3>&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;',$file_count,' playlists...</h3>';

# Calculate counter values for two pairs of table columns
$count=0;
$count2=ceil($file_count/2); # ceil rounds fractions up
if (is_float($count2)) {$count2=$count2; $loop_count=$count2-1;} else {$loop_count=$count2;}

//echo '<p><a href="http://www.google.co.uk/">google</a></p>';
//echo '<p><a href="file:///D:/WebDev/Apache/htdocs/local/Pink.m3u">Pink</a></p>';
# Start building the table
echo '<table border="1" width="100%"><tr>';
while ($count<=round($loop_count))
{
# Build table line
echo '<td>',$artist_a[$count],'</td><td>','<p><a href="',$filelist_a[$count],'"><font color="',$link_colour,'">',$title_a[$count],
'</a></p>','</td><td> </td><td>',$artist_a[$count2],'</td><td>','<p><a href="',$filelist_a[$count2],'"><font color="',$link_colour,'">',$title_a[$count2],'</a></p>','</td></tr>';
$count++;
$count2++;
}
echo'</table>
<p><font color="#FFFF00">
<a href="file:///c:/program%20files/winamp.exe">Pink</a></font></p>';
//<a href="file:///D:/WebDev/Apache/htdocs/local/Pink.m3u">Pink</a></font></p>';
//
//
//
// echo "<pre>";
// var_dump($filelist_a);
// echo "</pre>";
// echo "<pre>";
// var_dump($artist_a);
// echo "</pre>";
// echo "<pre>";
// var_dump($title_a);
// echo "</pre>";
//
//
?>

</html>
The resulting html.... (I forced the $loop_count to 3 before running and copying the html as I didn't think a list of my 44 albums would tell you much more than my taste in music
Quote:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My Music</title>

<style type="text/css">
body {font-family:Addled; color:black;}
</style>
</head>
<body background="../images/christina_aguilera.jpg" style="background-attachment: fixed"><font color="red"><h1>&nbsp;&nbsp;&nbsp;My Music...</font></h1><font color="red"><h3>&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;44 playlists...</h3><table border="1" width="100%"><tr><td>All Saints</td><td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/All%20Saints%20-%20All%20Saints.m3u"><font
color="yellow"> All Saints</a></p></td><td> </td><td>Mariah Carey</td><td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/Mariah%20Carey%20-%20Music%20Box.m3u"><font color="yellow">
Music Box</a></p></td></tr><td>Atomic Kitten</td><td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/Atomic%20Kitten%20-%20Right%20now.m3u"><font color="yellow"> Right now</a></p>
</td><td> </td><td>Michael Jackson</td><td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/Michael%20Jackson%20-%20Dangerous.m3u"><font color="yellow"> Dangerous</a></p></td></tr><td>
Avril Lavigne</td><td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/Avril%20Lavigne%20-%20Let%20Go.m3u"><font color="yellow"> Let Go</a></p></td><td> </td><td>Pink</td><td><p>
<a href="file:///F:\My%20Documents\My%20Music\Playlists/Pink%20-%20I'm%20Not%20Dead.m3u"><font color="yellow"> I'm Not Dead</a></p></td></tr><td>Belinda Carlisle</td><td><p>
<a href="file:///F:\My%20Documents\My%20Music\Playlists/Belinda%20Carlisle%20-%20Heaven%20On%20Earth.m3u"><font color="yellow"> Heaven On Earth</a></p></td><td> </td><td>Robbie Williams</td>
<td><p><a href="file:///F:\My%20Documents\My%20Music\Playlists/Robbie%20Williams%20-%20I've%20Been%20Expecting%20You.m3u"><font color="yellow"> I've Been Expecting Yo</a></p></td></tr></table>

<p><font color="#FFFF00">
<a href="file:///D:/WebDev/Apache/htdocs/local/Pink.m3u">Pink</a></font></p>
</html>
Any ideas on how to fix it would be great, but even a pointer in the right direction would be much appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 10th, 2007, 20:00
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 245
Thanks: 6
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

I wouldn't necessarily call that an apache problem, per se. It's more an issue of making sure that file system objects (outside Apache's httpdocs structure) are accessible from a web page. If you create a subdirectory "mysongs" in the directory where your php file exists, then edit the .m3u file to use relative paths ("mysongs/song1.mp3" etc.) then use <a href="test.m3u">play test playlist</a> - I think you'll find it will work fine. Getting apache to look at file:///d:/whatever is tricky. (It's been a while since I've tried this.)

Does your NAS have a webserver on it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old May 10th, 2007, 20:09
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 245
Thanks: 6
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

Maybe this will help- it's a page from a site I'm currently working on...
http://stickpuppy.com/dhs57/yearinreview.php
View the source on that page to get a feel for what it takes to play an m3u file. (NOTE: you don't need to do things like
<a href="file:///c:/program%20files/winamp.exe">Pink</a>
You should just post the links to the m3u files and let your browser handle the app used to play them. (Configure your browser as necessary if Winamp isn't currently the app associated with m3u files.)

Also right click on the jukebox on that page and save the .m3u file somewhere local and have a look at it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old May 10th, 2007, 20:26
Junior Member
Join Date: May 2007
Location: London
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

OK, thanks, I'll have a look tomorrow. It's getting a little late here now to engage the brain. Later...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old May 13th, 2007, 12:15
Junior Member
Join Date: May 2007
Location: London
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

The .m3u files already use relative addressing - as I found out when I moved them
Putting in "echo '<a href="Pink.m3u">Pink</a></font></p>';" did invoke the WinAmp player but it just cycled through the playlist without playing anything. This is its action if it cannot find the songs.

Putting in "echo '<a href="01 Stupid Girls.flac">Pink</a></font></p>';" generates an 'Opening' box so I can 'open With' WinAmp or save to disk. If I open with WinAmp it plays this single song OK.

I looked at your playlist and thought I'd replicate the format as it uses web paths to the songs rather than relative addressing. This format also cycled through the playlist without playing.

I think I do have a problem with my Apache set up that is not allowing 'secondary' running of files or programs for legitimate security purposes. I'm going to post on an Apache forum and ask for clues there, but if you or anyone else here come up with ideas to try I'd like to hear them.

And yes, my NAS does have a webserver on it, but I'm choosing not to use it as I'm trying to learn stuff on the PC. Also the instructions for getting it working are non-existant.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old May 14th, 2007, 21:40
Junior Member
Join Date: May 2007
Location: London
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problem phrasing the question.

A quick update. I now know how to phrase the question. How to you stream flac files from Apache? When I tested WAV files the playlists worked OK. It's just flac's that wont stream. It looks like a config problem in Apache but someone in this web forum may well have come across the problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
external programs

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Problem in HTML-newb question partyon Web Page Design 2 Jun 6th, 2008 00:18
First image problem and inline list problem konnor5092 Web Page Design 8 Dec 1st, 2007 09:08
Javascript problem/question kb3llm129 JavaScript Forum 0 May 6th, 2006 22:03
Question JacobHaug Web Page Design 1 Dec 26th, 2005 00:57
<body> question/problem..... Jaken Veina Web Page Design 4 Aug 11th, 2005 16:07


All times are GMT. The time now is 16:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42