?
Solved

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

Posted on 2003-03-16
5
Medium Priority
?
467 Views
Last Modified: 2013-12-12
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
Comment
Question by:playpool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
KC_Speedball earned 75 total points
ID: 8147837
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
 

Author Comment

by:playpool
ID: 8148372
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
 

Author Comment

by:playpool
ID: 8148605
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
 
LVL 1

Expert Comment

by:KC_Speedball
ID: 8151338
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
 

Author Comment

by:playpool
ID: 8152301
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question