Solved

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

Posted on 2011-09-14
1
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn how to count occurrences of each item in an array.
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.

695 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