Jump to content
MakeWebGames

Recommended Posts

Posted

So I want it to make it so when I credit a user, it will send an event saying they have been credited.

Under

$db->query("UPDATE users u SET money=money+{$_POST['money']}, crystals=crystals+{$_POST['crystals']} WHERE u.userid={$_POST['user']}");
print "User credited.";

 

I add:

 

event_add("You were given ${$_POST['money']} and/or {$_POST['crystals']} crystals from the administration. If you would like to know why you were given this, mail GurpZ ID1.",$c);

 

Then I get that error with manual thing. The user still gets the money/crystals but no event, and the admin who credits them gets an error.

Posted

Re: Adding an event_add

 

$do = mysql_query("UPDATE users SET money = money + '%u', crystals = crystals + '%u' WHERE userid = '%u' ",
   ($_POST['money']),
   ($_POST['crystals']),
   ($_POST['user']));
       mysql_query($do);

event_add($_POST['user'],"You just got credited \$".number_format($_POST['money'])." and/or ".number_format($_POST['crystals'])." from [url='viewuser.php?u=".$ir[']".$ir['username']."[/url]");

 

That should do it. Just for future...Instead of asking something like this. Just look at other files. They Will show you something this easy. You will get it solved ALOT faster if you just try.

  • 8 months later...
Posted

I like this idea.

I have added it to my test game to see the errors are.

I get this message after crediting user :

Warning: mysql_query() expects at most 2 parameters, 4 given in xampp\htdocs\Test\staff_users.php on line 356

 

Here's the part giving the error :

 

$do = mysql_query("UPDATE users SET money = money + '%u', crystals = crystals + '%u' WHERE userid = '%u' ",

($_POST['money']),

($_POST['crystals']),

($_POST['user']));

 

I think the error is in the Update Users bit it does not seem right.

Can someone explain what this means, I have not seen this message before.

 

 

 

Posted

you lack the sprintf within the mysql_query function, that's why. Should be something like:

 

$do = mysql_query(sprintf("UPDATE users SET money = money + '%u', crystals = crystals + '%u' WHERE userid = '%u' ",
($_POST['money']),
($_POST['crystals']),
($_POST['user'])));
Posted

Yup, I never noticed I missed that on the post i did before. lol. litle update though

 

$do = mysql_query(sprintf("UPDATE users SET money = money + %u, crystals = crystals + %u WHERE userid = %u",abs(@intval($_POST['money'])),abs(@intval($_POST['crystals'])),abs(@intval($_POST['user'])));

 

Just added to how i used to do it, thought it might help some people.

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