![]() |
| ||
| Re: Duplicate entry '' for key 2 OK, what I mean is the following $new_text is the variable name by which you refer to it in your code. The variable value is the value of $_GET['whatever']. My question is - your string INSERT INTO `article_fields`(`field_title`, `field_type`) VALUES("'.$new_text.'","'.$field_type.'")looks exactly as you would have it typed into your code. But when you call the page wich contains ECHO "INSERT STRING HERE $variable"; and PHP parses the code - the html output should be something like INSERT STRING HERE my value. So what bothers me in your post is that if the HTML output of the echo command is exactly as you have it posted here, there is something wrong in the formatting of your php string. Do you understand me better now? |
| ||
| Re: Duplicate entry '' for key 2 the ` (which are different than ') are not necessary, but I see phpMyAdmin and other programs use them a lot so it kind of became a habit of mine. it also helps me identify database and table names in the queries i write. i wrote the column names in so we could avoid silly errors that i figured s/he would have. cali_dotcom: if you have some code to look at, post it. maybe we can find if something else is preventing this from working, because i know the sql i posted works. |
| ||
| Re: Duplicate entry '' for key 2 It seems your table is not auto-incrementing... Try to add "AUTO_INCREMENT" to your primary key: CREATE TABLE table ( id_primary INT UNSIGNED NOT NULL AUTO_INCREMENT... |
| ||
| Re: Duplicate entry '' for key 2 mysql_query(sprintf("insert into article_fields (new_text, fields_type) values ('%s', '%s');", $new_text, $field_type)) |
| All times are GMT -4. The time now is 3:59 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC