# PHP: fwrite problems

**URL:** <https://forum.kirupa.com/t/php-fwrite-problems/28123>\
**Category:** programming\
**Created:** [August 10, 2003, 1:44pm UTC](https://forum.kirupa.com/t/php-fwrite-problems/28123 "2003-08-10T13:44:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danneman](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@Danneman](https://forum.kirupa.com/u/Danneman)\
**Post date:** [August 10, 2003, 1:44pm UTC](https://forum.kirupa.com/t/php-fwrite-problems/28123/1 "2003-08-10T13:44:18Z")

</div>

Hi, Im trying to have a url written to a textfiel via the “fwrite”-command in php.

I also dont want to type “http://” every time I input a link, so that should be included in the php-code.

```php

fwrite($FilePointer, "<a href=\"http://".$LinkOne."\" target=\"blank\">".$LinkNameOne."</a> <BR>" );

```

This should result in a nice HTML-coded url when “[www.myLink.com](http://www.myLink.com)” is sent by the $LinkOne-variable, but instead I get:

```php

<a href="www.myLink.com" target="blank">myLink</a>

```

That is, everything but the actual “http://”.

Where am I going wrong here?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 10, 2003, 2:32pm UTC](https://forum.kirupa.com/t/php-fwrite-problems/28123/2 "2003-08-10T14:32:23Z")

</div>

what you should do is this:

```php

fwrite($FilePointer, $LinkOne .".:-:.". $LinkNameOne);

```

and then when you print that out just add the http:// to the PHP code…

something like this:

```php

$textFile = "myTextFile.txt";
$filePointer = fopen($textFile, "a+");
$data = split(".:-:.", $fread($filePointer, 80000));
fclose($filePointer);

print "<a href=\"http://" . $data[0] . " target=\"_blank\">" . $data[1] . "</a> <br />";

```

something like that…

[edit]oh, and I tried your code, and it worked fine for me…[/edit]
