View Single Post
  #9 (permalink)  
Old 07-06-09, 01:25 AM
job0107's Avatar
job0107 job0107 is online now
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 2,660
Thanks: 0
Thanked 23 Times in 23 Posts
The PHP code in the database must not have opening and closing PHP tags,
just the raw PHP code.
And any HTML must be echoed.

Example:
The code in the database could look like this,
notice that there are no opening or closing PHP tags.
PHP Code:
echo "<p>Hello World.</p>"
Then your code will work.
PHP Code:
<?php
        $value 
$_GET['page'];
        
$host "localhost";
        
$user "ID";
        
$password "PW";
        
$db_name "DB";
        
$connection mysql_connect($host$user$password);
        
$db mysql_select_db($db_name) or die( "Couldn't select database");
        
$sql "SELECT * FROM site WHERE page_id = '$value'";
        
$mysql_result=mysql_query($sql,$connection);
        
$num_rows=mysql_num_rows($mysql_result);

                    if (
$num_rows == 0){
                            echo 
" ";
                    }

                    else {
                        while (
$row=mysql_fetch_array($mysql_result)) {
                                
$pagename=$row["pagename"];
                                
$content=$row["content"];

                        echo 
"<h1>$pagename</h1>";
                        eval(
$content);
                        }
                    }

                
mysql_close($connection);
                
?>
__________________
Jerry Broughton

Last edited by job0107; 07-06-09 at 01:27 AM.
Reply With Quote