I get this error message: Insert 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 'testing this thing again' at line 2

NOTE: the 'testing this thing again' is $body

This is my MySQL setup.

CREATE TABLE `articles` (
  `id` int(20) NOT NULL auto_increment,
  `loginid` varchar(19) NOT NULL,
  `title` varchar(25) NOT NULL,
  `author` varchar(30) NOT NULL,
  `body` text NOT NULL,
  `date` date default NULL,
  `category` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
$link = mysql_connect('xxxxx.xxxxxx.com', 'xxxxx','xxxxxx');
if (! $link) die(mysql_error());
mysql_select_db($db , $link) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO articles (`loginid`,`title`,`author`,`body`,`date`,`category`) 
VALUES ('".$loginid."','".$title."','".$author.",'".$body."','".$today."','".$category."')")
or die("Insert Error: ".mysql_error());
print "Record added\n";

Any help is appreciated!

Recommended Answers

All 3 Replies

Member Avatar for diafol
mysql_query("INSERT INTO articles (`loginid`,`title`,`author`,`body`,`date`,`category`) VALUES ('$loginid','$title','$author','$body','$today','$category')") or die...
commented: tsk tsk tsk +1

Thanks again. I'll come eat your brain Ardav maybe i get some of that knowledge! >:)

Member Avatar for diafol

Seriously, don't. I'm mad as a box of frogs. Can't keep focused on anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.