Jump to content

[SOLVED] what am i doing wrong here?


mike3800

Recommended Posts

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masspayment'>Mass Payment</a>";}

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masscpayment'>Mass Crystal Payment</a>";}

 

im sure you can see i am attempting to make an otion for a mass cash and mass crystal payout in a game

 

the mass cash payout was in the game and functional. when i added the crystal code, the link for the mass cash payment disappeared. i think my problem is in the code above, but im very new at this and not too sure what to do.

 

the mass crystal payout works fine

Link to comment
Share on other sites

i think the forum added that

 

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masspayment'>Mass Payment</a>";}

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masscpayment'>Mass Crystal Payment</a>";}

 

 

yeah, the forum changed it. i just checked and recopied and pasted and after i submitted, it made it /url

Link to comment
Share on other sites

It is becuase basically you are checking the same thing twice:

 

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masspayment'>Mass Payment</a>";}
if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masscpayment'>Mass Crystal Payment</a>";}

 

you are checking against $gp['gp_pay'] twice, so first it is setting it to the mass payment link, then (since it is still true) it is setting it to the mass crystal payment, you either need to make two different variables in the (I assume youa re using an array) one for each mass pay and mass crystal, or append the mass crystal to the mass payment.

Link to comment
Share on other sites

:-X How did i not spot that... it was either the 5am time here making me think it was echoing..

 

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masspayment'>Mass Payment</a>";}
if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masscpayment'>Mass Crystal Payment</a>";}

 

change the 2nd $gp_pay to $gp_payc (or whatever) the find where $gp_pay is being used and repeat for $gp_payc,

 

(credit to HaLo2FrEeEk )

Link to comment
Share on other sites

Try not to triple post.

 

Don't forget that if you set it to a different variable you need to echo both variables, so if you use $gp_payc and $gp_pay, you need to echo both $gp_payc and $gp_pay.

 

sorry about the posts. this is frustrating me a little. lol

 

if ($gp['gp_pay']) {$gp_pay="<a href='yourgang.php?action=staff&act2=masspayment'>Mass Payment</a>";}

if ($gp['gp_payc']) {$gp_payc="<a href='yourgang.php?action=staff&act2=masscpayment'>Mass Crystal Payment</a>";}

 

thats what it looks like now. is there somewhere else i need to change gp_pay to gp_payc? i cant find anywhere else

Link to comment
Share on other sites

i dont know. lol. im really new at this and just trying to understand what im doing wrong

 

case "masspayment";
gang_staff_masspayment();
break;

function gang_staff_masspayment()
{
global $ir,$c,$userid,$gangdata,$gp;
if (!$gp['gp_pay'])
  {
  print "You do not have access to this function!<br /><br />
  <a href='yourgang.php'>Back</a>";
  die ();
  }
$_POST['amnt']=abs((int) $_POST['amnt']);
if($_POST['amnt'])
{
$q=mysql_query("SELECT * FROM users WHERE gang={$ir['gang']}",$c);
while($r=mysql_fetch_array($q))
{
if($gangdata['gangMONEY'] >= $_POST['amnt'])
{
event_add($r['userid'],"You were given \${$_POST['amnt']} from your gang.",$c);
mysql_query("UPDATE users SET money=money+{$_POST['amnt']} WHERE userid={$r['userid']}", $c);
$gangdata['gangMONEY']-=$_POST['amnt'];
print "Money sent to {$r['username']}.<br />";
}
else
{
print "Not enough in the vault to pay {$r['username']}!<br />";
}
}
mysql_query("UPDATE gangs SET gangMONEY={$gangdata['gangMONEY']} WHERE gangID={$ir['gang']}", $c);
mysql_query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(), 'A mass payment of \${$_POST['amnt']} was sent to the members of the Family.')",$c);
print "Mass payment sending complete!<br />
<a href='yourgang.php'>> Back</a>";
}
else
{
print "<b>Mass Payment</b><br />
<form action='yourgang.php?action=staff&act2=masspayment' method='post'> Amount: <input type='text' name='amnt' />
<input type='submit' value='Send' /></form>";
}
}

 

case "masscpayment";
gang_staff_masscpayment();
break;

function gang_staff_masscpayment()
{
global $ir,$c,$userid,$gangdata;
if (!$gp['gp_payc'])
  {
  print "You do not have access to this function!<br /><br />
  <a href='yourgang.php'>Back</a>";
  die ();
  }


$_POST['amnt']=abs((int) $_POST['amnt']);
if($_POST['amnt'])
{
$q=mysql_query("SELECT * FROM users WHERE gang={$ir['gang']}",$c);
while($r=mysql_fetch_array($q))
{
if($gangdata['gangCRYSTALS'] >= $_POST['amnt'])
{
event_add($r['userid'],"You were given {$_POST['amnt']}crystals from your gang.",$c,'gang');
mysql_query("UPDATE users SET crystals=crystals+{$_POST['amnt']} WHERE userid={$r['userid']}", $c);
$gangdata['gangCRYSTALS']-=$_POST['amnt'];
print "crystals sent to {$r['username']}.<br />";
}
else
{
print "Not enough in the vault to pay {$r['username']}!<br />";
}
}
mysql_query("UPDATE gangs SET gangCRYSTALS={$gangdata['gangCRYSTALS']} WHERE gangID={$ir['gang']}", $c);
mysql_query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(), 'A mass payment of {$_POST['amnt']} crystals was sent to the members of the Gang.')",$c);
print "Mass crystal payment sending complete!<br />
<a href='yourgang.php?action=staff'>> Back</a>";
}
else
{
print "<h3>Mass Crystal Payment</h3>
How many crystals do you want to give to each member?<br />
There are currently {$gangdata['gangCRYSTALS']} in the gang.<br /><br />
<form action='yourgang.php?action=staff&act2=masscpayment' method='post'> Amount:<br /> <input type='text' name='amnt' />
<input type='submit' value='Send' /></form>";
}
}

 

 

those are the code for the mass cash payment and mass crystal payment

Link to comment
Share on other sites

I didn't read the code, but $gp[gp_pay] is an array, the array's name is $gp, it this array does not exist, calling it up will do nothing, you need to create an associative array (thats what this is) with the values (at least) gp_pay and gp_payc.  When a variable is called up in php, if it exists, the value in it is used, if it does not exist, it is created then the value returned, often times, it is created empty or null.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

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.