Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stream_encoding() Help

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Please help, I am getting an error below, even though I have defined the function in my code.

The error is:
Call to undefined function stream_encoding() in add.php on line 17

Here is my code.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <title> story of Bad Luck </title>
 </head>
 <body>
<?php // - add.php

//check for a form submission:
if (isset($_POST['submitted'])){
	if (!empty($_POST['quote']) && ($_POST['quote'] != 'Enter your quotation here.')){
	if($fp = fopen('quotes.txt', 'ab')){//Try to open file
	
	//set the encoding:
	[COLOR=red]stream_encoding($fp, 'utf-8'); [/color]//here is line 17
	
	fwrite($fp, "{$_POST['quote']}\n"); //Write the data
	fclose($fp);
	//print a message:
	print "<p> Your quotation has been stored.</p>";
	}else{ // could not open the file
	print '<p style="color:red;">Your quotation could not be stored due to a system error.</p>';
	}
	}else{//failes to enter a quotation
	print '<p style="color:red;">Please enter a quotation!</p>';
	}
}

	//leave PHP
	?>
	
	<form action="add.php" method="post">
		<textarea name="quote" rows="5" cols="30">Enter your quotation here.</textarea>
		<input type="submit" name="submit" value="Add This Quote!" />
		<input type="hidden" name="submitted" value="true" />
	</form>

	</body>
	</html>
 
I have solved this problem. I just removed the offending line - stream_encoding($fp, 'utf-8');

and the codes still works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top