php code into variable

Putting a php code, query, and output into a variable

Page 1 of 1

1 Replies - 898 Views - Last Post: 01 December 2008 - 04:21 AM Rate Topic: -----

#1 dannzyx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 16-September 08

php code into variable

Post icon  Posted 01 December 2008 - 03:44 AM

Hey people,

currently just playing around with php and I'm now trying to figure out the page creation.
So Im trying to create pages for a website, with a script that creates the $pagename.php and writes all the data to the database.
What I want do is, after writing all the content to the database add a script to the newly created php file and retrieve the content from the DB onto that page.

<?php

	foreach($_POST as $Key => $Value) {
  $$Key = $Value;
}
foreach($_GET as $Key => $Value) {
  $$Key = $Value;
}

$testje = "

<?php

$query='SELECT * FROM pages WHERE id = $id;
$result=mysql_query($query);
$num=mysql_numrows($result);
$content=mysql_result($result,$i,'content');
$title=mysql_result($result,$i,'page');

echo '$title';
echo '$content';
?>
<?php
";


$my_file = "$page.php";
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
$data = "$testje";
fwrite($handle, $data);
?>



Could anyone help me out and tell me how to get this code into the variable...

Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: php code into variable

#2 dannzyx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 16-September 08

Re: php code into variable

Posted 01 December 2008 - 04:21 AM

I made it work with basic php file handling.
Different approach but the same result.

Nevertheless I would still like to know if the approach above can work too.

-dann
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1