Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

Okay so first of all I'd like to say that errors aren't showing on my game,

I'm using V1 if that helps, I need them to display because ATM I have no idea what's wrong with this factions code:

<?php
session_start();
require "global_func.php";
if ($_SESSION['loggedin'] == 0)
{
   header("Location: login.php");
   exit;
}
$userid = $_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is = mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir = mysql_fetch_array($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->menuarea();
print "<font face='Arial' size='4'>Factions</font><hr width='90%'>";
switch ($_GET['step'])
{
case 'create':
create_faction();
break;

case 'profile':
faction_profile();
break;

case 'users':
faction_members();
break;

case 'search':
search_factions();
break;

case 'apply':
faction_apply();
break;

default:
factions_index();
break;
}
function factions_index()
{
global $ir,$c,$userid,$h;
$sql = sprintf("SELECT * FROM `factions` fa  LEFT JOIN `users` u ON (u.userid = fa.faLEADER) ORDER BY faID DESC");
$q = mysql_query($sql);
print "This is a list of all factions by ID
<table width='90%' cellspacing='1'><tr bgcolor='#AAAAAA'><th width='25%'>Name</th><th width='13%'>Members</th><th width='12%'>Reputation</th><th width='50%'>Image</th></tr>";
while($r = mysql_fetch_array($q))
{
print "<tr><td><a href='factions.php?step=profile&ID={$r['faID']}'><h3>{$r['faNAME']}</h3></a></td><td>";
$membs = sprintf("SELECT * FROM `users` WHERE faction = %u",
mysql_real_escape_string($r['faID']));
$mems  = mysql_query($membs);
print mysql_num_rows($mems)."</td>
<td>{$r['faREPUTATION']}</td>
<td>{$r['faIMAGE']}</td></tr>";
}
print "</table>
<hr width='90%'>> <a href='explore.php'>Back</a><hr width='90%'>";
}
function create_faction()
{
global $ir,$c,$userid,$h;
$sql = sprintf("SELECT * FROM `factions` WHERE faID > 0");
$q = mysql_query($sql);
$fcs = mysql_num_rows($q);
$r['faCOST'] = ($fcs*10000);
if($ir['money'] < $r['faCOST'])
{
print "
You don't have enough money. It costs ".money_formatter($r['faCOST'])." to create a new Faction.

<hr width='90%'>> <a href='explore.php' target='_blank'>Back</a><hr width='90%'>";
}
else if($ir['faction'] > 0)
{
print "
You are already part of a Faction. Leave before creating a new one.

<hr width='90%'>> <a href='explore.php' target='_blank'>Back</a><hr width='90%'>";
}
else if($_POST['name'] AND $_POST['description'] AND $_POST['status'])
{
$ins = sprintf("INSERT INTO `factions` (`faID`, `faNAME`, `faDESC`, `faSTATUS`, `faLEADER`, `faCOLEADER`, `faCAPACITY`, `faREPUTATION`) VALUES ('NULL','%s', '%s', '%s', '%d', '%d', '%d', '%d')",
mysql_real_escape_string($_POST['name']),
mysql_real_escape_string($_POST['description']),
mysql_real_escape_string($_POST['status']),
$userid,
$userid,
10,
100);
mysql_query($ins);
$r['insID'] = mysql_insert_id($c);
$fac = sprintf("UPDATE `users` SET faction = %d, money=money-%d WHERE (userid = %u)",
$r['insID'],
$r['faCOST'],
$userid);
mysql_query($fac);
print "
The {$_POST['name']} faction was successfully created.

<hr width='90%'>> <a href='factions.php?step=manage' target='_blank'>Back</a><hr width='90%'>";
}
else
{
print "
<form action='factions.php?step=create' method='post'>
A new faction will cost $10,000 times the amount of factions in existence.
The current price is <b>".money_formatter($r['faCOST'])."</b>.

Name your Faction

<input type='text' name='name' />


Choose a Status

<select type='dropdown' name='status'>
<option value='Peaceful'>Peaceful</option>
<option value='Aggressive'>Aggressive</option>
</select>


Description
<textarea name='description' cols='40' rows='7'></textarea>
<input type='submit' value='Create' /></form>
<hr width='90%'>> <a href='factions.php' target='_blank'>Back</a><hr width='90%'>";
}
}
function faction_profile()
{
global $ir,$c,$userid,$h;
$sql = sprintf("SELECT * FROM `factions` fa LEFT JOIN `users` u ON (u.userid = fa.faLEADER) WHERE (fa.faID = %u)",
mysql_real_escape_string($_GET['ID']));
$q = mysql_query($sql);
$r = mysql_fetch_array($q);
print "
<table width='400' bgcolor='#DFDFDF'><tr><td align='center'><b><font size='5'>{$r['faNAME']}</font></b></td></tr></table>

{$r['faDESC']}
<p>error here.</p>


<table width='400' bgcolor='#DFDFDF'><tr><td valign='middle' align='center'><font size='5'><b>{$r['faREPUTATION']}</b></font></td></tr></table>

<table width='400' bgcolor='#DFDFDF'><tr><td width='200' valign='middle'>
<b>Leader: </b><a href='viewuser.php?u={$r['userid']}>{$r['username']}</a>
";
$col = sprintf("SELECT * FROM `users` WHERE (userid = %u)",
mysql_real_escape_string($r['faCOLEADER']));
$q2 = mysql_query($col);
$co = mysql_fetch_array($q2);
print "<b>Co-Leader: </b><a href='viewuser.php?u={$co['userid']}'>{$co['username']}</a>
";
$membs = sprintf("SELECT * FROM `users` WHERE faction = %u",
mysql_real_escape_string($r['faID']));
$mems  = mysql_query($membs);
print "<b>Members: </b>'.mysql_num_rows($mems).'

<b>Reputation: </b>{$r['faREPUTATION']}

<b>Current chain: </b>{$r['faCHAIN']} attacks

<b>Best chain: </b>{$r['faBCHAIN']} attacks

<b>Status: </b>";
if ($r['faSTATUS'] == 'Peaceful')
{
print "<font color='green'><b>Peaceful</b></font>";
}
else
{
print "<font color='red'><b>Aggressive</b></font>";
}
print "
</td>
<td valign='top' align='right' width='200'><a href='factions.php?step=users&ID={$r['faID'}}>User list</a> <

<a href='factions.php?step=apply&ID={$r['faID']}'>Apply</a> <
</td></tr></table>

<table width='400' bgcolor='#DFDFDF'><tr>
<td width='50%' height='100%'>
<table width='100%' height='100%'><tr>
<td align='center'>
{$r['faDESC']}

</td>
</tr></table></td></tr></table>


<hr width='90%'>> <a href='factions.php'>Back</a><hr width='90%'>";
}
function faction_members()
{
global $ir,$c,$userid,$h;
$sql = sprintf("SELECT * FROM `factions` fa LEFT JOIN `users` u ON (u.faction = fa.faID) WHERE (fa.faID = %u)",
mysql_real_escape_string($_GET['ID']));
$q = mysql_query($sql);
print "<table width='90%' cellspacing='1'><tr bgcolor='#AAAAAA'><th width='25%'>Num</th><th width='25%'>Name</th><th width='25%'>Level</th><th width='25%'>Days in Faction</th></tr>";
while ($r = mysql_fetch_array($q))
{
$cn++;
print "<tr><td>$cn.</td><td><a href='viewuser.php?u={$r['userid']}>{$r['username']}</a></td><td>{$r['level']}</td><td>{$r['faction_days']}</td></tr>";
}
print "</table>


<hr width='90%'>> <a href='factions.php?step=profile&ID={$_GET['ID']}'>Back</a><hr width='90%'>";
}
function search_factions()
{
global $ir,$c,$userid,$h;
if (!$_POST['name'])
{
print "<form action='factions.php?step=search' method='post'>
<b>Search by Keyword</b>


Insert the keyword that you'd like to search for Factions:

<input type='text' name='name'>


<input type='submit' value='Search'></form>
<hr width='90%'>> <a href='factions.php'>Back</a><hr width='90%'>";
}
else
{
$sql = sprintf("SELECT * FROM `factions` fa  LEFT JOIN `users` u ON (u.userid = fa.faLEADER) WHERE (`faNAME` LIKE '%%%s%%')",
mysql_real_escape_string($_POST['name']));
$q = mysql_query($sql);
print "<b>Search by Keyword</b>


Keyword: {$_POST['name']}


<table width='90%' cellspacing='1'><tr bgcolor='#AAAAAA'><th width='25%'>Name</th><th width='13%'>Members</th><th width='12%'>Reputation</th><th width='50%'>Image</th></tr>";
while($r = mysql_fetch_array($q))
{
print "<tr><td><a href='factions.php?step=profile&ID={$r['faID']}><h3>{$r['faNAME']}</h3></a></td><td>";
$membs = sprintf("SELECT * FROM `users` WHERE faction = %u",
mysql_real_escape_string($r['faID']));
$mems  = mysql_query($membs);
print mysql_num_rows($mems)."</td>
<td>{$r['faREPUTATION']}</td>
<td>{$r['faNAME']} name</td></tr>";
}
print "</table>
<hr width='90%'>> <a href='factions.php?step=search'>Back</a><hr width='90%'>";
}
}
function faction_apply()
{
global $ir,$c,$userid,$h;
if ($ir['faction'])
{
print "
You are already in a faction at this time.


<hr width='90%'>> <a href='factions.php'>Back</a><hr width='90%'>";
}
else if (!$_GET['act'])
{
print "
Please type an application to this faction below:


<form action='factions.php?step=apply&act=submit&ID={$_G  ET['ID']}' method='post'>
<textarea type='text' name='app' cols='50' rows='8'>Type your application here</textarea>


<input type='submit' value='Submit'></form>


<hr width='90%'>> <a href='factions.php?step=profile&ID={$_GET['ID']}>Back</a><hr width='90%'>";
}
else if ($_GET['act'] == 'submit')
{
if ($_POST['app'])
{
$ins = sprintf("INSERT INTO `faction_apps` (`fpID`, `fpUSER`, `fpFACTION`, `fpAPP`, `fpTIME`) VALUES ('NULL','%d', '%d', '%s', '%d')",
mysql_real_escape_string($ir['userid']),
mysql_real_escape_string($_GET['ID']),
mysql_real_escape_string($_POST['app']),
time());
mysql_query($ins);
print "
Your application was submitted!


<hr width='90%'>> <a href='factions.php?step=profile&ID={$_GET['id']}'>Back</a><hr width='90%'>";
}
else
{
print "
You did not type an application to send!


<hr width='90%'>> <a href='factions.php?step=apply&ID={$_GET['ID']}'>Back</a><hr width='90%'>";
}
}
}
$h->endpage();
?>
Edited by bloodless2010
Posted
PHP Parse error: syntax error, unexpected '}', expecting ']' in test.php on line 186

Parse error: syntax error, unexpected '}', expecting ']' in test.php on line 186

 

PHP Parse error: syntax error, unexpected 'ET' (T_STRING), expecting '}' in test.php on line 280

Parse error: syntax error, unexpected 'ET' (T_STRING), expecting '}' in test.php on line 280

Pretty obvious I'd say.

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...