kendallkamikaze Posted November 27, 2008 Share Posted November 27, 2008 I've been working on this all night...in my sql under my "players" table I added a lastlog field. ive been trying to get it to post the date into the lastlog field but I cant seem to get the coding right. I've been putting the code in "loggedin.php" which is where you get directed to once you log in. <?php mysql_query("update player set lastlog=NOW() where id='$id'"); ?> please help?? Quote Link to comment Share on other sites More sharing options...
unkwntech Posted November 27, 2008 Share Posted November 27, 2008 Assuming you have connected to the database that should work, and IIRC the lastlog column needs to be a timestamp type. Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 IIRC the lastlog column needs to be a timestamp type. im new to all this, is it connected to the DB, i know what a timestamp is, but not sure what IIRC is? Quote Link to comment Share on other sites More sharing options...
unkwntech Posted November 27, 2008 Share Posted November 27, 2008 IIRC - If I remember correctly Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 you may also need to have single quotes around NOW() Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 do i have to have it set to timestamp or can i just use the date stamp? Quote Link to comment Share on other sites More sharing options...
corbin Posted November 27, 2008 Share Posted November 27, 2008 you may also need to have single quotes around NOW() NOW() is a function. Quotes are only put around strings. do i have to have it set to timestamp or can i just use the date stamp? It needs to be one of MySQL's built in timestamp types. datetime for example. Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 <?php require_once 'databaseconnection.php'; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $Username=$_POST['Username']; $Password=$_POST['Password']; $Username= stripslashes($Username); $Password = stripslashes($Password); $Username = mysql_real_escape_string($Username); $Password = mysql_real_escape_string($Password); $sql="SELECT * FROM player WHERE Username='$Username' and Password='$Password'"; $result=mysql_query($sql); $id=$r["id"]; $count=mysql_num_rows($result); if($count==1){ session_register("Username"); session_register("Password"); session_register("id"); header("location:loggedin.php"); $date = date("m/d/y"); $update = @mysql_query("UPDATE player SET lastlog = '$date' WHERE id = '".$_SESSION['id']."'"); setcookie("Username", "$Username"); setcookie("Password", "$Password"); setcookie("id", "$id"); $playerid=$_POST['playerid']; mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'"); } else { echo "You have entered the wrong login information"; } ?> this is what i have, but for some reason the DB is not reading it and setting the date :/ Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 change this: mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'"); to this: mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'")or die(mysql_error); Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 change this: mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'"); to this: mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'")or die(mysql_error); nope, didnt work Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 Did that display any error message? Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 Did that display any error message? no error message at all. Quote Link to comment Share on other sites More sharing options...
corbin Posted November 27, 2008 Share Posted November 27, 2008 Change mysql_error to mysql_error() Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 haha... Silly me Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 Change mysql_error to mysql_error() <?php require_once 'databaseconnection.php'; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $Username=$_POST['Username']; $Password=$_POST['Password']; $Username= stripslashes($Username); $Password = stripslashes($Password); $Username = mysql_real_escape_string($Username); $Password = mysql_real_escape_string($Password); $sql="SELECT * FROM player WHERE Username='$Username' and Password='$Password'"; $result=mysql_query($sql); $id=$r["id"]; $count=mysql_num_rows($result); if($count==1){ session_register("Username"); session_register("Password"); session_register("id"); header("location:loggedin.php"); $date = date("m/d/y"); $update = @mysql_query("UPDATE player SET lastlog = '$date' WHERE id = '".$_SESSION['id']."'"); setcookie("Username", "$Username"); setcookie("Password", "$Password"); setcookie("id", "$id"); $playerid=$_POST['playerid']; mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'")or die mysql_error(); } else { echo "You have entered the wrong login information"; } ?> i get an error with this code. with this code: <?php require_once 'databaseconnection.php'; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $Username=$_POST['Username']; $Password=$_POST['Password']; $Username= stripslashes($Username); $Password = stripslashes($Password); $Username = mysql_real_escape_string($Username); $Password = mysql_real_escape_string($Password); $sql="SELECT * FROM player WHERE Username='$Username' and Password='$Password'"; $result=mysql_query($sql); $id=$r["id"]; $count=mysql_num_rows($result); if($count==1){ session_register("Username"); session_register("Password"); session_register("id"); header("location:loggedin.php"); $date = date("m/d/y"); $update = @mysql_query("UPDATE player SET lastlog = '$date' WHERE id = '".$_SESSION['id']."'"); setcookie("Username", "$Username"); setcookie("Password", "$Password"); setcookie("id", "$id"); $playerid=$_POST['playerid']; mysql_query("UPDATE player SET lastlog=NOW() where playerid='$id'")or mysql_error(); } else { echo "You have entered the wrong login information"; } ?> there is no error but its still not functioning. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 Your die function needs to look like this: or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 Your die function needs to look like this: or die(mysql_error()); still not functioning. :/ this damn code is driving me nuts...should I put it on a different page? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 If you have php MyAdmin, do this: 1. go to the database you are using 2. Click on "SQL" 3. Type this: DESCRIBE player 4. Press Go If you are using SSH, do this: 1. type this (press enter): USE db_name 2. type this (press enter): DESCRIBE player Once you have done one of the above, copy and paste the results here Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 If you have php MyAdmin, do this: 1. go to the database you are using 2. Click on "SQL" 3. Type this: DESCRIBE player 4. Press Go If you are using SSH, do this: 1. type this (press enter): USE db_name 2. type this (press enter): DESCRIBE player Once you have done one of the above, copy and paste the results here id int(10) unsigned NO PRI NULL auto_increment Username text NO MUL NULL Password text NO NULL Playername text NO MUL NULL Firstname text NO NULL Email text NO NULL TOS text NO NULL Guidelines text NO NULL lastlog date NO NULL Points int(11) NO NULL AcademyLevel text NO NULL Associations text NO NULL Barns text NO NULL Money int(11) NO NULL Description text NO NULL Status text NO NULL Behavioural text NO NULL GirlScout int(11) NO NULL YourMom int(11) NO NULL Tutor text NO NULL TraitAdd text NO NULL onstatus text NO NULL chatlli timestamp NO 0000-00-00 00:00:00 banfromchat varchar(255) NO no banfromchatreason varchar(255) NO NULL TraitNumber int(11) NO NULL BarnShow text NO NULL banreason text NO NULL special text NO NULL refered varchar(32) NO No referer text NO NULL referalpoints int(11) NO NULL vet text NO NULL farrier text NO NULL trainer text NO NULL breeder text NO NULL Team int(11) NO 1 tstatus text NO NULL tpoints int(11) NO NULL IP varchar(50) NO NULL Browse varchar(50) NO NULL layout varchar(20) NO layouts_phism.php gold text NO NULL awards text NO NULL PS; they make me smile too. hhahahaha sorry i just read your icon and no im not a lesbian. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 Using the same method, run this: ALTER TABLE `player` CHANGE `lastlog` `lastlog` TIMESTAMP NOT NULL Who doesn't like boobies? Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 Who doesn't like boobies? eh I just like mine for the most part. i have a feeling theres not that many on this forum though hah Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2008 Share Posted November 27, 2008 I've seen two tonight Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 still not working ??? booo if you can get this right you'll desurve to see some boobies...seriously. Quote Link to comment Share on other sites More sharing options...
corbin Posted November 27, 2008 Share Posted November 27, 2008 >.< Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted November 27, 2008 Author Share Posted November 27, 2008 >.< whaaaaa << see that face? thats how i look right now and i might just cry. 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.