Solved

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

Posted on 2011-09-14
1
376 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 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