Insert query whats wrong with it

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
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Insert query whats wrong with it

Post by mohson »

Could someone please tell me whats wrong with my insert query - it worked perfectly but once I tried to incorporate my DATE_FORMAT code it stoped working - the date format code itself works fine as when I print results with the select query it works properly. its just I need to incorporate it into my insert as well - there is probably just something wrong with the order can anyone help.

Code: Select all

"INSERT INTO people 
			(person_id,org_id, salutation, 
			firstname, surname, organisation, role, 
			address1, address2, city, postcode, telephone, 
			mobile, fax, dateoflastcontact, datecontactagain, 
			notes, email)
	


 	VALUES 
			('$person_id','$org_id','$salutation',
			'$firstname','$surname', '$organisation', 
			'$role', '$address1', '$address2', '$city', 
			'$postcode', '$telephone', '$mobile', '$fax', 
			'$dateoflastcontact', '$datecontactagain', 
			'$notes', '$email')
		
	DATE_FORMAT(dateoflastcontact, '%d/%m/%y') 
		AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%d/%m/%y') 
		AS datecontactagain 
			
					"; 
ї\code]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your date format code is outside the insertion syntax.

Why do you want to store the date in a nonstandard way?
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

You can simply store the timestamp in an int(11) field - if you need any specific format, apply it a later stage through php's date() function... MySQL has it's own date type field but a timestamp as basic as it gets...
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Feyd, I want to insert the date in UK format which is dd-mm-yy which is how I have set the Date format could you show me how to make my code above work - as in which order to write it in??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you are using a mysql date type, it must be inserted in using their format. When selecting the data, you can format the date in whatever form you wish.
Post Reply