Jump to content
MakeWebGames

Recommended Posts

Posted

players can have same gang names by leaveing a space before the name can anyone help me fix this iv been trying to sort it but cant get around it

this is the function gang_staff_name from yourgang.php

function gang_staff_name()
{
global $db, $ir, $userid, $gangdata, $h, $leaders;
if(in_array($userid, $leaders))
{
if(isset($_POST['subm']))
{
$sql = sprintf("UPDATE gangs SET gangNAME = '%s' WHERE (gangID = %u)", clean($_POST['vp']), $gangdata['gangID']);
$db->query($sql);
echo "Gang name changed!

[url='yourgang.php?action=staff']> Back[/url]";
}
else
{
echo "Current Name: 
";
echo sprintf("%s
", format($gangdata['gangNAME']));
echo "
<form action='yourgang.php?action=staff&act2=name' method='post'>";
echo "<input type='hidden' name='subm' value='submit' />";
echo "<table class='table' width='75%'>";
echo "<tr>";
echo "<th>New name</th>";
echo sprintf("<td style='text-align:center;'><input type='text' name='vp' value='%s' size='40%%' /></td>", format($gangdata['gangNAME']));
echo "</tr>";
echo "<tr>";
echo "<td colspan='2' style='text-align:center;'><input type='submit' value='Change' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
}
}

 

and this is creategang.php and both of these have the same problem

<?php
include(DIRNAME(__FILE__) . '/globals.php');

function format($str)
{
if(is_numeric($str))
{
$str = number_format($str);
}
else
{
$str = nl2br($str);
$str = stripslashes($str);
}
return $str;
}

function clean($string)
{
$string = mysql_real_escape_string($string);
$string = htmlspecialchars($string);
return $string;
}

if($ir['money'] < 1000)
{
echo "You don't have enough money. You need \$1,000.";
$h->endpage();
exit;
}
if($ir['gang'])
{
echo "You're already in a gang!";
$h->endpage();
exit;
}
if(isset($_POST['name']))
{
$check=$db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE `gangNAME` = '%s'", clean($_POST['name'])));
if($db->num_rows($check))
{
print "ERROR.

[url='creategang.php']> Back[/url]";
$h->endpage();
exit;
}

$name = clean($_POST['name'] = trim($_POST['name']));
$desc = clean($_POST['desc']);
$sql = sprintf("INSERT INTO gangs (gangNAME, gangDESC, gangPREF, gangSUFF, gangMONEY, gangCRYSTALS, gangRESPECT, gangPRESIDENT, gangVICEPRES, gangCAPACITY) VALUES ('%s', '%s', '', '', 0, 0, 100, %u, %u, 5)", $name, $desc, $userid, $userid);
$db->query($sql);
$i = $db->insert_id();
$gang = sprintf("UPDATE users SET gang = %u, money = money - 1000 WHERE (userid = %u)", $i, $userid);
$db->query($gang);
echo "Gang created!";
}
else
{
echo "<h3>Create A Gang</h3>";
echo "<form action='creategang.php' method='post'>";
echo "<input type='hidden' name='submit' value='1' />";
echo "Name:<input type='text' name='name' />
";
echo "Description:
";
echo "<textarea name='desc' cols='40' rows='7'></textarea>";
echo "
<input type='submit' value='Create Gang for \$1,000' />";
echo "</form>";
}
$h->endpage();
?> 
Posted

Re: gang names problem

 

I will not do your work, but I will tell you to go to a site and what to look at

Site: php.net

Look for: trim, ltrim, rtrim

Simple stuff, you have the fishing equipment, now go teach yourself to fish.

thanks +1

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...