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

**URL:** <https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145>\
**Category:** Beginners - Learning PHP\
**Created:** [May 10, 2024, 11:31pm UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145 "2024-05-10T23:31:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hotspringsrus](https://www.phphelp.com/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@Hotspringsrus](https://www.phphelp.com/u/Hotspringsrus)\
**Post date:** [May 10, 2024, 11:31pm UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145/1 "2024-05-10T23:31:17Z")

</div>

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.

 ![image](https://www.phphelp.com/uploads/default/original/2X/1/1d29100a26b7067c35cfa7971cef1f5d0ed18b15.png)

```auto
<?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

---

<div class="post-metadata">

**Author:** ![Hotspringsrus](https://www.phphelp.com/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@Hotspringsrus](https://www.phphelp.com/u/Hotspringsrus)\
**Post date:** [May 10, 2024, 11:32pm UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145/2 "2024-05-10T23:32:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hotspringsrus](https://www.phphelp.com/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@Hotspringsrus](https://www.phphelp.com/u/Hotspringsrus)\
**Post date:** [May 11, 2024, 4:43am UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145/3 "2024-05-11T04:43:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![asshleyymariei](https://www.phphelp.com/user_avatar/www.phphelp.com/asshleyymariei/32/4334_2.png) [@asshleyymariei](https://www.phphelp.com/u/asshleyymariei)\
**Post date:** [June 27, 2024, 5:16am UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145/5 "2024-06-27T05:16:58Z")

</div>

**Can you explain how you solve it in detail?** 🤔 🤔

---

<div class="post-metadata">

**Author:** ![fatimaahmed](https://www.phphelp.com/user_avatar/www.phphelp.com/fatimaahmed/32/4338_2.png) [@fatimaahmed](https://www.phphelp.com/u/fatimaahmed)\
**Post date:** [July 11, 2024, 7:55am UTC](https://www.phphelp.com/t/trying-to-create-a-file-with-links-for-the-search-engine-to-find/36145/6 "2024-07-11T07:55:27Z")

</div>

Hello,  
Can you please explain this in more.
