jkewlo Posted December 3, 2008 Share Posted December 3, 2008 hey all I am boogeld again. I am trying to update a record in a table called DateTime in my database $date = date("Y-m-d H:i:s", time()); $sql=("UPDATE members SET DateTime = ". $date ." WHERE username= ". $username ." "); nothing is wrong with my code I don't think anyways well when I go to the database after I log in the DateTime field does not get updated I have it set to varchar(25) and it still does not update any clue why? Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/ Share on other sites More sharing options...
jkewlo Posted December 3, 2008 Author Share Posted December 3, 2008 here is all of the code from the check.php page <?php session_start(); include("Data/connect.php"); // username and password sent from form $username = $_POST['myusername']; $password = $_POST['mypassword']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql = "SELECT * FROM members WHERE username='" . $username . "' and password='" . $password . "'"; $result = mysql_query($sql); // Mysql_num_row is counting table row $count = mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if ($count == 1) { $date = date("Y-m-d H:i:s", time()); $sql="UPDATE members SET DateTime = ". $date ." WHERE username= ". $username ." "; // Register $myusername, $mypassword and redirect to file "member.php" $_SESSION['status'] = 'logged'; $_SESSION['myusername'] = $username; $_SESSION['Admin'] = $rows['level']; $level = $rows['level']; header("location: member.php"); } else { echo "Wrong Username or Password"; } ?> Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/#findComment-704774 Share on other sites More sharing options...
ILMV Posted December 3, 2008 Share Posted December 3, 2008 Why don't you just set your date datatype as 'datetime'? That will do it all for you? Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/#findComment-704785 Share on other sites More sharing options...
PFMaBiSmAd Posted December 3, 2008 Share Posted December 3, 2008 Since your code for the UPDATE query does not have a mysql_query() statement in it, how are you expecting the query to get executed? You have got a mysql_query() statement for the SELECT query, why not for the UPDATE query? Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/#findComment-704951 Share on other sites More sharing options...
jkewlo Posted December 3, 2008 Author Share Posted December 3, 2008 Oooo OK wasn't sure if i needed one there but now i understand as well as getting some sleep what to do thanks Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/#findComment-705185 Share on other sites More sharing options...
jkewlo Posted December 3, 2008 Author Share Posted December 3, 2008 hemm :'( it still doesnt work <?php session_start(); include("Data/connect.php"); // username and password sent from form $username = $_POST['myusername']; $password = $_POST['mypassword']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql = "SELECT * FROM members WHERE username='" . $username . "' and password='" . $password . "'"; $result = mysql_query($sql); // Mysql_num_row is counting table row $count = mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if ($count == 1) { // Register $username, $password and redirect to file "member.php" $_SESSION['status'] = 'logged'; $_SESSION['myusername'] = $username; $_SESSION['Admin'] = $rows['level']; $level = $rows['level']; header("location: member.php"); } else { echo "Wrong Username or Password"; } $date = date("Y-m-d H:i:s", time()); $sql1="UPDATE members SET DateTime = ". $date ." WHERE username= ". $username ." "; $result1 = mysql_query($sql1); ?> Link to comment https://forums.phpfreaks.com/topic/135305-php-time-date-function/#findComment-705188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.