• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

PHP error

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
what is wrong with it?

Parse error: syntax error, unexpected '?'
PHP:
echo $account->getPlayervip_time(); ? "</br ><center><b>You have '.$account->getPlayervip_time().' VIP days.";
 
Last edited:
Parse error: syntax error, unexpected '?'
PHP:
echo $account->getPlayervip_time(); ? "</br ><center><b>You have '.$account->getPlayervip_time().' VIP days.";
 
Parse error: syntax error, unexpected ';'
PHP:
echo $account->getPlayervip_time() ? '</br ><center><b>You have '.$account->getPlayervip_time().' VIP days.';

Parse error: syntax error, unexpected '?'
PHP:
echo $account->getPlayervip_time(); ? "</br ><center><b>You have '.$account->getPlayervip_time().' VIP days.";
 
echo $account->getPlayervip_time() ? "</br ><center><b>You have '.$account->getPlayervip_time().' VIP days." : '';
 
ModernAAC/system/application/views/account.php
Code:
<?php 
$GLOBALS['characters'] = $characters;
$ide = new IDE;
try { $ide->loadInjections("account"); } catch(Exception $e) { error($e->getMessage()); }
	echo "<h2>Hello <a href='".url('profile/view/'.$_SESSION['nickname'])."'>".ucfirst($_SESSION['nickname'])."</a>!</h2>";
	
	if($messages != 0)
		if($messages == 1)
			echo "<center><b>You have $messages new message! Click <a href='".url('msg/inbox')."'>here</a> to read them!</b></center><br/>";
		else
			echo "<center><b>You have $messages new messages! Click <a href='".url('msg/inbox')."'>here</a> to read them!</b></center><br/>";
?>

<?php

echo "<div id='tabs'>";
echo '<ul>
		<li><a href="#characters">Characters</a></li>
		<li><a href="#account">Account</a></li>
		<li><a href="#community">Community</a></li>
		<li><a href="#logout">Logout</a></li>
	</ul>';
	echo "<div id='characters'>";
	echo "<center><a href='".WEBSITE."/index.php/character/create_character'><button class='ide_button' onClick=\"window.location.href='".WEBSITE."/index.php/character/create_character';\">Create Character</button></a></center>";
	echo "<table width='100%'>";
	echo "<tr><td><center><b>Name</b></center></td><td><center><b>Level</b></center></td><td><center><b>Actions</b></center></td></tr>";
	foreach($characters as $row) {
		echo "<tr><td><center><a href=\"".WEBSITE."/index.php/character/view/$row->name\">$row->name</a></center></td><td><center>$row->level</center></td><td><center><a href=\"".WEBSITE."/index.php/account/editcomment/$row->id\" class='tipsy' title='Edit comment'><img src='".WEBSITE."/public/images/edit.gif'/></a> <a href='#' onClick='if(confirm(\"Are you sure?\")) window.location.href=\"".WEBSITE."/index.php/account/deletePlayer/$row->id\"' class='tipsy' title='Delete character'><img src='".WEBSITE."/public/images/false.gif'/></a><a href='#' onClick='if(confirm(\"Are you sure?\")) window.location.href=\"".WEBSITE."/index.php/account/undeletePlayer/$row->id\"' class='tipsy' title='Undelete character'>
<img src='".WEBSITE."/public/images/true.gif'/></a></center></td></tr>";
	
	}
	echo "</table>";
	echo "</div>";
	echo "<div id='account'>";
	echo "<center><a href='".WEBSITE."/index.php/account/changepassword'><button class='ide_button' onClick=\"window.location.href='".WEBSITE."/index.php/account/changepassword';\">Change password</button></a></center>";
	[COLOR="#FF0000"]echo "<center><b>You have ".$account->getPlayervip_time()." VIP days.";[/COLOR]
	echo "</div>";
	echo "<div id='community'>";
		echo "<b>Profile</b>";
		echo "<li><a href='".WEBSITE."/index.php/profile/update'>Edit Profile</a></li>";
		echo "<li><a href='".WEBSITE."/index.php/profile/avatar'>Update Avatar</a></li>";
		echo "<br/><b>Messages</b>";
		echo "<li><a href='".WEBSITE."/index.php/msg/inbox'>Inbox</a></li>";
		echo "<li><a href='".WEBSITE."/index.php/msg/outbox'>Outbox</a></li>";
		echo "<li><a href='".WEBSITE."/index.php/msg/write'>Write New</a></li>";
	echo "</div>";
	echo "<div id='logout'>";
		echo "<br /><center><b>Are you sure you want to log out?</b><br /><br /><a href='".WEBSITE."/index.php/account/logout'><button class='ide_button' onClick=\"window.location.href='".WEBSITE."/index.php/account/logout';\">Logout</button></a></center>";
	echo "</div>";
echo "</div>";

