Page 1 of 1
INSERT INTO
Posted: Tue Mar 09, 2010 11:31 pm
by manRay
I have know idea why this is not working. Every thing is correct, in terms of connecting to the DB.
Code: Select all
mysql_query ("INSERT INTO friend_info (FRIEND_ID,FULL_NAME,BIRTH_DATE,FAV_COLOR) VALUES (''1',bill gates','10-25-1967','green')");
Can anybody see why?
Re: INSERT INTO
Posted: Tue Mar 09, 2010 11:36 pm
by requinix
Weird quoting you got going on there.
Re: INSERT INTO
Posted: Tue Mar 09, 2010 11:38 pm
by kevinwinters
the 2 single quotes in front of 1 and looks like bill gates is missing single quote in front of his name.
those 2 items look odd to me....
Re: INSERT INTO
Posted: Wed Mar 10, 2010 8:43 am
by manRay
This doesn't work either
Code: Select all
mysql_query(" INSERT INTO friend_info SET FRIEND_ID ='7', FULL_NAME = 'bill gates', BIRTH_DATE = '10-25-1967', FAV_COLOR = 'green' ");
Re: INSERT INTO
Posted: Wed Mar 10, 2010 8:52 am
by kevinwinters
What is the error? Is your friend_id field formatted as a number or text?
Re: INSERT INTO
Posted: Wed Mar 10, 2010 8:53 am
by manRay
Nothing is getting inserted into the DB. I removed friend_ID from the query because it is a primary id that gets auto incremented.
Re: INSERT INTO
Posted: Wed Mar 10, 2010 4:56 pm
by mikosiko
manRay wrote:I have know idea why this is not working. Every thing is correct, in terms of connecting to the DB.
Code: Select all
mysql_query ("INSERT INTO friend_info (FRIEND_ID,FULL_NAME,BIRTH_DATE,FAV_COLOR) VALUES (''1',bill gates','10-25-1967','green')");
Can anybody see why?
you got answers to it in the first 2 posts.... don't know why you changed your syntaxes to INSERT... SET (which is incomplete).... your error is your
" usage...
try this.. (assuming FRIEND_ID is an auto-generated key)
Code: Select all
mysql_query("INSERT INTO friend_info (FRIEND_ID,FULL_NAME,BIRTH_DATE,FAV_COLOR) VALUES (NULL,'bill gates','10-25-1967','green')");