?
Solved

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

Posted on 2011-09-14
1
Medium Priority
?
401 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 2000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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