[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

How to transfer echo results to a html page?

Hi Folks,

Currently my scripts echo the results. Now I would like to transfer those results, mainly links, to a html page.
How can this be done?

Kind regards,

Dweep
0
PeterdeB
Asked:
PeterdeB
  • 6
  • 3
  • 2
2 Solutions
 
Oddsen84Commented:
How do you want to transfer these links? Do you want to add them to an existing page or insert them? Need more info first.
0
 
PeterdeBAuthor Commented:
Hi Oddsen84,

I would like to add them to an existing page.

Kind regards,

Dweep
0
 
Oddsen84Commented:
Does this page contain a way to recive these links and is it a static page? If this page doesn't contain a way of reciving links and is a static page then you will need to update the site by writing directly to the sitefiles.

Mabye a better way would be to have the reciving page get it's links from a database and have the sending database send new links to the database.

If any of this isn't clear don't hesitate to ask.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
AnniyanCommented:
$myFile = "yourhtmlfile.html";
$fh = fopen($myFile, 'w');
fwrite($fh, $whateverwasechoed);
fclose($fh);
0
 
AnniyanCommented:
replace $whateverwasechoed with (any string/ whatever you passed as parameter to echo)

I think this is what you were looking for
0
 
Oddsen84Commented:
I don't agree with you Anniyan although you most likely need to use these file functions in php. If you just do it this way you will brake the html format and the page won't be viewable in a browser.

If you want you can find more info here:
http://no.php.net/manual/en/function.fopen.php
http://no.php.net/manual/en/function.fclose.php
http://no.php.net/manual/en/function.fread.php
http://no.php.net/manual/en/function.fwrite.php
http://no.php.net/manual/en/function.file.php
http://no.php.net/manual/en/function.file-exists.php

These are some functions you are bound to meet if you just want to write to file. But I would strongly advise against updating a web page this way
0
 
Oddsen84Commented:
You could also write all the links to a *.txt file and have the html page contain a bit of php which loops and reads the text out from the file and then displays it.
0
 
PeterdeBAuthor Commented:
Hi Oddsen84,

I created validated.html containing only the necessary tags to make it a valid html page. How should I change this into a page that is capable of receiving the data?

Furthermore: using a database, will be a complicated matter, right?

Thanks for your responses,

Hi Anniyan,

I am testing your code right now thanks for your responses,

Dweep

0
 
Oddsen84Commented:
Although setting up a database can be a daunting challenge it's the way to go for a website destined for greatness ;) Making a page able to receive data is not something I can help you with but making a script for saving to file you have already.

<<Anniyan:
<<$myFile = "yourhtmlfile.html";
<<$fh = fopen($myFile, 'w');
<<fwrite($fh, $whateverwasechoed);
<<fclose($fh);

All you need now is to reverse the process so instead of fopen($myFile, 'w'); you use fopen($myFile, 'r');
And instead of the fwrite you use  $text = fread($fh, filesize($myfile));
Then you should use a way of checking if the link(s) exist right? If you always add a \n (newline) then you can use explode("\n", $text); Then just loop trough and check each of your links against the file. If no links already exsist then you just append the new links like Anniyan showed you
0
 
Oddsen84Commented:
When I say always add a newline character I mean you should append it to the end of all links like this:

$var = 'http://www.someplace.com'."\n";
Notice the difference? I used 'single hyphens' for the link and "double hyphens" for the control character. This is because PHP interprets these differently and instead of just adding the plain text \n it is substituted with the control character for new lines(read all about it here http://en.wikipedia.org/wiki/Control_character)
0
 
PeterdeBAuthor Commented:
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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