Results 1 to 3 of 3

Thread: mysql error somewhere

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default mysql error somewhere

    hi,
    I use this script to insert my info onto mysql:
    PHP Code:
    mysql_query("INSERT INTO inbox (To, msg, from, look, date, time, tema) 
            VALUES('
    $to', '$msg', '$from', '$look', '$date', '$time', '$tema')") or die(mysql_error()); 
    My table rows are:
    PHP Code:
    CREATE TABLE IF NOT EXISTS `inbox` (
      `
    idint(50NOT NULL,
      `
    Tovarchar(40character set utf8 collate utf8_lithuanian_ci NOT NULL,
      `
    msgvarchar(1000character set utf8 collate utf8_lithuanian_ci NOT NULL,
      `
    fromvarchar(30character set utf8 collate utf8_lithuanian_ci NOT NULL,
      `
    lookvarchar(30character set utf8 collate utf8_lithuanian_ci NOT NULL,
      `
    datedate NOT NULL,
      `
    timetime NOT NULL,
      `
    temavarchar(200character set utf8 collate utf8_lithuanian_ci NOT NULL,
      
    PRIMARY KEY  (`id`)
    ENGINE=MyISAM  DEFAULT CHARSET=latin1
    but i got error:
    PHP Code:
    You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near 'To, msg, from, look, date, time, tema) VALUES('mantelis', 'kitas', 'admin', '' at line 1 
    Whats wrong??
    Last edited by auriaks; 11-25-2009 at 05:46 PM.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Try:

    PHP Code:
    mysql_query("INSERT INTO inbox (`To`, `msg`, `from`, `look`, `date`, `time`, `tema`) 
            VALUES('
    $to', '$msg', '$from', '$look', '$date', '$time', '$tema')") or die(mysql_error()); 
    This will make them read as columns and not as statements.
    Since some columns can be confused, like DATE and FROM

  3. #3
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    Thanks.... working

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
  •