Trying to create a file with links for the search engine to find

I am trying to create a simple index of links to txt files I have uploaded. I want them to be discovered by the search engine. I believe my code is correct as it is a simple open and then write to the file. The error appears to be the server blocking the write. I haven’t had issues with other functions so am wondering what is blocking me. I haven’t found any other help files to help someone so new to writing code in general. Thanks.

<?php

echo "<br>", "Now building index file to link new articles to the search engine<br>";
$findex="index_csv.csv";
$annaindex="index.html";

fopen($annaindex,"w");
if (($handle=fopen ($findex, "r")) !==FALSE)
{
	while(($line =  fgetcsv($handle)) !== FALSE) 
	{
 		list($totstring, $totlen, $period, $http, $lenanna, $lentitle, $post, $title, $fnamelen, $old,$fnameless, $bat, $pdate) = $line;
		$new=$post . "_". $fnameless . ".txt"; 		

 		echo "Now processing $new", "<br>";
		$annalink = '<a href=\"' . $new. '\">'. $title . '</a>/n';
		
		echo $annalink, "<br>";
		fwrite ($annaindex,$annalink);
	}

  }


//*****************************************************

fclose($handle);
fclose($annaindex);
echo "finished creating file";
?>
  • Formatted by Admin

sorry. I forgot how to format the example code as txt in the forum

I was able to find a solution to my own problem. I assigned a handle to the resource like I did with the csv file.

Can you explain how you solve it in detail? :thinking: :thinking:

Hello,
Can you please explain this in more.

Sponsor our Newsletter | Privacy Policy | Terms of Service