need MYSQL help here

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wedouglas
    So Fucking Banned
    • Aug 2004
    • 5921

    #1

    need MYSQL help here

    whats wrong with this command?

    Insert into bBadult_config
    (id, name, value)
    VALUES (
    ('1', 'EMAIL', 'change@me'),
    ('2', 'BLOGNAME', '.$config['blogname'].'),
    ('3', 'TEMPLATE', 'default'),
    ('4', 'DB_TEMPLATES', 'false'),
    ('5', 'DEFAULT_MODIFIER', 'simple'),
    ('6', 'DEFAULT_STATUS', 'live'),
    ('7', 'PING','false'),
    ('8', 'COMMENT_MODERATION','none'),
    ('9', 'NOTIFY','false'),
    ('12', 'META_DESCRIPTION', 'Some words about this blog'),
    ('13', 'META_KEYWORDS','work,life,play,web design'),
    ('15', 'EMAIL','[email protected]'),
    ('10', 'BLOG_DESCRIPTION', '.$config['blogdescription'].'),
    ('14', 'LAST_MODIFIED', UNIX_TIMESTAMP());


    Its telling me:

    ERROR 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 ' 'EMAIL', 'change@me'),
    ('2', 'BLOGNAME', '.$config['blogname']
  • Varius
    Confirmed User
    • Jun 2004
    • 6890

    #2
    I believe you are missing a closing ) at the end.
    Skype variuscr - Email varius AT gmail

    Comment

    • jwerd
      Confirmed User
      • Jun 2003
      • 1953

      #3
      Instead of:
      ('2', 'BLOGNAME', '.$config['blogname'].'),
      Try:
      ('2', 'BLOGNAME', '".$config['blogname']."'),
      Yii Framework Guru - Seasoned PHP vet - Partner @ XXXCoupon.com

      Comment

      • wedouglas
        So Fucking Banned
        • Aug 2004
        • 5921

        #4
        nope and nope....

        Comment

        • rickholio
          Confirmed User
          • Jan 2004
          • 1914

          #5
          You have an extra ( after values. Multi row inserts have brackets around each row, not around all rows.

          Also, every one of those $config[blogname]'s need to be encapsulated in additional quotes unless $config[blogname] is guaranteed to be a number of some variety.

          HTH. HAND.

          BTW - you *can* use subscripted arrays within quotes in PHP, thusly:

          $result = mysql_query("Insert into bBadult_config
          (id, name, value)
          VALUES
          (1, 'EMAIL', 'change@me'),
          (2, 'BLOGNAME', '$config[blogname]'),
          (3, 'TEMPLATE', 'default'),
          (4, 'DB_TEMPLATES', 'false'),
          (5, 'DEFAULT_MODIFIER', 'simple'),
          (6, 'DEFAULT_STATUS', 'live'),
          (7, 'PING','false'),
          (8, 'COMMENT_MODERATION','none'),
          (9, 'NOTIFY','false'),
          (12, 'META_DESCRIPTION', 'Some words about this blog'),
          (13, 'META_KEYWORDS','work,life,play,web design'),
          (15, 'EMAIL','[email protected]'),
          (10, 'BLOG_DESCRIPTION', '$config[blogdescription]'),
          (14, 'LAST_MODIFIED', UNIX_TIMESTAMP())");
          Last edited by rickholio; 06-13-2005, 11:19 PM.
          ~

          Comment

          • rickholio
            Confirmed User
            • Jan 2004
            • 1914

            #6
            I also hope that you're filtering and mysql_real_escape_string()ing any data that might be user-input, so's to take care of storing data with quotes and stripping out possible exploit code.
            ~

            Comment

            • Meorazhar
              Confirmed User
              • May 2005
              • 672

              #7
              Hello,
              use
              ('2', 'BLOGNAME', $config['blogname']),
              instead of
              ('2', 'BLOGNAME', '.$config['blogname'].'),

              Same applies to this:
              ('10', 'BLOG_DESCRIPTION', '.$config['blogdescription'].'),

              Comment

              • Meorazhar
                Confirmed User
                • May 2005
                • 672

                #8
                And, like it was stated, you will need an extra closing )

                Comment

                • wedouglas
                  So Fucking Banned
                  • Aug 2004
                  • 5921

                  #9
                  Originally posted by rickholio
                  I also hope that you're filtering and mysql_real_escape_string()ing any data that might be user-input, so's to take care of storing data with quotes and stripping out possible exploit code.
                  Im just trying to create a fix for a problem im having. is there a quick way to copy data from one table to another?

                  Comment

                  • rickholio
                    Confirmed User
                    • Jan 2004
                    • 1914

                    #10
                    Originally posted by wedouglas
                    Im just trying to create a fix for a problem im having. is there a quick way to copy data from one table to another?
                    Code:
                    insert into TARGET_TABLE 
                      select column1, column2, column3, etc from SOURCE_TABLE 
                        where some_column=some_criteria;
                    ~

                    Comment

                    • wedouglas
                      So Fucking Banned
                      • Aug 2004
                      • 5921

                      #11
                      thanks. I just cant seem to figure out this issue. I have a blog installed on my main domain http://www.digitalconfessional.net

                      but when i try to install another one on the subdomain http://adult.digitalconfessional.net it wont work.

                      Even if i tell it to use the same database and table prefix. makes no sense

                      Comment

                      Working...