Jump to content

[SOLVED] PHP File Writting Probs...


pugboy

Recommended Posts

For some reason, the following code doesn't work. Just places a 0 in the file...

 

<?php
	$ref = $_GET["rid"];
	$dir = "dir/" . $ref . "/ref.txt";
	if(file_exists($dir)){
		$myFile = $dir;
		$fh = fopen($myFile, 'r');
		$theData = fread($fh, filesize($myFile));
		fclose($fh);
		$theData = $theData + "X";
		$fh = fopen($myFile, 'w') or die("Can't open file");
		fwrite($fh, $theData);
		fclose($fh);
	}
	?>

 

The file has text already in it, and I am using it for a referral program on my site... The rid is the username, and their account is in the "dir" folder.

 

Anyone know why?

 

Link to comment
https://forums.phpfreaks.com/topic/103788-solved-php-file-writting-probs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.