if(empty($acc[0]['rlname']) || empty($acc[0]['location']) || empty($acc[0]['about_me']))
	alert("You might consider updating your public profile <a href='".WEBSITE."/index.php/profile/update'><b>here</b></a>!");
?>
 
PHP:
echo "<center><b>You have ".$account->getCustomField('vip_time')." VIP days.";
 
It wasn't anything wrong with your column, works fine here.

Have you tried to reset the VIP days?

Code:
UPDATE accounts SET vip_time = 0
UPDATE accounts SET vip_time = vip_time + 7
 
I changed to 20 in mysql and in game it shows: 10:49 Your vip has finished in 31 December 1969 22:00:20 and now is 07 October 2012 10:49:45

- - - Updated - - -

When I add 20 days in-game it shows 1351345876 in mysql

- - - Updated - - -

I look on vip lib
LUA:
vip = {
   name = "Vip system";
   author = "Mock";
   version = "1.0.0.0";
   query="ALTER TABLE `accounts` ADD `vip_time` INTEGER";
   query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL"
}

function vip.setTable()
   dofile('config.lua')
   if sqlType == "sqlite" then
   	db.executeQuery(vip.query)
   else
        db.executeQuery(vip.query2)
   end
end

function vip.getVip(cid)
         assert(tonumber(cid),'Parameter must be a number') 
         if isPlayer(cid) == FALSE then error('Player don\'t find') end; 
         ae =  db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
         if ae:getID() == -1 then
            return 0
         end

local retee = ae:getDataInt("vip_time") or 0
ae:free()
         return retee
end

function vip.getVipByAcc(acc)
         assert(acc,'Account is nil')
         local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
         if a:getID() ~= -1 then
             return a:getDataInt("vip_time") or 0, a:free()
         else
             error('Account don\'t find.')
         end
end

function vip.setVip(cid,time)
         dofile("config.lua")
         assert(tonumber(cid),'Parameter must be a number')
         assert(tonumber(time),'Parameter must be a number')
         if isPlayer(cid) == FALSE then error('Player don\'t find') end; 
         db.executeQuery("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';")
end

function vip.getVipByAccount(acc)
         assert(acc,'Account is nil')
         return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0
end                                      

function vip.hasVip(cid)
         assert(tonumber(cid),'Parameter must be a number')
         if isPlayer(cid) == FALSE then return end;
         local t = vip.getVip(cid) or 0
         if os.time(day) < t then
            return TRUE
         else
            return FALSE
         end
end

function vip.hasVips(cid)
         assert(tonumber(cid),'Parameter must be a number')
         if isPlayer(cid) == FALSE then return end;
         local t = vip.getVip(cid)
         if os.time(day) < t then
            return TRUE
         else
            return FALSE
         end
end

function vip.accountHasVip(acc)
         assert(acc,'Account is nil')
         if os.time() < vip.getVipByAccount(acc) then
            return TRUE
         else
            return FALSE
         end
end
function vip.getDays(days)
   return (3600 * 24 * days)
end

function vip.addVipByAccount(acc,time)
   assert(acc,'Account is nil')
   assert(tonumber(time),'Parameter must be a number')
   local a = vip.getVipByAcc(acc)
   a = os.difftime(a,os.time())
   if a < 0 then a = 0 end;
   a = a+time
   return vip.setVipByAccount(acc,a)
end

function vip.setVipByAccount(acc,time)
         dofile("config.lua")
         assert(acc,'Account is nil')
         assert(tonumber(time),'Parameter must be a number')
         db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
         return TRUE
end

function vip.returnVipString(cid)
   assert(tonumber(cid),'Parameter must be a number')
   if isPlayer(cid) == TRUE then
      return os.date("%d %B %Y %X ", vip.getVip(cid))
   end
end

getDataInt("vip_time"), isnt it?
 
UNIX timestamps.
This should work:
Code:
echo "<center><b>You have ".intval(($account->getPlayervip_time() -  time())/86400)." VIP days.";
 
Wooow, thank you rep!

- - - Updated - - -

Can you help with it?
PHP:
		function AddPremium($name,$days) {
			$SQL = $this->connect();
			$account = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('UPDATE accounts SET vip_time = (vip_time + '.$days.') WHERE name = "'.$account['name'].'"');
		}
 
I tried to use it inside sql but just got errors

- - - Updated - - -

PHP:
		function AddPremium($name,$days) {
			$SQL = $this->connect();
			$account = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('UPDATE accounts SET vip_time = (vip_time + VAR) WHERE name = "'.$account['name'].'"');
		}

In VAR i tried: now(), timestamp, localtime, localtime(), LOCALTIME()*86400, LOCALTIME()/86400, now()/86400, ".intval((vip_time() - time())/86400).", ('.$days.' * 86400)
All these values are adding wrong days(sometime years) of vip

- - - Updated - - -

I realy cant make it work, can someone help?
 
Last edited:
Back
Top