Timestamp help

Forum
Last Post
Threads / Messages
Maybe the user has logged in, but the data aint saved properly. Or perhaps the login data was saved but not retrieved properly. You need to check the database table where the lastlogin field is stored, and see if it is 0 or NULL.
In the database it's NULL and on the profile it shows the N/A.

The database is setup like this:

lastlogin | INT | 20 | Default: Null | NULL

This is my class_userprofile.php

private function aboutme(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$title = new Comment($mysidia->lang->basic.$mysidia->input->get("user"));
$membersince = $mysidia->db->select("users", array("membersince"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$line = $mysidia->db->select("online", array("username"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
if($line == $mysidia->input->get("user")){$online = "<font color=green>Online</font>";}else{$online = '<font color=red>Offline</font>';}
$usergroup = $mysidia->db->select("users", array("usergroup"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$groups = $mysidia->db->select("groups", array("groupname"), "gid = '{$usergroup}'")->fetchColumn();
$deluxe = $mysidia->db->select("users", array("deluxe"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$active = $mysidia->db->select("users", array("active"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$inactive = $mysidia->db->select("users", array("inactive"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$expires = $mysidia->db->select("users", array("expires"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
$css = $mysidia->db->select("companion", array("css"), "unlocked = '{$this->companion}'")->fetchColumn();

$lastLoginDate = $current_user_i2->lastlogin ? (new DateTime("@{$current_user_i2->lastlogin}"))->format("d-m-Y") : "N/A";

$str_bio = stripslashes($this->bio);
$basicinfo = "<strong>Member Since:</strong> {$membersince}<br>
Online Status: {$online}</br>
Last Active: {$lastLoginDate}<br>
Title: {$groups}<br>
Deluxe:{$deluxe} <font color='red'><i>{$inactive}</i></font><font color='green'><i>{$active}</font></i> <b>{$expires}</b><br>
Name: {$this->nickname}{$nickname}<br>
Gender: {$this->gender}<br>
<br>
Bio: <br><b>{$str_bio}</b>"; 1630475807375.png
 
If it is null in database, then you need to save this record to the database with an update query. If it is not null in database, then maybe you have not found a way to retrieve the record from database.
 
<b>Member Since:</b> {$membersince->format('d-m-Y')}</br>
Adding this in gave me this error

Fatal error: Call to a member function format() on null in /home/atrocity/public_html/view/profileview.php on line 204
Line 204 is where that is

NEVERMIND I was missing the CAps on the S in since- works now- thanks <3
 
If it is null in database, then you need to save this record to the database with an update query. If it is not null in database, then maybe you have not found a way to retrieve the record from database.
Hey Famer, I ended up going back and working with my code again since I couldn't get this working and I got mine working! I have no idea why it matters(I'm still learning) but for some reason my code worked exactly the way it was when I made my mod, but I had to switch my database lastlogin to users_profile table instead of users. It liked that and is now working lol. I guess that explains why it wasn't working in users, it only worked for my account, and when I went to other profiles my time stamp showed up on other's profiles. After moving it to users_profile everything is working normal now. Individuals are getting their times stamped.

I updated my mod and renewed the resource.
 
I think it works this way because the user profile page uses the UserProfile class as model, rather than the User/Member class. But anyway, I am glad you got it to work.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,267
Messages
33,048
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top