SQL Abfrage Error / PHP

  • PHP

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von Link.

    SQL Abfrage Error / PHP

    Huhu, ich wolte heute ein Modul installieren was zu fehlern führt.

    Kurzgesagt die Tabellen werden nicht erstellt bekomme beim Manuell ausführen : ( Fatal error: Using $this when not in object context in )
    Spoiler anzeigen

    PHP-Quellcode

    1. <?php
    2. $GUIDSettings = array(
    3. 'online' => "1",
    4. 'vonline' => "1",
    5. 'ponline' => "0",
    6. );
    7. $GUIDTextsettings = array(
    8. 'Message1' => "You can change this message by going to the admin CP -> My Apps -> GUID System",
    9. 'Message2' => "You can change this message by going to the admin CP -> My Apps -> GUID System",
    10. );
    11. $INSERT = array();
    12. $count = 1;
    13. foreach($GUIDSettings as $name => $title)
    14. {
    15. $test_count = $this->DB->buildAndFetch( array( 'select' => 'count(name) as count', 'from' => 'guid_settings', 'where' => "name='{$name}'" ) );
    16. if($test_count['count'] == 0)
    17. {
    18. $INSERT[] = "INSERT INTO guid_settings (`name` , `vaule` ) VALUES ('{$name}', '{$title}');";
    19. }
    20. $count++;
    21. }
    22. foreach($GUIDTextsettings as $name => $title)
    23. {
    24. $test_count = $this->DB->buildAndFetch( array( 'select' => 'count(name) as count', 'from' => 'guid_settings', 'where' => "name='{$name}'" ) );
    25. if($test_count['count'] == 0)
    26. {
    27. $INSERT[] = "INSERT INTO guid_settings (`name` , `textvaule` ) VALUES ('{$name}', '{$title}');";
    28. }
    29. $count++;
    30. }
    31. $this->DB->update( 'groups', array( 'g_guid_access' => 1 ), "g_id=4" );
    32. ?>


    Spoiler anzeigen

    PHP-Quellcode

    1. [/spoiler][spoiler]<?php
    2. //add table g_guid_access
    3. if ( ! $this->DB->checkForField( 'g_guid_access', "groups" ) )
    4. {
    5. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}groups ADD g_guid_access int(1) not null default 0");
    6. }
    7. if ( ! $this->DB->checkForField( 'g_guid_admin_', "groups" ) )
    8. {
    9. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}groups ADD g_guid_admin_ int(1) not null default 0");
    10. }
    11. if ( ! $this->DB->checkForField( 'g_guid_group_access', "groups" ) )
    12. {
    13. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}groups ADD g_guid_group_access int(1) not null default 0");
    14. }
    15. if ( ! $this->DB->checkForField( 'VGUID', "members" ) )
    16. {
    17. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}members ADD VGUID varchar(32) not null default 'VIP GUID'");
    18. }
    19. if ( ! $this->DB->checkForField( 'PGUID', "members" ) )
    20. {
    21. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}members ADD PGUID varchar(32) not null default 'PUBLIC GUID'");
    22. }
    23. if ( ! $this->DB->checkForField( 'gameonline', "members" ) )
    24. {
    25. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}members ADD gameonline varchar(255) not null default ''");
    26. }
    27. if ( ! $this->DB->checkForField( 'lastcheck', "members" ) )
    28. {
    29. $this->DB->query("alter table {$this->DB->obj['sql_tbl_prefix']}members ADD lastcheck int(255) not null default ''");
    30. }
    31. //lets do the GUID settings now ;)
    32. if ( ! $this->DB->checkForTable( 'guid_settings' ) )
    33. {
    34. $this->DB->query("CREATE TABLE {$this->DB->obj['sql_tbl_prefix']}guid_settings(`name` varchar(255) NOT NULL,`vaule` int(1) NULL, `textvaule` varchar(255) NULL, PRIMARY KEY (name))TYPE=MyISAM AUTO_INCREMENT=1;");
    35. }
    36. //lets do the HACK settings now ;)
    37. if ( ! $this->DB->checkForTable( 'hack_settings' ) )
    38. {
    39. $this->DB->query("CREATE TABLE {$this->DB->obj['sql_tbl_prefix']}hack_settings(`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,`name` VARCHAR( 255 ) NOT NULL ,`exename` VARCHAR( 255 ) NOT NULL default 'Enter your hack execuable here' ,`update` VARCHAR( 255 ) NOT NULL , `announcement` VARCHAR( 255 ) NOT NULL default 'Enter your hack announcement here', PRIMARY KEY ( `id` ) ) ENGINE = MYISAM;");
    40. }
    41. //make our admin group id 4 to admin on GUID tech :)
    42. if ( $this->DB->checkForField( 'g_guid_access', "groups" ) )
    43. {
    44. $this->DB->update( 'groups', array( 'g_guid_access' => 1 ), "g_id=4" );
    45. }
    46. ?>[/spoiler][spoiler]



    Woran liegt es? Sonst muss ich die Tabellen Manuell erstellen nur das Problem ist das zu entziffern :

    Aufbau :
    ibf_guid_settings
    Message1 TEXT "der text"
    Message2 TEXT "der text"

    liege ich soweit richtig?

    Das hat nichts mit SQL zu tun, sondern ist PHP-spezifisch. Thema verschoben. ~Trade

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Trade“ ()

    Servus,

    wie wär's mit mehr Code?
    Deine Fehlermeldung lässt darauf schließen, dass sich der von dir gepostete Code in einer statischen Methode befindet (public static function Irgendwas(){}). Da hast du natürlich keinen Zugriff auf den Objektkontext. Du solltest dort dann mit self::* arbeiten (d.h. auch die entsprechenden abzurufenden Object Properties müssen statisch deklariert werden).


    Link :thumbup:
    Hello World

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Link“ ()