[help] sql error

Discussion in 'Databases' started by flyzz, Aug 23, 2009.

  1. #1
    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 't', 'sdfgbsdfgsdfgs', 'main', '0', '0', '1251038498','2009-08-23 02:36:38')' at line 1

    this is the error ^^^^

    it is when you add a ' or another punctuation mark or sometihng in there the table is as follows

    
    -- 
    -- Table structure for table `topics`
    -- 
    
    CREATE TABLE `topics` (
      `id` int(11) NOT NULL auto_increment,
      `username` varchar(100) NOT NULL default '',
      `title` int NOT NULL,
      `topictext` text NOT NULL,
      `forum` enum('main','crew','ooc','classifieds','main1','cw92','cw93','cw94','cw95','c1','c1','c3','c4','c5','c6','c7','c8','c9','c10','c11','c12','c13','c14','c15','c16','c17','c18','c19','c20','c21','rip') NOT NULL default 'main',
      `locked` enum('0','1') NOT NULL default '0',
      `sticky` enum('0','1') NOT NULL default '0',
      `lastreply` varchar(100) NOT NULL default '',
      `made` datetime NOT NULL default '0000-00-00 00:00:00',
      `crew` varchar(100) NOT NULL default '',
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=4347 DEFAULT CHARSET=latin1 AUTO_INCREMENT=4347 ;
    
    Code (markup):

    i need help asap if you need more details
     
    flyzz, Aug 23, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your create table has no syntax errors. Are you doing inserts afterwards? You'll need to show us the INSERT instead.
     
    premiumscripts, Aug 23, 2009 IP
  3. flyzz

    flyzz Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    mysql_query("INSERT INTO `topics` (`id`, `username`, `title`, `topictext`, `forum`, `locked`, `sticky`, `lastreply`,`made`,`crew`) VALUES ('', '$username', '$title1', '$topictext', '$forum', '0', '0', '$time','$timer','$fetch->crew');") or die (mysql_error());
    }else{
    mysql_query("INSERT INTO `topics` (`id`, `username`, `title`, `topictext`, `forum`, `locked`, `sticky`, `lastreply`,`made`) VALUES ('', '$username', '$title', '$topic_text', '$forum', '0', '0', '$time','$timer');") or die (mysql_error());
    }
    
    Code (markup):
     
    flyzz, Aug 23, 2009 IP
  4. flyzz

    flyzz Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    anyone!....
     
    flyzz, Aug 23, 2009 IP
  5. Smart Hero

    Smart Hero Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you can use.
    mysqld --skip-grant-tables -u mysql &
     
    Smart Hero, Aug 23, 2009 IP
  6. flyzz

    flyzz Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    where?????
     
    flyzz, Aug 23, 2009 IP
  7. Smart Hero

    Smart Hero Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    by a program SSH
     
    Smart Hero, Aug 23, 2009 IP
  8. flyzz

    flyzz Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    how :s could you do it ?
     
    flyzz, Aug 23, 2009 IP
  9. Smart Hero

    Smart Hero Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    you should have SSH in your site for use it.

    if you haven't SSH, you should call your host.
     
    Smart Hero, Aug 23, 2009 IP
  10. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You need to mysql_real_escape_string() every value.

    So do : '" . mysql_real_escape_string($username) . "', '" .... etc

    Also, you don't need an autoincremented column in your sql, so you can remove the id column and the empty ''.
     
    premiumscripts, Aug 24, 2009 IP
  11. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #11
    Do an echo of your mysql string so we can see the actual query that is being sent to mysql so:
    echo "INSERT INTO `topics` (`id`, `username`, `title`, `topictext`, `forum`, `locked`, `sticky`, `lastreply`,`made`,`crew`) VALUES ('', '$username', '$title1', '$topictext', '$forum', '0', '0', '$time','$timer','$fetch->crew');"
    PHP:
     
    superdav42, Aug 25, 2009 IP