Jump to content

PHP errors


sdg2008

Recommended Posts

Hopefully someone can help.

The following code was working fine, until I added the 3 lines under [<a href=attack.php?ID={$r['userid]}'>Attack</a>]<br />";

I originally had an error because I'd not closed off that line. I've done that and now I'm getting repeated errors. Anybody able to shed any light on it?

<?php
include "globals.php";
$_GET['u'] = abs((int) $_GET['u']);
if(!$_GET['u'])
{
print "Invalid use of file";
}
else
{
$q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}");
if($db->num_rows($q) == 0)
{
print "Sorry, we could not find a user with that ID, check your source.";
}
else
{
$r=$db->fetch_row($q);
if($r['user_level'] == 1) { $userl="Member"; } else if($r['user_level'] == 2) { $userl="Admin"; } else if ($r['user_level'] == 3) { $userl="Secretary"; } else if($r['user_level'] == 0) { $userl="NPC"; }  else {$userl="Assistant"; }
$lon=($r['laston'] > 0) ?date('F j, Y g:i:s a',$r['laston']) : "Never";
$sup=date('F j, Y g:i:s a',$r['signedup']);
$ts=$r['strength']+$r['agility']+$r['guard']+$r['labour']+$r['IQ'];
$d="";
if($r['laston'] > 0)
{
$la=time()-$r['laston'];
$unit="seconds";
if($la >= 60)
{
$la=(int) ($la/60);
$unit="minutes";
}
if($la >= 60)
{
$la=(int) ($la/60);
$unit="hours";
if($la >= 24)
{
$la=(int) ($la/24);
$unit="days";
}
}
$str="$la $unit ago";
}
else
{
  $str="--";
}
if($r['last_login'] > 0)
{
$ll=time()-$r['last_login'];
$unit2="seconds";
if($ll >= 60)
{
$ll=(int) ($ll/60);
$unit2="minutes";
}
if($ll >= 60)
{
$ll=(int) ($ll/60);
$unit2="hours";
if($ll >= 24)
{
$ll=(int) ($ll/24);
$unit2="days";
}
}
$str2="$ll $unit2 ago";
}
else
{
  $str2="--";
}

if($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>";$d="<img src='donator.gif' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; }
if($r['laston'] >= time()-15*60) { $on="<font color=green><b>Online</b></font>"; } else { $on="<font color=red><b>Offline</b></font>"; }
print "<h3>Profile for {$r['username']}</h3>
<table width=100% cellspacing=1 class='table'><tr style='background:gray'><th>General Info</th><th>Financial Info</th> <th>Display Pic</th></tr>
<tr><td>Name: {$r['username']} [{$r['userid']}] $d<br />
User Level: $userl<br />
Duties: {$r['duties']}<br />
Gender: {$r['gender']}<br />
Signed Up: $sup<br />
Last Active: $lon<br />
Last Action: $str<br />
Last Login: $str2<br />
Online: $on<br />
Days Old: {$r['daysold']}<br />
Location: {$r['cityname']}</td><td>
Money: £{$r['money']}<br />
Crystals: {$r['crystals']}<br />
";
if($r['married'] == 1)
{
$marryq=mysql_query("SELECT * FROM `marriages` WHERE (`marriage_from` = '$r[userid]') OR (`marriage_to` = '$r[userid]')",$c);
$mr=mysql_fetch_array($marryq);
if($mr['marriage_from'] == $userid) { $from=2; $themid=$mr['marriage_to']; } else { $from=1; $themid=$mr['marriage_from']; }
if($from == 1)
{
$uq=mysql_query("SELECT * FROM users WHERE userid='$mr[marriage_to]'",$c);
} else {
$uq=mysql_query("SELECT * FROM users WHERE userid='$mr[marriage_from]'",$c);
}
$marr=mysql_fetch_array($uq);
$married="<a href='viewuser.php?u=$themid'>".$marr['username']."</a>";
$marriagetxt=" (<a href='marriageinfo.php?ID=$themid'>Info</a>)";
} else {
$married="<font color=red>N/A</font>";
$marriagetxt="";
}
print "Married: $married$marriagetxt <br />
Married: ".number_format($r['married_times'])." times<br />

Property: {$r['hNAME']}<br />

Referals: ";
$rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}");
print $db->num_rows($rr);
print "<br />
Friends: {$r['friend_count']}<br />
Enemies: {$r['enemy_count']}
</td> <td>";
if($r['display_pic'])
{
print "<img src='{$r['display_pic']}' width='150' height='150' alt='User Display Pic' title='User Display Pic' />";
}
else
{
print "This user has no display pic!";
}
$sh=($ir['user_level'] >1) ? "Staff Info" : " ";
print "</td></tr>
<tr style='background:gray'><th>Physical Info</th><th>Links</th><th>$sh</th></tr>
<tr><td>Level: {$r['level']}<br />
Health: {$r['hp']}/{$r['maxhp']}<br />
Gang: ";
if($r['gang'])
{
print "<a href='gangs.php?action=view&ID={$r['gang']}'>{$r['gangNAME']}</a>";
}
else
{
print "N/A";
}
if($r['fedjail'])
{
print "<br /><b><font color=red>In federal jail for {$r['fed_days']} day(s).<br />
{$r['fed_reason']}</font>";
}
if($r['hospital'])
{
print "<br /><b><font color=red>In hospital for {$r['hospital']} minutes.<br />{$r['hospreason']}</font></b>";
}
if($r['jail'])
{
print "<br /><b><font color=red>In jail for {$r['jail']} minutes.<br />{$r['jail_reason']}</font></b>";
}

print "</td><td>[<a href='mailbox.php?action=compose&ID={$r['userid']}'>Send Mail</a>]<br /><br />
[<a href='sendcash.php?ID={$r['userid']}'>Send Cash</a>]<br /><br />";
if($set['sendcrys_on'])
{
print "[<a href='sendcrys.php?ID={$r['userid']}'>Send Crystals</a>]<br /><br />";
}
if($set['sendbank_on'])
{
if($ir['bankmoney'] >= 0 && $r['bankmoney'] >= 0)
{
print "[<a href='sendbank.php?ID={$r['userid']}'>Bank Xfer</a>]<br /><br />";
}
if($ir['cybermoney'] >= 0 && $r['cybermoney'] >= 0)
{
print "[<a href='sendcyber.php?ID={$r['userid']}'>CyberBank Xfer</a>]<br /><br />";
}
}
print "
[<a href='attack.php?ID={$r['userid']}'>Attack</a>]<br />";
$marq=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid=$userid AND it.itmtypename='$type'",$c)
if(mysql_num_rows($marq) and $ir['married'] == 0)
{
print "<br />
[<a href='propose.php?ID={$r['userid']}'>Propose</a>]<br />";
} 

[<a href='contactlist.php?action=add&ID={$r['userid']}'>Add Contact</a>]
if($ir['user_level'] == 2 || $ir['user_level'] == 3 || $ir['user_level'] == 5)
{
print "<br /><br />
[<a href='jailuser.php?userid={$r['userid']}'>Jail</a>]<br /><br />
[<a href='mailban.php?userid={$r['userid']}'>MailBan</a>]";
}
if($ir['donatordays'] > 0)
{
print "<br /><br />
[<a href='friendslist.php?action=add&ID={$r['userid']}'>Add Friends</a>]<br /><br />
[<a href='blacklist.php?action=add&ID={$r['userid']}'>Add Enemies</a>]<br />";
}
print "</td><td>";
if($ir['user_level'] == 2 || $ir['user_level'] == 3 || $ir['user_level'] == 5)
{
  $r['lastiph']=@gethostbyaddr($r['lastip']);
  $r['lastiph']=checkblank($r['lastiph']);
  $r['lastip_loginh']=@gethostbyaddr($r['lastip_login']);
  $r['lastip_loginh']=checkblank($r['lastip_loginh']);
  $r['lastip_signuph']=@gethostbyaddr($r['lastip_signup']);
  $r['lastip_signuph']=checkblank($r['lastip_signuph']);
print "<h3>Internet Info</h3><table width='100%' border='0' cellspacing='1' class='table'>
<tr><td></td><td class='h'>IP</td><td class='h'>Hostname</td></tr>
<tr><td class='h'>Last Hit</td><td>$r[lastip]</td><td>$r[lastiph]</td></tr>
<tr><td class='h'>Last Login</td><td>$r[lastip_login]</td><td>$r[lastip_loginh]</td></tr>
<tr><td class='h'>Signup</td><td>$r[lastip_signup]</td><td>$r[lastip_signuph]</td></tr></table>";
print "<form action='staffnotes.php' method='post'>
Staff Notes: <br />
<textarea rows=7 cols=40 name='staffnotes'>{$r['staffnotes']}</textarea>
<br /><input type='hidden' name='ID' value='{$_GET['u']}' />
<input type='submit' value='Change' /></form>";
}
else
{
print " ";
}
print "</tr></table>";
}
}
function checkblank($in)
{
  if(!$in) { return "N/A"; }
  return $in;
}
$h->endpage();
?>

