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: Plugin install code help.  (Read 6196 times)

0 Members and 1 Guest are viewing this topic.

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Plugin install code help.
« on: October 28, 2007, 02:32:37 pm »

Hello,

I am making a plugin and seems to be good apart from the install function.
It works without the install function but just reports a critical error when i put the code in. Heres the code:

Code: [Select]
<?php 
function this_install() {
global 
$CONFIG;

   
$sql = ("INSERT INTO `{$CONFIG['TABLE_PREFIX']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");

$result mysql_query($sql);


}
?>

any ideas?

thanks,
« Last Edit: October 31, 2007, 07:55:23 am by GauGau »
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Plugin install code help.
« Reply #1 on: October 28, 2007, 02:44:15 pm »

GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad

you forget table name under query
Logged
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #2 on: October 28, 2007, 03:48:51 pm »

Sorry, that was an error when i posted its actually `{$CONFIG['TABLE_CONFIG']}`  and it doesent work. just returns the error.
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #3 on: October 28, 2007, 07:34:54 pm »

I have made an improvment.

I know have this:

Code: [Select]
function this_install() {

    // Install
    if ($_POST['submit']=='Submit') {

        return true;

        // Loop again
    } else {

        return 1;
    }
 $sql = ("INSERT INTO `{$CONFIG['TABLE_CONFIG']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");


}


When i click install it shows the configure part of the codebase and when i click submit it just loops the same page. What is wrong with the above code?

Thanks,

ps the if else clause in that code is from the FileMove plugin.


Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Nibbler

  • Guest
Re: Plugin install code help.
« Reply #4 on: October 28, 2007, 08:34:08 pm »

1. Code placed after a return; will never run.
2. $sql is just a string, so does nothing anyway. You need to actually run the query using cpg_db_query($sql).
Logged

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #5 on: October 28, 2007, 08:50:10 pm »

I now have this:

What should go after the $_POST? is it correct?

Code: [Select]
function this_install() {

    // Install
    if ($_POST['submit']=='Submit') {
   
 $sql = ("INSERT INTO `{$CONFIG['TABLE_CONFIG']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");

   cpg_db_query($sql);
        return true;

        // Loop again
 } else {


        return 1;
    }




}

And it just does the same, any ideas?

Thanks Nibbler
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #6 on: October 28, 2007, 09:36:15 pm »

I fixed it, but when you create the admin button what should it link to? i know its plugin_name/????

Thanks,
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Plugin install code help.
« Reply #7 on: October 29, 2007, 04:39:04 am »

It depends on what you up to with admin button , usually it links to configuration (e.g. config.php)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Plugin install code help.
« Reply #8 on: October 29, 2007, 08:45:07 am »

GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad
Moving accordingly.

Logged

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #9 on: October 29, 2007, 06:27:18 pm »

Using Frantz's backup plugin as an example the link is "file=backup/backup"  where does this link to? is it backup.php where backup is the file which contains the config? am i getting the function of "function plugin_configure()" confused? Right now i am thinking that this contains the information that can be configured (ie the content that the button links to). This may be wrong and i need to then create a file called config.php to contain the config information.

What is correct?

Thanks,
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Plugin install code help.
« Reply #10 on: October 29, 2007, 06:57:14 pm »

file=folder/file means :
include file.php from {gallery root}/plugins/folder into index.php


and yes backup.php contains configuration settings for that plugin
You can name the file, what ever you want to
Logged
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #11 on: October 29, 2007, 07:47:09 pm »

Aha! thanks,the problem is that the .php extension is not required. it can just be file="plugin/config". Thanks Sami.

On the config page how do i make it fit in with the theme?
What file must i include to solve this error on the config page?
Undefined variable: CONFIG
Call to undefined function cpg_db_query()

Thanks,

And very sorry for all the questions, im not new to php and mysql but i am new to pluginizing.
« Last Edit: October 29, 2007, 08:00:33 pm by just_some_guy »
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Plugin install code help.
« Reply #12 on: October 30, 2007, 04:44:20 am »

just add this to the very first of your file to define CONFIG and coppermine functions
Code: [Select]
require('include/init.inc.php');

then use pageheader function to add coppermine header to your page
Code: [Select]
pageheader($title);
$title is your page title
Logged
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D
Re: Plugin install code help.
« Reply #13 on: October 30, 2007, 10:24:24 pm »

Fantastic Sami, thats much better thanks again!
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 19 queries.