Results 1 to 6 of 6
  1. #1
    Join Date
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default How to get a new mod to automatically create its own table?

    Hello everyone,
    I’m working on a customer testimonials mod for ZenCart and I want to make this mod setup the tables automatically I know you can create tables using php but I’m not having any luck I’m not that great with my php coding just yet so any suggestions on what I’m doing wrong would be great, thanks guys.

    Code:
    <?PHP
    $buildSQL = "
    CREATE TABLE `zen_testimonials` (
      `id` int(6) NOT NULL auto_increment,
      `image` varchar(255) default NULL,
      `quote` longtext,
      `business_name` varchar(255) default NULL,
      `location` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    CREATE TABLE `zen_testimonials_settings` (
      `id` int(6) NOT NULL auto_increment,
      `testimonials_title` varchar(255) default NULL,
      `testimonials_link_title` varchar(255) default NULL,
      `items_per_row` char(3) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    INSERT INTO `zen_testimonials_settings` VALUES ('1', 'Testimonials', 'Testimonials v1.0', '5');";
    @mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Unable to connect");
    @mysql_select_db(DB_DATABASE) or die("Unable to select database DB_DATABASE");
    $result = mysql_query("SELECT testimonials_link_title FROM zen_testimonials_settings");
    $i = mysql_fetch_row($result);
    if(!$i){mysql_query($buildSQL);}
    $testimonials_link_title = $i[0];
    $za_contents[] = array("text" => "$testimonials_link_title", "link" => zen_href_link("testimonials.php?session=display", "", "NONSSL"));
    mysql_close();
    ?>

  2. #2
    Join Date
    Mar 2006
    Posts
    919
    Plugin Contributions
    2

    Default Re: How to get a new mod to automatically create its own table?

    Just out of interest... did you know that a testimonials contribution already exists?

    http://www.zen-cart.com/index.php?ma...roducts_id=446

  3. #3
    Join Date
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default Re: How to get a new mod to automatically create its own table?

    Yes, that mod would not install there was a problem with the .sql file it would not work via zencart admin or Navicat. Also the mod I'm working on has other features that Testimonial Manager does not have.

  4. #4
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default Re: How to get a new mod to automatically create its own table?

    Quote Originally Posted by IllusionGuy View Post
    Yes, that mod would not install there was a problem with the .sql file it would not work via zencart admin or Navicat. Also the mod I'm working on has other features that Testimonial Manager does not have.
    I'd be interested to know exactly what problem(s) you had installing "Testimonial Manager"

  5. #5
    Join Date
    May 2007
    Posts
    136
    Plugin Contributions
    0

    Default Re: How to get a new mod to automatically create its own table?

    This is the error I get from: admin -> tools -> install sql patches
    Code:
    1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Test Site', '', 'This is just a test submission to show you how it looks, grea' at line 1
    in:
    [INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde's Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), '0000-00-00 00:00:00');]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
    Navicat:
    Code:
    1146 - Table 'loyaltee.configuration_group' doesn't exist

  6. #6
    Join Date
    Nov 2005
    Location
    Colorado Springs, CO USA
    Posts
    7,033
    Plugin Contributions
    31

    Default Re: How to get a new mod to automatically create its own table?

    Quote Originally Posted by IllusionGuy View Post
    This is the error I get from: admin -> tools -> install sql patches
    Code:
    1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Test Site', '', 'This is just a test submission to show you how it looks, grea' at line 1
    in:
    [INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde's Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), '0000-00-00 00:00:00');]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
    Navicat:
    Code:
    1146 - Table 'loyaltee.configuration_group' doesn't exist
    You can try this and see if it works (the correction is highlighted):

    INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde\'s Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), , NULL);

    The newest version of the mod has this correction. This version also includes the following features:

    * options in admin for image display (Width, Height, and Directory
    * options in admin to display "Company", "City" and "State/Country" fields on the Add testimonial page.
    * administrators can add an image as well as a link to the author's site
    * Submission of testimonials can be restricted to registered customers
    * Random display of testimonials in side box
    * Display testimonial title, truncated text in sidebox
    * Display testimonial submission date

 

 

Similar Threads

  1. Replies: 0
    Last Post: 5 Feb 2013, 10:08 AM
  2. Create your own product bundles mod
    By slanphear in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 29 Dec 2011, 05:00 PM
  3. re: customers dbase table corrupted. How can I create new one
    By anthonytjm in forum General Questions
    Replies: 0
    Last Post: 2 Aug 2010, 03:19 PM
  4. How do I move the qty box/buy now button etc to its own column in product listing?
    By b3motorsports in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 11 Feb 2008, 07:48 AM
  5. How do i create my own sideboxes?
    By Jodz in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 3 Nov 2006, 02:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR