how to add custom php script - DOESN'T WORK :( - Page 2 how to add custom php script - DOESN'T WORK :( - Page 2
 

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

Main Menu

how to add custom php script - DOESN'T WORK :(

Started by gabIT, April 19, 2004, 09:04:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

shutiri

ok...  thank you. 
Can I create a new topic with the title "phpadsnew/CPG integration" so if somebody knows or already had this trouble can answer me ?

shutiri.

sigepjedi

GauGau


Ive read through many of the posts regarding phpads, and implementing the banner invokation code into coopermine, and as with many of the others Ive ran into the same problems.

Ive followed all the steps throughout this post regardig the modification of theme.php and creating '{BANNER}' => theme_custom_banner() in the $template_vars portion of this file.

Having said that, and reaching the same road blocks, here is a new piece of information to this puzzel:
Running debug upon reaching the roadblock "There was an error while processing a database query."
Ive come across the following:

------------------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
------------------------

'BW' is my prefix for Coopermine, and 'adclicks' is my prefix for my phpads database.

If looks as though calling the invocation code of phpads is placing its database name infront of the remaining calls in coopermine. And then the rest just goes to hell.

Thoughts?


Joachim Müller

yes: the mySQL connection to your banner software hasn't been established properly. I'm not sure if your banner script will work at all - you simply can't combine some sorts of scripts.

GauGau

DefenceTalk.com

Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.defencetalk.com%2Fpictures%2Fsignature_cpg.php&hash=c0098ed5314d39beb9e8799c7c8787a9a0353b45)

sigepjedi

Quote from: DefenceTalk.com on June 07, 2004, 01:51:31 PM
Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)

We are using that method of calling banners. I dont think you are grasping the issue at hand with PHPADS.

GAUGAU:

Is there a way in which to re-set the coppermine DB names, or DB prefixes. I think if i re-set this variable after I make my call to phpads, then everything would be back to normal in the coopermine world following the PHPADS call.

Joachim Müller

I don't understand fully - do you mean you want to end the established connection to the db at some point, or do you want to just rename the prefix once?

GauGau

sigepjedi

in calling the banner.php code, thus initiating the communication link to PHPADS, it apparently sets the DB prefix or connection VAR to its own known variable.

-----------EXAMPLE---------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
-----------EXAMPLE---------------

coopermine fires, DB name/prefix =  "BW_"
PHPADS fires, DB name/prefix is modified to: "adclicks.BW_"

apparently it overwrites this prefix variable used in DB connectivity.

After I make my call to PHPADS, can i re-initiate the coppermine DB prefix back to "BW_"?

So my code for banner.php would look something like:

Quote
<?php
// PHPADS BANNER CODE
   if (@include('C:/PHPADS/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('', 31, '_blank', '', '0', $phpAds_context);
        $phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
    } 
    // Assign the $phpAds_raw['html'] variable to your template
    echo $phpAds_raw['html'];
   $banner = "<center>$phpAds_raw['html']</center>";
// PHPADS BANNER CODE

//RE-INITIATE THE DB PREFIX HERE

?>

So that once PHPADS was done, and coopermine continues through its processes remaining, it has the correct DB prefix.

Joachim Müller

I'm not sure what vars are being reset by phpAds, try re-setting the db prefix after the phpAds code like this:$CONFIG['TABLE_PREFIX'] = "yourCopperminePrefix_";

GauGau

sigepjedi

Negative Ghost-Rider, same thing.

I added to the last line of my Banner.php file the re-setting of the DB prefix var.

DEBUG INFO

There was an error while processing a database query.
Quote
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0

mySQL error: Table 'adclicks.bw_comments' doesn't exist


File: C:\The\Path\To\MySite\include\functions.inc.php - Line: 101


Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098

Line 101 of functions.inc.php contains the following (LN 87- LN 103)
Quote
// Error message if a query failed
function db_error($the_error)
{
       global $CONFIG;

       if (!$CONFIG['debug_mode']) {
           cpg_die(CRITICAL_ERROR, 'There was an error while processing a database query', __FILE__, __LINE__);
       } else {

               $the_error .= "\n\nmySQL error: ".mysql_error()."\n";

               $out = "<br />There was an error while processing a database query.<br /><br/>
                   <form name='mysql'><textarea rows=\"8\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form>";

           cpg_die(CRITICAL_ERROR, $out, __FILE__, __LINE__);
       }
}

Line 1098 of functions.inc.php contains the following (LN1091 - LN 1102)
Quote
     if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){

              // return the url to the wm script
              return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

      }else{
              // it's a thumb, don't bother wm'ing
              if (is_null($pic_row['pid']) || !isset($CONFIG['url_mode']) || $CONFIG['url_mode']!='hide')
               return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
             return 'get_file.php?pid='.$pic_row['pid'].'&size='.$mode;

      }

and, at the very bottom the SQL Query Debug Info:
Quote
USER:
Array
(
   [ID] => f906caa6dd5e01a219b7fb162eca3287
   [am] => 1
   [liv] => Array
       (
           
  • => 108
               [1] => 263
               [2] => 78
               [3] => 202
           )

    )


    GET :
    Array
    (
    )


    POST :
    Array
    (
    )

Thoughts?

jriba

GauGau:

What's the PRO/CON of making a function in theme.php for the phpAdsNew code (or any other code for that matter) and then inserting the {BANNER} tag into template.html

vs.

insertint the phpAdsNew code directly into template.html ???

Nibbler

Only html can go into the template. PHP goes into the theme.php

lucasnet

I have a question. I use this solution but i have 1 problem. When i enetered a this codes script show at the bottom of page. Not where {BLABLA} is but at first, before logo. ??? What i must do ?
LuCaS ( lucas@tuning4u.info ) GG: 40139
---------------------------------------------------------
http://tuning4u.info - best wallpapers and tuning photos

Nibbler

The code you have added probably outputs using echo or similar. It should return all its output as the result of the function in which it resides. If you can't do this easily you can use output buffering to capture the output.

jriba

I have solved this problem!

Add the phpAdsNew "Local Mode" php invocation code to the "../include/functions.inc.php" file.  Add it "AS IS" how the phpAdsNew code generator gives it to you.  Make sure to click on "Store the banner inside a variable so it can be used in a template" before generating the phpAdsNew code.  And add it to functions.inc.php at the very top, before
// Decode the user profile contained in a cookie
function user_get_profile()


Thats it for the functions.inc.php file.

Edit themes.php, find:
global $CONFIG, $THEME_DIR;
replace it with:
global $CONFIG, $THEME_DIR, $phpAds_raw;

and find:
'{ADMIN_MENU}' => theme_admin_mode_menu()
add after:
'{BANNER}' => $phpAds_raw['html']

and make sure to add a comma (" , ") at the end of '{ADMIN_MENU}' => theme_admin_mode_menu() to make it look like this '{ADMIN_MENU}' => theme_admin_mode_menu(),since you are adding to the array.

That's it..

Enjoy!

lucasnet

LuCaS ( lucas@tuning4u.info ) GG: 40139
---------------------------------------------------------
http://tuning4u.info - best wallpapers and tuning photos

jriba

I should probably also mention 2 things that might be obvious to some, but not others:

1) Remember to put the {BANNER} where ever you want the banner to appear in template.html

2) Remember to take out the first and last lines of the invocation code: "<$php" and "?>", when you put it in functions.inc.php

That's it!