UTime not writing or loading database

Hello all,

So here I picked up UTime and installed it on my brothers DarkRP. I linked it up to his DarkRP database so he can view it later from the web and his loadingpage.
I checked the database connection, and when it is connecting it doesn’t return an error.
But, the time is not saving to his database and not loading from his database, what’s te problem?



-- Written by Team Ulysses, http://ulyssesmod.net/
module( "Utime", package.seeall )
if not SERVER then return end

utime_welcome = CreateConVar( "utime_welcome", "1", FCVAR_ARCHIVE )

require ("mysqloo")                // Include the modules
 
local DATABASE_HOST = "127.0.0.1"   // database host (can be an ip)
local DATABASE_PORT = 3306                // port to the database, you probably wont need to change this unless you get told to
local DATABASE_NAME = "darkrp"       // name of the database
local DATABASE_USERNAME = "root"        // username which you use to access it
local DATABASE_PASSWORD = "b3stp4ssw0rd3v4h"          // password of the username

function connectToDatabase()
	databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
	databaseObject.onConnectionFailed = function() print("Failed to connect to the database, totaltime not initialized!") end
	databaseObject:connect()
end
connectToDatabase()

if not sql.TableExists( "darkrp_player" ) then
	databaseObject:query( "CREATE TABLE IF NOT EXISTS darkrp_player ( totaltime INTEGER NOT NULL, lastvisit INTEGER NOT NULL );" )
end

function onJoin( ply )
	local uid = ply:UniqueID()
	local row = databaseObject:query( "SELECT totaltime, lastvisit FROM darkrp_player WHERE uid = " .. uid .. ";" )
	local time = 0

	if row then
		databaseObject:query( "UPDATE darkrp_player SET lastvisit = " .. os.time() .. " WHERE uid = " .. uid .. ";" )
		time = row.totaltime
	else
		databaseObject:query( "INSERT into darkrp_player ( totaltime, lastvisit ) VALUES ( 0, " .. os.time() .. " );" )
	end
	ply:SetUTime( time )
	ply:SetUTimeStart( CurTime() )
	print( "Time of " .. ply:GetName() .. " loaded from database with value of: " .. math.floor( ply:GetUTimeTotalTime() ) )
	
end
hook.Add( "PlayerInitialSpawn", "UTimeInitialSpawn", onJoin )

function updatePlayer( ply )
	databaseObject:query( "UPDATE darkrp_player SET totaltime = " .. math.floor( ply:GetUTimeTotalTime() ) .. " WHERE uid = " .. ply:UniqueID() .. ";" )
	print( "Time of " .. ply:Nick() .. " Saved to database with value of: " .. math.floor( ply:GetUTimeTotalTime() ) )
	end
hook.Add( "PlayerDisconnected", "UTimeDisconnect", updatePlayer )

function updateAll()
	local players = player.GetAll()

	for _, ply in ipairs( players ) do
		if ply and ply:IsConnected() then
			updatePlayer( ply )
		end
	end
end
timer.Create( "UTimeTimer", 67, 0, updateAll )



It doesn’t seem that the IP points to anything. Are you sure it is the IP of a web server?

Ip points to localhost, on darkrp mysql config this works.

try
[lua]
if table.getn(row) > 0 then
[/lua]

instead of
[lua]
if row then
[/lua]

doesn’t work.

EDIT: even the mysql version of UtimeMOO doesn’t write to table darkrp_player (edited yes)