Fatal error: Cannot redeclare strip()

Hello,

after editing correctly the default theme in order to include my website header etc..i'm getting the following:

Fatal error: Cannot redeclare strip() (previously declared in /home/.sites/242/site105/web/resources/zenphoto/zen/functions-db.php:96) in /home/.sites/242/site105/web/call/news.php on line 1000

the header of my index.php deafut theme it's actually like this:

<?php session_start(); include('../../call/news.php'); ?>
<?php if (!defined('WEBPATH')) die(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

please, do you know how can i fix this Fatal error?

Thanks so much!
tito

Comments

  • Can you please tell us what version of zenphoto you are using? I am unable to find a declaration for strip() in the code of the current versions.
  • zenphoto 1.0.8.2 (βeta) release, just downloaded a few hours ago and i wanted to try. could it be some problem concerning the other session start from another script? (see: <?php session_start(); include('../../call/news.php'); ?> above define webpath)
  • tito: 1.0.8.2 was released around April. We have since made TONS of bug fixes and implemented many many new features, please check it out here: http://www.zenphoto.org/files/nightly

    Just save your zp-config, update the new zp-config, upload the new files, then run zen/upgrade.php

    After you do this PLEASE let us know if you still have this error
  • i have noticed that this problem occurs just when i use the default theme, where i did add my html header n footer plus another session on top for another script running on the site (see: <?php session_start(); include('../../call/news.php'); ?> above define webpath).

    the point is that line 96 of /zen/functions-db.php where "Cannot redeclare strip()" it occurs, and on such file i can see:

    96. function strip($string) {
    97. if (get_magic_quotes_gpc()) {
    98. return stripslashes($string);
    99. etc...

    i guess it has something to do with that function strip on line 96.
    do you believe that i should download one of those unstable packages to solve this issue? i guess it has something to do with sessions. do you have any idea how to solve this?

    Thanks so much!
    tito
  • FYI: line 1000 of the other script - not zenphoto - /news.php is as follows:

    994. function strip($text) {
    995. $search = array('/\[include\](.*?)\[\/include\]/', '/\[break\]/', '/</', '/>/');
    996. $replace = array('', '', ' <', '> ');
    997. $output = preg_replace($search, $replace, $text);
    998. $output = stripslashes(strip_tags($output));
    999. return $output;
    1000. }
  • I recommend changing the strip function in your other theme to be something like strip_news() and then finding everywhere its used be searching for strip( and changing it to strip_news(

    Since this is not a zenphoto issue but a specific issue to you because both of your scripts contain a function with the same name I dont see this being changed in ZenPhoto.
  • I see now, Thanks a lot for explaining this issue to me, i'm not good in php.

    Best,
    tito
  • done as per yr suggestion and it's almost working now, i'm just getting an sql error:

    MySQL Query ( SELECT folder, sort_order FROM `albums` ORDER BY sort_order ) Failed. Error: Table 'call_news.albums' doesn't exist

    Please can you help me? Thanks!
    tito
  • Do you have zenphoto working without any changes?

    The error you are getting is because mySQL did not find a database table row. If your database is named call_news, check what tables it has. You may not have run the setup or you don't have the proper db prefix set up in zp-config.
  • the only change i've made is in theme/default as above specified.
    i do have a dedicated database called 'photos' where only zenphoto tables are stored, and i can see album and images listed through phpMyAdmin. so there's not need of a prefix.

    i guess that error is due to a theme/default conflict, maybe echo getAlbumLinkURL() is causing a conflict with functions with the other non zenphoto script? (see prev postings).

    I really dont't know..
  • You did not answer the question "does an unmodified installatin work?" If a clean install works, then your changes cause the problem. If not, then something else is wrong. It is really important to know the difference.
  • yes, i did add mere html header and footer, plus a session on top for another script running on my website. i did it on: /themes/default/ index.php, image.php, album.php
    and now there are 2 session on top of these pages:

    <?php session_start(); include('../../call/news.php'); ?>
    <?php if (!defined('WEBPATH')) die(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    aitf311 suggested to change the strip function in order to solve the 'Cannot redeclare strip', and it worked.

    now, i guess there's a problem with getAlbumLinkURL() code from the themes, cause i get: Error: Table 'call_news.albums' doesn't exist. sounds like it's getting the wrong URL path, isn'it?

    sbillard, i can confirm that the changes in themes are causing these problems, but just because different sessions and functions from others scripts are usually settled on websites, and mine was the case. i'm not a php programmer, so your suggestions are much appeciated.

    Thanks so much!
    tito
  • Well, PHP does not allow you to override functions. So, if you are going to mix two sets, you will have to insure that there are no conflicts.
Sign In or Register to comment.