You are here: Re: problem with fwrite() « All PHP « IT news, forums, messages
Re: problem with fwrite()

Posted by Steve on 10/07/05 16:18

> i want to make a php page on the fly.
> i have made a very basic page that works fine:
>
> ------------ basic page source -------------
> /* make file */
> $file = fopen("02_output.php","w");
>
> /* make source code for the new php page */
> /* $inhoud = "<? echo 'wie wil er naar de kermis' ?>"; */
>
> /* write code to the new php page */
> $schrijven = fwrite($file, $inhoud);
>
> fclose($file);
> -----------------------------------------------

This example will write an empty file, because the assignment to
$inhoud is commented out.

> the problem is when the page gets a different structure: (see source code
> below)
>
> ----------------- new basic page source ---------------------------
> /* make file */
> $file = fopen("02_output.php","w");
>
> /* make source code for the new php page */
> $inhoud .= "<? echo" ;
> $inhoud .= " 'wie wil er naar de kermis'";
> $inhoud .= " ?>";
> */
>
> /* write code to the new php page */
> $schrijven = fwrite($file, $inhoud);
>
> fclose($file);
> ----------------------------------------------------------------------

This example will throw a runtime error because there's a close comment
*/ on a line by itself with no open comment to match it. It will
therefore not create any file at all.

> when i want to open the new page (02_output.php) i get an error message:

> Parse error: parse error, expecting `','' or `';'' in
> c:\apache\htdocs\zrommelen\file_maken_20051007_02\02_output.php on line 1

But we don't know what code created that file; it certainly wasn't the
code above because that would stop before reaching the fopen(). It
isn't possible to give you any help or advice when we can't see the
actual code you are trying to execute. You should:

(1) Write the code.
(2) Ensure that it passes syntax checking (use php -l to syntax check
without executing).
(3) Copy and paste it into your posting.

---
Steve

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация