create a php file with fwrite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joachimseitz
Forum Commoner
Posts: 25
Joined: Fri Feb 20, 2004 10:36 am
Location: Germany
Contact:

create a php file with fwrite

Post by joachimseitz »

what i want to do is create a new php file
f.e.
test.php

the thing is it gets stuff from a mysql db

this is how im trying it

Code: Select all

<?
$user_id="user_id";
$result="result";
$sname="sname";
$arow="row&#1111;'sname']";
$brow="row";
$quote=""";

$pagename="test";
$fp = fopen("$pagename.php", "w");
$fpwrite = fwrite($fp,
"<?
require_once('config.php');

$$user_id=9;
$$result = mysql_query('SELECT * FROM users WHERE id=$$user_id');
while ($$brow = mysql_fetch_array($$result))&#123;
   $$sname=$$arow;
&#125;

echo 'Hello, this is $$sname text!';

?>");
fclose($fp);
?>
i want to got some " in the file cause i cant only work with '
since the query wont work without "

so i need some ideas how to make it work
maybe also even easier ideas than always havin $$xxx

the other problem is that it can't include the config.php since it has other user rights
but this problem isn't essential atm since i can always just have the config in the same file :/
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You can use \" to display a double quote within double quotes.
Post Reply