Results 1 to 10 of 10

Thread: Adding table to database

  1. #1
    Join Date
    Aug 2009
    Posts
    79

    Default Adding table to database

    Hi forum

    I'm creating an addon to display announcements on agents admin page and I want to store the announcements in the database in a new table. I'm wondering if the table will be wiped out in the future if I upgrade it. Is there a way to prevent this.

  2. #2
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Adding table to database

    As long as you don't name your new DB table the same as an existing OR DB table, an upgrade won't touch it.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  3. #3
    Join Date
    Aug 2009
    Posts
    79

    Default Re: Adding table to database

    cool, Thank you

  4. #4
    Join Date
    Aug 2009
    Posts
    79

    Default Re: Adding table to database

    Hi forum

    I'm creating the notification addon discussed above and I'm creating the code so that I can add messages to the database but I'm having trouble with the insert statement. it's giving me an unexpected $end error and I can't figure it out. I checked to make sure that I have all of the curly brackets since this is the common reason I get this error they all match up. since the addon code is pretty lengthy below is the code just for the function i'm having trouble with. Can anyone help me figure out what I did wrong.

    PHP Code:
    function announcement_newmessage () {
     
    $admincheck login::loginCheck('Admin'true);
        if(
    $admincheck !== true) {
    //DO NOTHING: ADMIN NOT LOGGED
    } else {
    if(!isset(
    $_POST['submit'])) {
    $self $SERVER['PHP_SELF'];
    $display .= '<form id="newmessage name="newmessage" method="post" action="'.$self.'">';

    $display .= '<fieldset>';
    $display .= '<legend>New Message</legend>';
    $display .= '<table>';
    $display .= '<tr>';
    $display .= '<td>Date</td><td><input type="text" name="announcementdb_date" value=""></td>';
    $display .= '</tr>';
    $display .= '<tr>';
    $display .= '<td>Subject</td><td><input type="text" name="announcementdb_subject" value=""></td>';
    $display .= '</tr>';
    $display .= '<tr>';
    $display .= '<td>Message</td><td><textarea name="announcementdb_messge" cols= 80 rows=10 value=""></textarea></td>';
    $display .= '</tr>';
    $display .= '<tr>';
    $display .= '<td><input type="submit" name="submit" id="submit" value="submit"></td>';
    $display .= '</tr>';
    $display .= '</table>';
    $display .= '</fieldset>';
    $display .= '</form>';
    return 
    $display;
    } else {
    global 
    $config$conn$jscript;
    //    $jscript .= '<link href="' . $config['baseurl'] . '/addons/announcement/announcement.css" rel="stylesheet" type="text/css" />' . "\r\n";
        
    require_once($config['basepath'].'/include/misc.inc.php');
        
    $misc = new misc();
    $announcementdb_date $_POST['announcementdb_date'];
    $announcementdb_subject $_POST['announcementdb_subject'];
    $annuoncementdb_message $_POST['announcementdb_message'];
    $sql'INSERT INTO  ' $config['table_prefix'] . 'announcementdb (announcementdb_id, announcementdb_date, announcementdb_subject, announcementdb_message) VALUES('.".', '.$announcementdb_date.', '.$announcementdb_subject.', '.$announcementdb_message.')';
    $recordSet = $conn->Execute($sql);
    $display .= 'message added';
    }
    }


  5. #5
    Join Date
    May 2004
    Location
    Long Island, NY
    Age
    49
    Posts
    9,796

    Default Re: Adding table to database

    Your sql statement has an error with the quotes somewhere. Looks like it is here: VALUES('.".', '

    I think maybe the '' needs to be escaped (\'\').

  6. #6
    Join Date
    Aug 2009
    Posts
    79

    Default Re: Adding table to database

    thanks i'll try it.

    While I have your attention, have you gotten a chance to read the message I sent you. I was inquiring about customization of your paypal addon. your addon only allows one payment per listing and I wanted to edit this to be able to charge by subscription or allow more than one listing per payment. Can you help me out plz.

  7. #7
    Join Date
    May 2004
    Location
    Long Island, NY
    Age
    49
    Posts
    9,796

    Default Re: Adding table to database

    Really backed up on emails. Will look for it when I get home from work tonight and respond.

  8. #8
    Join Date
    Aug 2009
    Posts
    79

    Default Re: Adding table to database

    I'm still having trouble with the insert statement for my addon. Any ideas on what I'm doing wrong? I tried making the changes PBFlash suggested but it still gave me the same syntax error. I'm wrecking my brains on this one, so if anyone has any idea about what's causing the error please help me out.

  9. #9
    Join Date
    May 2004
    Location
    Long Island, NY
    Age
    49
    Posts
    9,796

    Default Re: Adding table to database

    You need quotes around the values you are inserting. The values section should be:

    VALUES(\'\', \' '.$announcementdb_date.' \', \' '.$announcementdb_subject.' \', \' '.$announcementdb_message.' \')';

  10. #10
    Join Date
    Aug 2009
    Posts
    79

    Default Re: Adding table to database

    Thanks, it working perfectly.

    Also, sorry to be a nag but I sent you another private message regarding the paypal customization. If you can take a quick look at it and let me know if you can help me I would be greatly appreciated.

Similar Threads

  1. Adding table around featuring listing
    By bighomebuyers.com in forum Templates - Help/Ideas/Discussion (CLOSED)
    Replies: 1
    Last Post: 01-07-2009, 07:56 PM
  2. Database Error adding new listing
    By tomyken in forum General Help (CLOSED)
    Replies: 1
    Last Post: 03-02-2008, 09:03 PM
  3. 5 open realty installs using same user database table
    By bit in forum General Help (CLOSED)
    Replies: 0
    Last Post: 09-05-2006, 09:06 AM
  4. 5 open realty installs using same user database table
    By bit in forum General Discussion
    Replies: 0
    Last Post: 09-05-2006, 09:06 AM
  5. Temporay Table to permenant table!
    By brilliants in forum HELP (CLOSED)
    Replies: 2
    Last Post: 02-12-2005, 08:48 AM

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
  •