Problem with install and uninstall code

Matthew Hawley

Well-known member
I get this error when I try to save.
LIkmLyn.png


Here is my code for Install.php

Code:
<?php

class CF_Directory_Install {

  public static function install($addon) {

    $db = XenForo_Application::get('db');

    $db->query("CREATE TABLE IF NOT EXISTS `xf_ci_directory_pages` (

                  `page_id` int(11) unsigned NOT NULL AUTO_INCREMENT,

                  `route` varchar(25) NOT NULL DEFAULT '',

                  `display_order` int(11) NOT NULL DEFAULT '0',

                  PRIMARY KEY (`page_id`)

                ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;");

  }

class CF_Directory_Uninstall {

  public static function uninstall() {

    $db = XenForo_Application::get('db');

    $db->query("DROP TABLE `xf_cf_directory_pages`;");

  }

}
 
You are dropping the wrong table: $db->query("DROP TABLE `xf_cf_directory_pages`;");

Regardless, posting the error message next time would help.
 
Now when I try it, I get this.

Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in /home3/xxx/public_html/xxx/library/CF/Directory/Install.php on line 27
 
You should also add IF EXISTS to your uninstall drop table:

$db->query("DROP TABLE IF EXISTS `xf_cf_directory_pages`;");
 
Back
Top Bottom