Quote:
Originally Posted by Ashkwil
Ok well i want this script to add a certain member VIP privaleges.
Heres what i coded.
Code:
if ($view == "vipmem") {
echo "<BR><BR><B>Make A Member V.I.P:<form action=admin.php?step=vipadd method=post>";
echo "Id: <input size=5 type=text name=who><input type=submit value=Submit!></form></B><br>";
}
if ($step == "vipadd") {
$vip = mysql_query("select * from players where id=$who");
$vips = mysql_fetch_array($vip);
mysql_query("UPDATE players SET `credits`='credits+500000' `platinum`='platinum+200' `vip`='Y' WHERE `id`='$who'");
Print "You made is $who VIP!";
} else {
Print "VIP Adding Failed";
include"footer.php";
exit;
}
It doesnt add any credits ro platinum to the player AND it constantly shows VIP adding failed at the bottom of the page no matter which admin option im on.
Thanks i advance
Ash~
|
Ok... I am guessing here, because I don't completely understand your code... so here goes.
The first problem I see is you are using the method=Post using a form but are using the GET syntax (i.e. admin.php?step=vipadd ) So when you declare the variable $step how does the program know if you want the POST or GET global of 'step'.
First off... get rid of the form.. you don't need it. Just create a hyperlink to admin.php?step=vipadd . In the script, Declare the variable as $step=$_GET['step'] and you will get into the proper segment of your code to add information to your database.
Next, you query your database and then put that record into an array using
Code:
$vips = mysql_fetch_array($vip);
Now you must reference the elements of that array when you make your new query to update the database. (i.e. vips[0] is the reference for the first element in the array -- let's say this field refers to credits, vips[1] -- the second element let say is platinum)
Code:
mysql_query("UPDATE players SET `credits`='credits+500000' `platinum`='platinum+200' `vip`='Y' WHERE `id`='$who'");
will not work because the script does not know what the credit,plantinum variable are.. you must do the math outside of the query like this
Code:
$newcredit = vips[0] + 500000;
$newplat = vips[1] + 200;
//now do the query
mysql_query("UPDATE players SET `credits`=$newcredit `platinum`= $newplat `vip`='Y' WHERE `id`=$who");
Give that a try....
__________________
Please login or register to view this content. Registration is FREE - step-by-step learn how to design, create and install your own website in hours...not days. Please login or register to view this content. Registration is FREEwas never so easy.
Last edited by memberpro; 02-20-2007 at 07:38 PM..
|