ZenphotoCMS Forum
Fatal error: Cannot redeclare strip() - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Fatal error: Cannot redeclare strip() (/thread-1697.html)



Fatal error: Cannot redeclare strip() - tito - 12-10-2007

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:

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

Thanks so much!
tito




Fatal error: Cannot redeclare strip() - sbillard - 12-10-2007

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.




Fatal error: Cannot redeclare strip() - tito - 12-10-2007

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: above define webpath)




Fatal error: Cannot redeclare strip() - aitf311 - 13-10-2007

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




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

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: 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:

  1. function strip($string) {
  2. if (get_magic_quotes_gpc()) {
  3. return stripslashes($string);
  4. 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




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

FYI: line 1000 of the other script - not zenphoto - /news.php is as follows:

  1. function strip($text) {
  2. $search = array('/[include](.*?)[\/include]/', '/[break]/', '//');
  3. $replace = array('', '', ' ');
  4. $output = preg_replace($search, $replace, $text);
  5. $output = stripslashes(strip_tags($output));
  6. return $output;
  7. }



Fatal error: Cannot redeclare strip() - aitf311 - 13-10-2007

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.




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

I see now, Thanks a lot for explaining this issue to me, i'm not good in php.

Best,
tito




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

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




Fatal error: Cannot redeclare strip() - sbillard - 13-10-2007

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.




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

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..




Fatal error: Cannot redeclare strip() - sbillard - 13-10-2007

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.




Fatal error: Cannot redeclare strip() - tito - 13-10-2007

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:

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




Fatal error: Cannot redeclare strip() - sbillard - 13-10-2007

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.