INSERT INTO

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

INSERT INTO

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: INSERT INTO

Post by requinix »

Weird quoting you got going on there.
kevinwinters
Forum Newbie
Posts: 20
Joined: Wed Jan 06, 2010 8:31 pm

Re: INSERT INTO

Post 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....
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: INSERT INTO

Post 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' ");
kevinwinters
Forum Newbie
Posts: 20
Joined: Wed Jan 06, 2010 8:31 pm

Re: INSERT INTO

Post by kevinwinters »

What is the error? Is your friend_id field formatted as a number or text?
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: INSERT INTO

Post 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.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: INSERT INTO

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