Problem with two cpmfetch codes on one site Problem with two cpmfetch codes on one site
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Problem with two cpmfetch codes on one site

Started by El_Kevo, December 08, 2006, 08:38:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

El_Kevo

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 ;)

Gizmo

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
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

Gizmo

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.
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

El_Kevo


vuud

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


Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Gizmo

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.
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

niks_007

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