FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » why do examples fail to work?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
why do examples fail to work? [message #171130] Mon, 27 December 2010 05:58 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
http://www.w3schools.com/php/php_file.asp

<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>

for my efforts, my result is ";}fclose($file);?>

regardless of what I enter for the name of the text file, even if it does
exist. Or how I enter the path.

If it matters, I am using Rapid PHP 2010.
With the local php 5. server.
Re: why do examples fail to work? [message #171131 is a reply to message #171130] Mon, 27 December 2010 07:40 Go to previous messageGo to next message
Henrik Carlqvist is currently offline  Henrik Carlqvist
Messages: 2
Registered: December 2010
Karma: 0
Junior Member
richard <member(at)newsguy(dot)com> wrote:
> for my efforts, my result is ";}fclose($file);?>

You probably did not configure your web server to use php to parse the php
parts of the php files. Instead your server serves the source of your php
file to the browser.

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc123(at)poolhem.se Examples of addresses which go to spammers:
root@localhost postmaster@localhost
Re: why do examples fail to work? [message #171135 is a reply to message #171130] Mon, 27 December 2010 08:30 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 27/12/2010 6:58, richard escribió/wrote:
> http://www.w3schools.com/php/php_file.asp
>
> <?php
> $file = fopen("welcome.txt", "r") or exit("Unable to open file!");
> //Output a line of the file until the end is reached
> while(!feof($file))
> {
> echo fgets($file). "<br />";
> }
> fclose($file);
> ?>
>
> for my efforts, my result is ";}fclose($file);?>
>
> regardless of what I enter for the name of the text file, even if it does
> exist. Or how I enter the path.
>
> If it matters, I am using Rapid PHP 2010.
> With the local php 5. server.

As you probably know, PHP runs on the server. If you see the original
source code in the browser, that means that you don't have a working PHP
set-up.

Read the Rapid PHP 2010 documentation to find out how to make its server
run properly or just discard the bundled stuff and install the original
programs, which are normally well documented.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: why do examples fail to work? [message #171145 is a reply to message #171130] Mon, 27 December 2010 20:14 Go to previous message
Katie is currently offline  Katie
Messages: 4
Registered: December 2010
Karma: 0
Junior Member
On Dec 27, 5:58 am, richard <mem...@newsguy.com> wrote:
> http://www.w3schools.com/php/php_file.asp
>
> <?php
> $file = fopen("welcome.txt", "r") or exit("Unable to open file!");
> //Output a line of the file until the end is reached
> while(!feof($file))
>   {
>   echo fgets($file). "<br />";
>   }
> fclose($file);
> ?>
>
> for my efforts, my result is ";}fclose($file);?>
>

Can you get any php code to run ?

Katie
--
CoderStack
http://www.coderstack.co.uk/perl-jobs
The Software Developer Job Board
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Slowly coming together
Next Topic: PHP code for automated tracking
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 01:02:27 GMT 2024

Total time taken to generate the page: 0.02844 seconds