Log in

View Full Version : Resolved mysql error somewhere



auriaks
11-25-2009, 04:08 PM
hi,
I use this script to insert my info onto mysql:

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:

CREATE TABLE IF NOT EXISTS `inbox` (
`id` int(50) NOT NULL,
`To` varchar(40) character set utf8 collate utf8_lithuanian_ci NOT NULL,
`msg` varchar(1000) character set utf8 collate utf8_lithuanian_ci NOT NULL,
`from` varchar(30) character set utf8 collate utf8_lithuanian_ci NOT NULL,
`look` varchar(30) character set utf8 collate utf8_lithuanian_ci NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`tema` varchar(200) character set utf8 collate utf8_lithuanian_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


but i got error:

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 'To, msg, from, look, date, time, tema) VALUES('mantelis', 'kitas', 'admin', '' at line 1


Whats wrong??

Schmoopy
11-25-2009, 04:17 PM
Try:


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

auriaks
11-25-2009, 05:45 PM
Thanks.... working :D