hello all;
scratching my head because I have no clue why this query doesn't work. php5, mysql 5.1

INSERT INTO cats (title,type,cat_parent,cat_descr) VALUES ('Category Name', '0','0','Category Description')

BASIC insert query.
and the error I get ad infinitum is this:

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 '(title,) VALUES ('Category Name', )' at line 1

if anyone could spot what I'm doing wrong or help, that'd be great. thanks.

:) sxccodette

Is there more code to this, because your query is correct from what I can see.

This..

INSERT INTO `cats` (title, type, cat_parent, cat_descr) VALUES ('Category Name', '0', '0', 'Category Description')

OR, full example..

$sql = mysql_query("INSERT INTO `cats` (title, type, cat_parent, cat_descr) VALUES ('Category Name', '0', '0', 'Category Description')");

What is the field type for (type and cat_parent). You don't need the quote for the integer. Make sure that the field names are also correct.

hi, dear
As i don't know about your fields name and their data types are correct or not.
still you can try this syntax also,

mysql_query("INSERT INTO cats (title,type,cat_parent,cat_descr)VALUES ('Category Name', '0','0','Category Description')");

or try to use die() function in insert query for finding the exact error.

Hi,
I was in the same situation and I find the solution,
what I did was just change the "double quote" for 'simple quotes' and the simples for doubles.....

mysql_query('INSERT INTO cats (title,type,cat_parent,cat_descr)VALUES ("Category Name", "0","0","Category Description")');
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.