mysql - Wrong datetime is stored in database -


my table looks (..., date1, date2, date3, date4, date5, ...)

and code this:

date_default_timezone_set('europe/london');  $date = date("y-m-d h:i:s");  $query = mysqli_query($db, "insert table (date1, date2, date3, date4, date5) values ('$date','$date','$date','$date','$date'); 

problem date2 have server new york datetime, while date1, date3, date4 , date5 have london datetime.

how possible? used same variable $date attributes. in table defined datetime not null.

i'm not familiar mysqli (i use pdo) maybe should verify if database has default values date fields.

also, if i'm not wrong, shoud use double quotes in query.

finally, you should take care sql injection (wikipedia.org/wiki/sql_injection). you're query may vulnerable.

regards,

jonathan f.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -