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

Edited by sexycodette: n/a

7 Years
Discussion Span
Last Post by Adiel

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



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')");

Edited by Clarkeez: n/a


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.

Edited by monica singh: n/a


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")');
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.