Malkavbug Posted March 15, 2006 Share Posted March 15, 2006 Hit an odd issue tonight, and really am too tired to start to dig for an answer. Basically a datetime issue.Also, I appreciate any replies, and in the name of me trying to learn how this works could you please explain why it isn't working, not just how to fix it? I would greatly appreciate it.Here is the code (respaced and all for these forums)[code]$sql = "INSERT INTO members(Handle,Password,Email,CreateDate,RegionGroup,AgeGroup,Sex) VALUES('$NewHandle',password('$NewPassword'),'$email','NOW()','$region','$age','$sex')";[/code]DB Side (MySQL) I am atCreateDate datetime Not Null default = 0000-00-00 00:00:00All other columns are inputing correctly, except CreateDate, which is just entering the defauly value of 0000-00-00 00:00:00Probably as simple as giving [code]'NOW()'[/code] a value before the insert, such as [code]'NOW()'= "$timenow"[/code]or it could just be some issue with me having it in upper case.Either way, brain fried for tonight, just glad the account creation portion is working.Also, if you know off the top of your head now to grab the users IP addess and assign it to a variable it would be much appreciated (same deal, want to into it into a column) :P Quote Link to comment Share on other sites More sharing options...
Steveo31 Posted March 15, 2006 Share Posted March 15, 2006 NOW() is a function, not a translated value, so remove the single quotes.INSERT INTO table VALUES('something', 'other value', NOW(), 'other values); Quote Link to comment Share on other sites More sharing options...
Malkavbug Posted March 15, 2006 Author Share Posted March 15, 2006 Fixed it. you rock! :P I image it is the same deal with the inserting the users IP address once I find that function (assuming there is a function for this, trying to dig for it myself)I really appreciate the help, it was driving me nuts. So any functions being inserted do not need quotes around them, only variables. Quote Link to comment Share on other sites More sharing options...
keeB Posted March 15, 2006 Share Posted March 15, 2006 [!--quoteo(post=355197:date=Mar 15 2006, 02:52 AM:name=Malkavbug)--][div class=\'quotetop\']QUOTE(Malkavbug @ Mar 15 2006, 02:52 AM) [snapback]355197[/snapback][/div][div class=\'quotemain\'][!--quotec--]Fixed it. you rock! :P I image it is the same deal with the inserting the users IP address once I find that function (assuming there is a function for this, trying to dig for it myself)I really appreciate the help, it was driving me nuts. So any functions being inserted do not need quotes around them, only variables.[/quote]Anything that is a string would get quotes around them, but if you had $x = 10, insert into tblHi(id) values ($x) would work. Functions do not, because then they don't get evaluated. :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.