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
Your create table has no syntax errors. Are you doing inserts afterwards? You'll need to show us the INSERT instead.
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):
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 ''.
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: