Trium918 Posted December 10, 2006 Share Posted December 10, 2006 I am trying to create a script that will store the user registeration date in a database so that I can keep track of the user last visit to my website. If anyone can help me, I will be more than happy to accept any ideas of where to start first.[code=php:0]$host="localhost";$database="Date"; //The name of the database$dusername="root";//$dpassword="";$x=mysql_connect($host,$database,$dusername/*,$dpassword*/);$x1=mysql_select_db($database)or die("Could not select Date database !");/*$user_date is the name of the column in the database but how do I insert the user register date into the variable $user_dateso that it can be stored inside $user_date which will be stored in the database called Date?*/$query="INSERT into Date Values('".$user_date."')";$result=mysql_query($query);if (!($result)) { die("User Register date could not be stored"); } [/code] Link to comment https://forums.phpfreaks.com/topic/30133-date-and-time/ Share on other sites More sharing options...
paul2463 Posted December 10, 2006 Share Posted December 10, 2006 [code]<?php$user_date = date("Y-m-d"); //this is the date NOW$query="INSERT into Date ($user_date) Values ('$user_date')" $result=mysql_query($query) or die("User Register date could not be stored");?>[/code] Link to comment https://forums.phpfreaks.com/topic/30133-date-and-time/#findComment-138522 Share on other sites More sharing options...
Trium918 Posted December 10, 2006 Author Share Posted December 10, 2006 Paul2463, when I try it your way, the [code=php:0]or die("User Register date could not be stored");[/code] is the result that I am getting. Link to comment https://forums.phpfreaks.com/topic/30133-date-and-time/#findComment-138528 Share on other sites More sharing options...
papaface Posted December 10, 2006 Share Posted December 10, 2006 try:[code]<?php$user_date = date("Y-m-d"); //this is the date NOW$query="INSERT into Date ($user_date) Values ('".$user_date."')";$result=mysql_query($query) or die("User Register date could not be stored");?>[/code] Link to comment https://forums.phpfreaks.com/topic/30133-date-and-time/#findComment-138529 Share on other sites More sharing options...
AndyB Posted December 10, 2006 Share Posted December 10, 2006 Change the error messaging so it's more helpful while testing:$result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);What is name of the [b]table[/b]? Link to comment https://forums.phpfreaks.com/topic/30133-date-and-time/#findComment-138533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.