Hi! i have a problem with cpmfetch!
i have this code on the left side of my page
<?php include("bilder_zufall.php"); ?>
(for random pictures)
which is include this code:
<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewRandomMedia(4,1);
$objCpm->cpm_close();
?>
and on the right side this code
<?php include("bilder_neu.php"); ?>
(for new pictures)
which include this code:
<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewLastAddedMedia(8,1);
$objCpm->cpm_close();
?>
now, i got this error message on the right side (where the new pictures from the gallery are)
Fatal error: Cannot redeclare class cpm in /home/www/web189/html/cpmfetch/cpmfetch.php on line 33
what's happen?! can't i put 2php codes on one side or what?!
if you want to see it, look at http://www.bratze-bunker.de/start.php
PS: soory for my bad english ;)
Reading through the posts this morning having my coffee (OK, I'm a tea drinker...), I saw the similarities in this post with yours. Something about the include statement being added twice. Not sure but you can give it a try.
http://forum.coppermine-gallery.net/index.php?topic=39024.0 (http://forum.coppermine-gallery.net/index.php?topic=39024.0)
OK... I'm the curious type and couldn't help giving this a try. :) I set up my blog to have two images shown from two scripts and I got the same error as you. Then I removed this line from the second script and it worked fine.
include "./cpmfetch/cpmfetch.php";
I also remembered reading on Vuud's site that this only needs to be called once per page.
great man! thanks a lot!
you save my day ;)
Quote from: Gizmo on December 08, 2006, 01:07:57 PM
OK... I'm the curious type and couldn't help giving this a try. :) I set up my blog to have two images shown from two scripts and I got the same error as you. Then I removed this line from the second script and it worked fine.
include "./cpmfetch/cpmfetch.php";
I also remembered reading on Vuud's site that this only needs to be called once per page.
Yep,
Just as a moving forward note, I am starting to advocate using include_once versus include - simply because there are more and more issues with this sort of thing coming up. I believe include_once will not error out if it gets called a second time... You could also use require_once, but I doubt someone would want the whole page going AWOL on a cpmfetch problem :)
Good point! This way your individual php files are transferrable to other pages without having to edit them which I had to do this morning.
Its very easy
dont close the object in first time only at the end of second time.
First time
<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewRandomMedia(4,1);
?>
Second Time
<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewLastAddedMedia(8,1);
$objCpm->cpm_close();
?>
Hope this can help.
Niks