Old 01-20-2006   #1 (permalink)
Registered User
 
Join Date: Aug 2005
Posts: 15

silly little php problem...

... that is turning out to be a brain teaser for me. I'm using the fopen command to create a new file and write some stuff in it, which is held in a variable. However, its returning a puzzling result.

Here is the code:


Code:
$contents = "http://www.loaded-designs.com/wuc/upload/$filename";
	$file = "upload/$nameofm3u.m3u"; 
     	$open = fopen($file, "w+"); 
     	fwrite($open, $contents); 
     	fclose($open);
then when I open up the new .m3u file, it reads as follows:

Code:
http://www.loaded-designs.com/wuc/upload/Array[name]
Any ideas why this would happen? It seems like it isn't processing the contents of the variable until after it inserts it into the .m3u. Thats just my thought, but any help is greatly appreciated!!!

Also another quick little question... I need to get rid of all blank spaces in a string... for example, lets say:

Code:
$variable = "$bandname $songtitle";

// $bandname = "Lamb of God";
// $songtitle = "New American Gospel";
is there a string fuction or any method to get rid of the spaces?

Thanks,
- Jeff Miller
www.loaded-designs.com

Last edited by ibanez270dx; 01-20-2006 at 01:49 AM.
ibanez270dx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-20-2006   #2 (permalink)
Registered User
 
Join Date: Apr 2005
Location: antwerp, belgium
Posts: 51

for the second problemyou might try to work with ereg_replace
not sure if it's going to work, but it's worth a try

http://be.php.net/manual/nl/function.ereg-replace.php

for the first problem you'll probably have to work with a small loop
don't think you can put an array in there all at once
__________________
sneeuwbal is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-21-2006   #3 (permalink)
"Enter Random Text Here"
 
sancho's Avatar
 
Join Date: Jun 2005
Location: Handsacre, UK
Posts: 37

Send a message via MSN to sancho Send a message via Skype™ to sancho
Hi

I have a question about the first problem. Are you using an array of filenames in the content variable? If so the code below will fix your problem.

PHP Code:
foreach($filename as $f)
{
    
$contents "http://www.loaded-designs.com/wuc/upload/$f";
    
$file "upload/$nameofm3u.m3u"
    
$open fopen($file"a+"); 
    
fwrite($open$contents); 
    
fclose($open); 

As for removing spaces the easiest way is to use str_replace. So the code would look something like:

PHP Code:
$bandname str_replace(" ","WHAT YOU WNAT TO REPLACE SPACES WITH""Lamb of God");
$songtitle str_replace(" ","WHAT YOU WNAT TO REPLACE SPACES WITH""New American Gospel");

$variable "$bandname $songtitle"
__________________

Portfolio: www.simonmclaughlin.co.uk
Cheap UK hosting: www.qubithosting.com
sancho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 01-24-2006   #4 (permalink)
Registered User
 
Join Date: Aug 2005
Posts: 15

thanks guys, I figured it all out now!

That first problem was odd - it ended up being the way I defined the variable. I had:

$filename = "$_FILES[file][name]";

which didn't work and only defined $variable as array[name]. The correct thing was:

$filename = $_FILES[file][name];

Sometimes the smallest things are the biggest problems... Once again thanks for your help!
ibanez270dx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pro's and Con's to Upgrading PHP pipersdragon HTML / PHP / ASP / JS 1 12-29-2005 11:43 PM
PHP problem - please help ibanez270dx HTML / PHP / ASP / JS 12 08-31-2005 01:24 PM
PHP News Problem GoldNetX HTML / PHP / ASP / JS 3 08-07-2005 07:37 PM
Chicken & The Egg Problem! Man1c M0g HTML / PHP / ASP / JS 3 04-05-2005 07:02 PM
redhat problem Milkdrop General Discussions 3 12-14-2003 07:05 AM


All times are GMT +1. The time now is 09:39 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT