Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Problem with two cpmfetch codes on one site  (Read 7013 times)

0 Members and 1 Guest are viewing this topic.

El_Kevo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Problem with two cpmfetch codes on one site
« on: December 08, 2006, 08:38:59 am »

Hi! i have a problem with cpmfetch!

i have this code on the left side of my page
Code: [Select]
<?php include("bilder_zufall.php"); ?>(for random pictures)
which is include this code:
Code: [Select]
<?php 
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewRandomMedia(4,1);
$objCpm->cpm_close();
?>


and on the right side this code
Code: [Select]
<?php include("bilder_neu.php"); ?>(for new pictures)
which include this code:

Code: [Select]
<?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)
Code: [Select]
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 ;)
Logged

Gizmo

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1015
    • BullsEye Photos
Re: Problem with two cpmfetch codes on one site
« Reply #1 on: December 08, 2006, 12:42:07 pm »

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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1015
    • BullsEye Photos
Re: Problem with two cpmfetch codes on one site
« Reply #2 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.

Code: [Select]
include "./cpmfetch/cpmfetch.php";
I also remembered reading on Vuud's site that this only needs to be called once per page.
Logged
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

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Problem with two cpmfetch codes on one site
« Reply #3 on: December 08, 2006, 01:13:27 pm »

great man! thanks a lot!

you save my day ;)
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: Problem with two cpmfetch codes on one site
« Reply #4 on: December 08, 2006, 03:52:14 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.

Code: [Select]
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 :)


Logged
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

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1015
    • BullsEye Photos
Re: Problem with two cpmfetch codes on one site
« Reply #5 on: December 08, 2006, 04:01:14 pm »

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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 73
Re: Problem with two cpmfetch codes on one site
« Reply #6 on: December 19, 2006, 09:37:18 pm »

Its very easy
dont close the object in first time only at the end of second time.

First time
Code: [Select]
<?php 
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewRandomMedia(4,1);
?>

Second Time
Code: [Select]
<?php 
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gallery");
$objCpm->cpm_viewLastAddedMedia(8,1);
$objCpm->cpm_close();
?>

Hope this can help.
Niks
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 19 queries.