Link to comment
https://forums.phpfreaks.com/topic/95622-php-errors/
Share on other sites

Hi all,

 

My environment is Windows vista, pp5,  Apache 2.2, Mysql 5. My problem is that R_ENABLED, RT_BIN and CT_BIN are empty even though I assign a path to them i.e nothing gets printed. What am I doing wrong

 

I have a file to test the config below and with the following variable defined in config.inc.php like this

 

define('GS_BIN', "C:\Program Files\gs\gs8.60\bin\gswin32c.exe");

 

//requires RT_BIN (rt binary) and CT_BIN (ct binary) to be enabled

define('R_ENABLED', true);

define('RT_BIN', "C:\projroot\rt.exe");

define('CT_BIN', "C:\projroot\ct.exe");

 

 

 

==========================================================================================

 

<html>

<head>

<title>Test Installation</title>

</head>

<body>

<?PHP

 

include("../config.inc.php");

 

 

if (R_ENABLED)

{

 

if (file_exists(CT_BIN)) {

print "<p>Found ct</p>";

} else {

echo "<p>Could not find ct in path: " . CT_BIN .  "</p><p>Please modify config.inc.php, CT_BIN to point to the ct executable or disable OCR by changing R_ENABLED to false</p>";

$fail = true;

}

 

if (file_exists(RT_BIN)) {

print "<p>Found RT</p>";

} else

{

echo "<p>Could not find RT in path: " . RT_BIN .  "</p><p>Please modify config.inc.php, RT_BIN to point to the rt executable or disable R by changing R_ENABLED to false</p>";

$fail = true;

}

}

 

if ($fail)

{

print "<h1>FAILED</h1>";

}

else

{

print "<h1>Passed Configuration Test</h1>";

}

 

 

?>

</body>

</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/95622-php-errors/#findComment-489599
Share on other sites

Sorry. It would have been helpful had I posted them.

 

The one I'm getting now is

 

Parse error: syntax error, unexpected T_IF in /home/viewuser.php on line 178

 

You did not close line 177

 

$marq=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid=$userid AND it.itmtypename='$type'",$c)

 

should be

 

$marq=mysql_query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid=$userid AND it.itmtypename='$type'",$c);

Link to comment
https://forums.phpfreaks.com/topic/95622-php-errors/#findComment-489619
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.