PHP not executing
Moderator: General Moderators
PHP not executing
I need to insert some code into a MySQL database, so a friend of mine can make a couple of pages for his Uni project. However, the PHP that he insert's does not get executed on the pages that output the code from the database. Does anyone know how I can solve this?
Thanks.
Thanks.
Well, it's just standard code...
Update code page (Snipped)
And the show page...
As I said, pretty standard. I remember hearing somewhere that PHP doesnt like being parsed as it comes out of a MySQL database, however, I cant remember where I heard it to : (
Thanks.
Update code page (Snipped)
Code: Select all
<?PHP
...
if($update != ""){
$sql = "UPDATE site SET 1='$page1' WHERE id='$update'";
$rs = mysql_query($sql) or die(mysql_error());
}
?>
</HEAD>
<form action="index.php?update=1" method="post">
Question Page 1:<br />
<textarea rows="20" cols="90" name="page2"><?PHP echo"$code2"; ?></textarea>
<br />
<input type="submit" value="Update" />
</form>
...Code: Select all
<?PHP
...
$sql = "SELECT * FROM site WHERE id='1'";
$rs = mysql_query($sql) or die(mysql_error());
$get = mysql_fetch_assoc($rs);
$code1 = $get['1'];
echo($code1);
?>Thanks.
Code: Select all
<?php
echo (eval($code));
?>That was it, although I'm coming out with an error :\
Parse error: parse error, unexpected '<' in /home/chris/public_html/med/Firstpage.php(11) : eval()'d code on line 1
The exact code I am using to parse the code is:
Thanks.
Parse error: parse error, unexpected '<' in /home/chris/public_html/med/Firstpage.php(11) : eval()'d code on line 1
The exact code I am using to parse the code is:
Code: Select all
<?PHP
$conn = mysql_connect('localhost', 'username', 'password') or die(mysql_error());
$rs = mysql_select_db('database', $conn) or die(mysql_error());
$sql = "SELECT * FROM site WHERE id='1'" or die(mysql_error());
$rs = mysql_query($sql) or die(mysql_error());
$get = mysql_fetch_assoc($rs);
$str = $get['1'];
eval($str);
echo($str);
?>
Last edited by Archy on Tue Nov 02, 2004 3:15 pm, edited 1 time in total.
The echo function just outputs text to the browser, such as html and stuff, the eval function runs the code.... if the code you run has an echo in it, it will print out like normal so there is no need to eval the variable then echo it you can just eval it...
I am refering to the lines
That is unless you want them to be able to view your source.
I am refering to the lines
Code: Select all
eval($str);
echo($str);