Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 06:30 am EDT

Geeklog Forums

Php function in static pages


Status: offline

thedailycynic

Forum User
Junior
Registered: 09/12/04
Posts: 17
I am running 1.3.10 scr2 and i cannot turn on the php in the static pages. Is there a way that I can turn it on in the database. i have followed att the documentation but when i go to the static pages and try to create a new one it says that the php has not been activated please see the documentation.

Thanks for the help
Music News Washington DC
Graphic Design Virginia

Record Label Washington DC

Active Sports Wear
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
So why don't you follow the documentation?

bye, Dirk
 Quote

Status: offline

thedailycynic

Forum User
Junior
Registered: 09/12/04
Posts: 17
Quote by thedailycynic: i have followed all the documentation


i did
Music News Washington DC
Graphic Design Virginia

Record Label Washington DC

Active Sports Wear
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by thedailycynic: i did

Well, you're not exactly giving a lot of information to base any tips on ...

Double check that PHP is activated in the plugin's config.php file, that the Static Pages Admin group has the proper permissions and that your current user is a member of that group. It must be one of those ...

bye, Dirk
 Quote

Status: offline

thedailycynic

Forum User
Junior
Registered: 09/12/04
Posts: 17
I figured out the problem for some reason when i opened up the config in the static pages the seocnd time around there was absolutly nothing in it. Dont know what happened but now it works — weird. ... thanks dirk
Music News Washington DC
Graphic Design Virginia

Record Label Washington DC

Active Sports Wear
 Quote

Status: offline

thedailycynic

Forum User
Junior
Registered: 09/12/04
Posts: 17
I am getting this error though now on the index page which I have set as a static page.

Parse error: parse error, unexpected ' /home/thedailycynic/gl2.thedailycynic.com/plugins/staticpages/functions.inc(475) : eval()'d code on line 1

I dont know what is going on. I have looked through that file. Here is the code that i am using in the static page.


Text Formatted Code



<table width="701" border="0">
  <tr>
    <td width="205">Top Headlines </td>
    <td width="31" rowspan="5"> </td>
    <td width="451">This months Articles </td>
  </tr>
  <tr>
    <td>

        #################################################################################################
$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY sid DESC LIMIT 0, 10";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);
$display = '
<!-- ############  The latest news ############# -->
<!-- the style for this is in the image.css file -->
<table cellpadding="0" cellspacing="0" border="0" class="storylist">';
$rcnt = 1;
for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    if($rcnt > 2) $rcnt = 1;
    $display .= '<tr><td class="row'. $rcnt .'"><a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes($A['title']) . '</a></td></tr>';
    $rcnt++;

}
$display .= '</table>
<!-- ############  The latest news ############# -->';
echo $display;

</td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td>Newest Features </td>
    <td>Featured Press Releases </td>
  </tr>
  <tr>
    <td>

       
        #################################################################################################
$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY sid DESC LIMIT 0, 10";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);
$display = '
<!-- ############  The latest news ############# -->
<!-- the style for this is in the image.css file -->
<table cellpadding="0" cellspacing="0" border="0" class="storylist">';
$rcnt = 1;
for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    if($rcnt > 2) $rcnt = 1;
    $display .= '<tr><td class="row'. $rcnt .'"><a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes($A['title']) . '</a></td></tr>';
    $rcnt++;

}
$display .= '</table>
<!-- ############  The latest news ############# -->';
echo $display;
</td>
    <td>       
   
        #################################################################################################
$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY sid DESC LIMIT 0, 10";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);
$display = '
<!-- ############  The latest news ############# -->
<!-- the style for this is in the image.css file -->
<table cellpadding="0" cellspacing="0" border="0" class="storylist">';
$rcnt = 1;
for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    if($rcnt > 2) $rcnt = 1;
    $display .= '<tr><td class="row'. $rcnt .'"><a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes($A['title']) . '</a></td></tr>';
    $rcnt++;

}
$display .= '</table>
<!-- ############  The latest news ############# -->';
echo $display;


</td>
  </tr>
</table>



 

Music News Washington DC
Graphic Design Virginia

Record Label Washington DC

Active Sports Wear
 Quote

Status: offline

jhk

Forum User
Chatty
Registered: 07/13/02
Posts: 57
Suggestion:
Take a backwards step and do a simple php static page. E.g.:
Text Formatted Code
return "It finally works! Dirk is da Man";
 

In a page set to "Execute php (return)";

That should show you whether the installation was flawed.
 Quote

Status: offline

thedailycynic

Forum User
Junior
Registered: 09/12/04
Posts: 17
That works fine which i think it is now in my code that i am trying to put into a static page.
Music News Washington DC
Graphic Design Virginia

Record Label Washington DC

Active Sports Wear
 Quote

Status: offline

jhk

Forum User
Chatty
Registered: 07/13/02
Posts: 57
hopeful
That is good news. Smile

Perhaps you should try using the "return" method on your pages. I prefer to put all of my output into a single variable, $return, and then end the page with a "return $return;" statement. That way I have no regular html on my pages to confuse myself. Wink

For longer sections of html, you can use the heredoc format:
Text Formatted Code
$return .= <<<SPECIALSTRING
Here
is
some
html
SPECIALSTRING;




 

Two caveats:
1) The ending string MUST be to the far left of the line. No spaces or tabs.
2) You can define any string to be the "special" encapsulation string.

See: the Heredoc format

Good luck,
Jens
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by thedailycynic: Parse error: parse error, unexpected '
/home/thedailycynic/gl2.thedailycynic.com/plugins/staticpages/functions.inc(475) : eval()'d code on line 1

That's because you're mixing HTML and PHP. In static pages, only "plain PHP" is allowed, but you can switch back and forth between PHP and HTML like this:
Text Formatted Code
?><b>Hello</b> <?php echo "world";
 

Which, btw, is also mentioned in the documentation ...

bye, Dirk
 Quote

All times are EDT. The time is now 06:30 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content