Solved

I keep getting 'Resource id #9' for a value of a variable

Posted on 2011-09-14
1
365 Views
Last Modified: 2012-05-12
Hi,
I understand why I'm getting Resource id #9 as a value (its the allocated memory space I think for the value).. or something like that.

Problem is I can't see why I get that. Here is the pertinent code:

$myurl= $RecordingUrl.".mp3";
   $infile = fopen ($myurl, "r");
   $outfile = fopen ("../../../modules/account/recordings/".$account_id."/test2.mp3","w");
   while (!feof ($infile))
   {
    fwrite($outfile,fread ($infile, 1024));
   }

   fclose($outfile);
   fclose ($infile);





	$email = $stationemail;
	$subject = "Winning Caller Details for ".$campaignname." from ".$stationname;
	$body = "Contest Details for ".$campaignname.":\n\n";
	$body .= "Contest ended: ".date("F j, Y, g:i a")."\n";
	$body .= "Caller phoned in using: ".$CallTo." contest line.\n";
	$body .= "Winning Caller was put through to: ".$djphone.".\n";
	$body .= "Caller's Name: ".$CallerName."\n";
	$body .= "Caller's Phone Number: ".$FromCaller."\n";
	$body .= "Caller's City: ".$CallerCity."\n";
	$body .= "Caller's Province/State: ".$CallerState."\n";
	$body .= "Recording Duration: ".$CallDuration." minutes long.\n\n";
	$body .= "Here is the link to the recording:\n";
	$body .= $outfile;

Open in new window


The script is saving an mp3 from a remote location into a local directory on the server (that works fine, there is a file there)
Next I'm emailing the url to the newly created mp3 on my server. For a value (last line of the code), I keep getting 'Resouce id #9)

How do I get the url to the mp3 file instead of the resource number?

Thanks tj
0
Comment
Question by:tjyoung
1 Comment
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 36538422
you will need something similar to the code below.  The 'Resource id #9' is because of $outfile = fopen();

fopen does NOT return the name of the file - it returns a resource id.
$myurl= $RecordingUrl.".mp3";
$outurl="../../../modules/account/recordings/".$account_id."/test2.mp3";
   $infile = fopen ($myurl, "r");
   $outfile = fopen ($outurl,"w");
   while (!feof ($infile))
   {
    fwrite($outfile,fread ($infile, 1024));
   }

   fclose($outfile);
   fclose ($infile);





	$email = $stationemail;
	$subject = "Winning Caller Details for ".$campaignname." from ".$stationname;
	$body = "Contest Details for ".$campaignname.":\n\n";
	$body .= "Contest ended: ".date("F j, Y, g:i a")."\n";
	$body .= "Caller phoned in using: ".$CallTo." contest line.\n";
	$body .= "Winning Caller was put through to: ".$djphone.".\n";
	$body .= "Caller's Name: ".$CallerName."\n";
	$body .= "Caller's Phone Number: ".$FromCaller."\n";
	$body .= "Caller's City: ".$CallerCity."\n";
	$body .= "Caller's Province/State: ".$CallerState."\n";
	$body .= "Recording Duration: ".$CallDuration." minutes long.\n\n";
	$body .= "Here is the link to the recording:\n";
	$body .= $outurl;

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now