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!
$class is A variable being assigned to a new class. If you are unaware of what classes are, I suggest reading up on them at http://us3.php.net/manual/en/ref.classobj.php . Unfortunately, php is not much of an object oriented language, so for whatever purpose you are using eval, this may not be the most useful. If you want to provide a little more detail as to what you are trying to accomplish, that would be useful.
<?php
include "connect.php";
$PID=$_GET['PID'];
$page="SELECT * FROM Pages WHERE PID='$PID'";
$page2=mysql_query($page);
while ($page3=mysql_fetch_assoc($page2))
{
eval("\$ps = new $page3[PageSource];");
}
?>
<?php
session_start();
include "connect.php";
if (isset($_SESSION['Username']))
{
session_destroy();
print "You have been logged out.";
}
else
{
print "You must be logged in before you can logout.";
}
?>
It keeps parsing no matter what I have in the table.
Parse error: parse error, unexpected '<', expecting T_STRING or T_VARIABLE or '$' in /home/fractal/domains/ut-online.org/public_html/logout.php(11) : eval()'d code on line 1
Any ideas?
EDIT: This topic was posted for me since I didn't have an account at the time.. .-.
feyd wrote:I'm going to guess that you have <?php or similar as the first thing... you don't need that, you're already running in php.
It'd be nice to know what's in the record to better help...
I thought about that but when I removed the <?php and ?> tags it complained about the session_start();
Then I removed that and it complained about the include "connect.php";
Then I removed that aswell and it complained about the if statement I have..
<?php
include "connect.php";
$PID=$_GET['PID'];
$page="SELECT * FROM Pages WHERE PID='$PID'";
$page2=mysql_query($page);
while ($page3=mysql_fetch_assoc($page2))
{
eval("{$page3['PageSource']}");
}
?>
This should be closer to what you want. The class example sent you off on the wrong direction.
<?php
include "connect.php";
$PID=$_GET['PID'];
$page="SELECT * FROM Pages WHERE PID='$PID'";
$page2=mysql_query($page);
while ($page3=mysql_fetch_assoc($page2))
{
eval("{$page3['PageSource']}");
}
?>
This should be closer to what you want. The class example sent you off on the wrong direction.
Sounds like a pretty bad idea. I can rarely think of a time when eval is useful, or more importantly safe. Why exactly are you storing code, there has to be a better way...