Unable to write data into a file in my server using php

Hey guys i am writing a code which will get data frm the user and then write a file in my server and well sadly i am really confused with the annoying errors and warnings i am getting plz help here is my code
[php]<?php
//This File Gets the data from the chat setup form and then writes the chat file or edits it

//Get Data from the form
$cname=$_POST[‘cname’];
$nicklen=$_POST[‘nicklen’];
$msglen=$_POST[‘msglen’];
$pm=$_POST[‘pm’];
$msgh=$_POST[‘msgh’];
$aname=$_POST[‘aname’];
$pass=$_POST[‘pass’];
$cheight=$_POST[‘cheight’];
$cwidth=$_POST[‘cwidth’];
$prcadmin=$_POST[‘prcadmin’];
$cas=$_POST[‘cas’];
$frznick=$_POST[‘frznick’];
$sm=$_POST[‘sm’];
$id=$_COOKIE[“id”];
//Check if the cookie id is empty
if (!isset($id))
{
header( ‘Location: www.techbreeze.in/mychat/chat-add.html’) ;
}
//Check if any field is empty and redirect to setup page if empty
if ((isset($cname))&&(isset($nicklen))&&(isset($msglen))&&(isset($pm))&&(isset($msgh))&&(isset($aname))&&(isset($pass))&&(isset($cheight))&&(isset($cwidth)))
{
if ((is_numeric ($nicklen)) && (is_numeric ($msglen))&&(is_numeric($pm))&&(is_numeric($msgh))&&(is_numeric ($cheight))&&(is_numeric ($cwidth)))
{
//Start writting data into the file
$str1=";";
$str2 = “.php”;
$str4 = “\n”;

		$File = $id . $str2;
		$fh = fopen($File, 'w') or die("can't open file");
           
  			$stringData = "<?php\n";
           		fwrite($fh, $stringData);
           
           		$strt1= "require_once /mychat/src/phpfreechat.class.php;\n";
   		        $stringData = $strt1;
           		fwrite($fh, $stringData);
                         
           		$strt1='$params["serverid"]    =';
           		$stringData = $strt1 . $id . $str1 . $str4;
           		fwrite($fh, $stringData);
           		fclose($fh);

		
		$strt3 = "$params";
		$stringData = $strt3;
		fwrite($fh, $stringData);
		fclose($fh);
	}
	else
	{
		echo "Only numeric Inputs allowed for the fields";
		echo  "<br><br><br>";
		echo "Enter the maximum length of nick";
		echo  "<br>";
		echo "Maximum Lenth of message";
		echo  "<br>";
		echo "Max number of Simultaneous PM";
		echo  "<br>";
		echo "No. of msg to be stored in history";
		echo  "<br>";
		echo "Height of the Chat Room";
		echo  "<br>";
		echo "Width of Chat Room";
		echo  "<br><br><br>";
		echo "Please Fill them up Carefully!";
		echo "<meta HTTP-EQUIV='REFRESH' content='6; url= http://www.techbreeze.in/chat-setup.html'>";
				
	}

}
else
{
echo “You Have one or more incomplete Field”;
echo “
”;
echo “Please Fill them up Carefully!”;
echo “”;
}

   ?>[/php]

ok now the error i am getting is

Warning: fclose(): 3 is not a valid stream resource in /home/techbr/domains/techbreeze.in/public_html/mychat/chatcreate.php on line 52
Any ideas as to what i should do and why i am getting this error.
Sponsor our Newsletter | Privacy Policy | Terms of Service