• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

PHP noob question - using fwrite() to write HTML hyperlinks

i keep running into the problem of how to write html code, specifically hyperlinks to an external text file.

i want to use fwrite(), but the question is how. Example:

fwrite($fp, "Webpage: <a href=".$url.

i want the file to recieve the following line

Webpage: <a href="www.link.com">link text</a><br>

the problem is the double quotes, since the href in the html tag has to be in quotes as well as the variable containing the link text...what am i supposed to do??

thanks in advance,

playpool
0
playpool
Asked:
playpool
  • 3
  • 2
1 Solution
 
KC_SpeedballCommented:
Where does the $url comes from?

You can use the PHP-Functions addslashes and stripslashes to for using the double quotes.

Another hint: you can start the echo with a single quote
like echo' ....'; perhaps this helps
0
 
playpoolAuthor Commented:
its not an echo, cuz i'm writing the line to a file. I'm using the fwrite() command, which i think would look something like this with the strip slashes

fwrite($fp, "Webpage: <a href=\"$url"\>$url</a>\n");

does that look right??

and by the way, the $url is a local variable that is assigned with its value from a form.

playpool
0
 
playpoolAuthor Commented:
so after i get that done, how should i redirect the submit.php page to the page that is gonna show all the entries????

is ther a redirect command?

playpool
0
 
KC_SpeedballCommented:
you can move the "trigger-part" which writes into textfile to another page.... so the form where the urls are typed in not send to php self, but to this other page...where the new url is added to textfile an after that all lines in the textfile where printed.

Bye the it is more easy to use databases instead of textfiles
0
 
playpoolAuthor Commented:
i want to use a database, but the server i'm using has limited space, and its my friends, and he doesn't want to mess with installing mySQL so i'm kinda stuck.

playpool
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now