Jump to content

Phpfr3ak

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Everything posted by Phpfr3ak

  1. Yea, if there $playerID is in bank_accounts as PlayersID, i dont want them to display in the dropdown.
  2. Could anyone point me in the correct direction of how to go about excluding results from a drown down menu, Basically i'm calling everyone who's a contact to the user in the code below, id like to remove contacts who already have a bank account with the user, So basically its something along the lines of if the player_id is already in the table bank_accounts as PlayersID, then its excluded, Hope this makes sense and any help would be great, Thanks <select name="contact1" class="maintablepstats" id="contact1"> <option value=""></option> <?php $sql = "SELECT player_id, contact_id, name, is_active FROM contacts as c JOIN players as p ON c.contact_id = p.id WHERE c.player_id = $playerID AND is_active = 1 ORDER BY name ASC"; $que = mysql_query($sql) or die(mysql_error()); while($list = mysql_fetch_array($que)) { ?> <option value="<?php echo $list['contact_id'] ?>"><?php echo $list['name'] ?></option> <?php } ?> </select>
  3. scratch that worked it out, sorry
  4. Hey, having an odd issue, looking to show players whos within 25 ranks of them lower and higher, i'm unsure as to why the following code doesn't actually do it... would anyone care to explain... <?php $score = $playerdata['score']; $sql = "SELECT * FROM `players` WHERE '$score' BETWEEN 25 AND 75 ORDER BY `score` DESC"; $query = mysql_query($sql) or die(mysql_error()); $i=0; while($players = mysql_fetch_array($query)) { $i++; ?>
  5. Grow Completed. 1 1 Thats echoing $num1 and $num2 so in theory it should work?? <?php include("server.php"); $sql = "SELECT * FROM players"; $que = mysql_query($sql); while($res=mysql_fetch_array($que)) { $sql2 = "SELECT * FROM player_inventory WHERE item_id = '17' AND player_id = '$res[id]'"; $que2 = mysql_query($sql2) or die(mysql_error()); $res2 = mysql_fetch_array($que2); $num = mysql_num_rows($que2); $Weight = 8 / 100 * (100 + $res['ProductionWeight']) * $res2['quantity']; $Quality = 75 / 100 * (100 + $res['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; $sql3 = "SELECT * FROM drug_inventory WHERE quality = '$Quality' AND player_id = '$res2[player_id]'"; $que3 = mysql_query($sql3) or die(mysql_error()); $res3 = mysql_fetch_array($que3); $num2 = mysql_num_rows($que3); if($num >= 1){ if($num2 == 0){ $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res[id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; }else{ if($num2 >= 1){ $sql = "UPDATE drug_inventory SET weight = weight + '$Weight' WHERE quality = '$Quality' AND player_id = '$res[id]'"; mysql_query($sql) or die(mysql_error());; echo "Grow Completed. $num $num2"; } } } } ?>
  6. Its not failing per say, its really odd, its updating one player, and then just inserting a new entry for the others, it kind of has to be working somehow to initially update that 1 player, no?
  7. Sorry really bad habbit i guess, just found it stopped the headers already set stuff to just code it outright on lines.
  8. Rightio, i fixed that error, only issue is it now only updates 1 player not all the players if the row already exists for said player, im really just plain lost as to why, below is the new code, any help would really be appreciated guys <?php include("server.php"); $sql = "SELECT * FROM players"; $que = mysql_query($sql); while($res=mysql_fetch_array($que)) { $sql2 = "SELECT * FROM player_inventory WHERE item_id = '17' AND player_id = '$res[id]'"; $que2 = mysql_query($sql2) or die(mysql_error()); $res2 = mysql_fetch_array($que2); $num = mysql_num_rows($que2); $Weight = 8 / 100 * (100 + $res['ProductionWeight']) * $res2['quantity']; $Quality = 75 / 100 * (100 + $res['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; $sql3 = "SELECT * FROM drug_inventory WHERE player_id = '$res[id]' AND quality = '$Quality'"; $que3 = mysql_query($sql3) or die(mysql_error()); $res3 = mysql_fetch_array($que3); $num2 = mysql_num_rows($que3); if($num >= 1 && $num2 >= 1){ $sql = "UPDATE drug_inventory SET weight = weight + '$Weight' WHERE quality = '$Quality' AND player_id = '$res[id]'"; mysql_query($sql) or die(mysql_error());; }else{ if($num >= 1 && $num2 == 0){ $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res[id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; echo "Grow Completed."; } } } ?>
  9. Just put together my cronjob, was working fine but wanted it to just update a row if it existed already with the same quality value instead of inserting a whole new row, for some reason i'm getting a; Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.3\www\public_html\crons\GrowCron.php on line 17 Error, Line 17 is $sql3 = "SELECT * FROM player_inventory WHERE player_id = '$res2[id]' AND quality = '$Quality'"; $num2 = mysql_num_rows(mysql_query($sql3)); if($num2 == 0){ Any clues? <?php include("server.php"); $sql2 = "SELECT * FROM players"; $que2 = mysql_query($sql2); while($res2=mysql_fetch_array($que2)) { $sql = "SELECT * FROM player_inventory WHERE item_id = 17 AND player_id = $res2[id]"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $num = mysql_num_rows($que); $Weight = 8 / 100 * (100 + $res2['ProductionWeight']) * $res['quantity']; $Quality = 75 / 100 * (100 + $res2['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; if($num >= 1){ $update = "UPDATE players SET StreetCred = StreetCred + $StreetCred"; mysql_query($update) or die(mysql_error());; $sql3 = "SELECT * FROM player_inventory WHERE player_id = '$res2[id]' AND quality = '$Quality'"; $num2 = mysql_num_rows(mysql_query($sql3)); if($num2 == 0){ $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res2[id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; }else{ //row exists, update it. $sql5 = "UPDATE drug_inventory SET weight = $weight WHERE player_id = '$res2[id]' AND quality = '$Quality'"; mysql_query($sql5) or die(mysql_error());; echo "Grow Completed."; } } } ?>
  10. Nevermind worked it out yet again, sorry for wasting your time
  11. Worked that part out, only query i have now is how do i make it only effect people with item 17 purchased, what i have now; <?php include("server.php"); $sql = "SELECT * FROM player_inventory WHERE item_id = 17"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $sql2 = "SELECT * FROM players"; $que2 = mysql_query($sql2); while($res2=mysql_fetch_array($que2)) { $Weight = 8 / 100 * (100 + $res2['ProductionWeight']); $Quality = 75 / 100 * (100 + $res2['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; $update = "UPDATE players SET StreetCred = StreetCred + $StreetCred"; mysql_query($update) or die(mysql_error());; $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res2[id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; echo "Grow Completed."; } ?>
  12. Don't have a huge deal of experience with this side of things, well php as a whole really but really struggle with this side, ive coded up a cron but it only works for 1 user, unsure as to why, i want it to do the action for every player that has item 17, the codes below any help would be appreciated, Thanks guys <?php include("server.php"); $sql = "SELECT * FROM player_inventory WHERE item_id = 17"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $sql2 = "SELECT * FROM players WHERE id = $res[player_id]"; $que2 = mysql_query($sql2); while($res2=mysql_fetch_array($que2)) { $Weight = 8 / 100 * (100 + $res2['ProductionWeight']); $Quality = 75 / 100 * (100 + $res2['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; $update = "UPDATE players SET StreetCred = StreetCred + $StreetCred WHERE id = $res[player_id]"; mysql_query($update) or die(mysql_error());; $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res[player_id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; echo "Grow Completed."; } ?>
  13. Wow, that fixed it never seen that issue before, Thanks going to stop using the lazy method now for sure.
  14. Odd I'm getting You can now use the invite option under the CREWS menu to invite other players to join you."; ?> Echo'd when ?Show=Created isn't even being used, also never seen an end php tag being echod before, testing this on easyphp could be why maybe?
  15. Pretty simple, when a crews created it will divert to this page with the url extension ?Show=Created surely the following code should do this? <? if($_GET['Show']=="Created") echo "Crew created successfully!<br> You can now use the invite option under the CREWS menu to invite other players to join you."; ?>
  16. Fixed cheers guys, both of the solutions helped a great deal
  17. All the variables are set for sure, anyone have any clue why the following isnt inserting anything into the db? //### Query to insert new item into the database table "items" $query = "INSERT INTO `items`(`name`,`image`,`description`,`description2`,`description3`,`ItemType`,`cash_price `,`credit_price `,`GrowAmount`,`SellAmount`,`MaxOff`,`MaxDef`,`MaxHoes`,`Attack`,`Defense`,`Prestige`,`SafeLimit`,`ProductionQuality`,`ProductionWeight`,`HoDrugUsage`,`HoIncome`,`PurchaseDiscount`,`Informants`,`Pimpness`,`SalesPrice`,`SalesWeight`,`TroopDiscount`,`NotoReq`,`SCReq`,`PRReq`,`Buyable`,`ClassSpecific`,`Sellable`,`Multiple`) VALUES('{$name}','{$image}','{$description}','{$description2}','{$description3}','{$ItemType}','{$price}','{$creditprice}','{$GrowAmount}','{$SellAmount}','{$MaxOff}','{$MaxDef}','{$MaxHoes}','{$Attack}','{$Defense}','{$Prestige}','{$SafeLimit}','{$ProductionQuality}','{$ProductionWeight}','{$HoDrugUsage}','{$HoIncome}','{$PurchaseDiscount}','{$Informants}','{$Pimpness}','{$SalesPrice}','{$TroopDiscount}','{$NotoReq}','{$SCReq}','{$PRReq}','{$Buyable}','{$ClassSpecific}','{$Sellable}','{$Multiple}'"; //### Execute the above query mysql_query($query);
  18. Thanks guys, worked a treat, javascript wasn't a route i wanted to go down for validation, far to easy to exploit and bypass it, cheers.
  19. This works but the tags right at the end just annoys me and knowing its there and not correct and all, unsure as to where they should go without it throwing error msgs up <?php if($playerdata['is_admin'] == 1){ $result = mysql_fetch_array($query); if($_POST){ $price = mysql_real_escape_string($_POST['price']); $creditprice = mysql_real_escape_string($_POST['creditprice']); $ItemType = mysql_real_escape_string(isset($_POST['ItemType'])); $description = mysql_real_escape_string($_POST['description']); $image = mysql_real_escape_string($_POST['image']); $name = mysql_real_escape_string($_POST['name']); if($name == ""){ echo "You must enter an item name.<br><br>"; }else{ if($description == ""){ echo "You must enter a description for this item.<br><br>"; }else{ if($description2 == ""){ echo "You must enter a Character Req for this item.<br><br>"; }else{ if($description3 == ""){ echo "You must enter a What item does for this item.<br><br>"; }else{ if($ItemType == ""){ echo "You must select a item type.<br><br>"; }else{ if($price == ""){ echo "You must select a price for this item.<br><br>"; }else{ if($creditprice == ""){ echo "You must select a game credit price.<br><br>"; }else{ $sql = "INSERT INTO items(name,image,description,ItemType) VALUES ('$name', $image', '$description', '$ItemType')"; mysql_query($sql); echo "You have created $name<br /><br />"; } } } } } } } } ?>
  20. How do i go about the tags in this, with the elseifs really lost in the past ive done it different and included exits and such but i want it to display at the top of the page and not go onto a whole new page to say the error, sorry if im making little sense just kinda baffled <?php if($playerdata['is_admin'] == 1){ $result = mysql_fetch_array($query); if($_POST){ $price = mysql_real_escape_string($_POST['price']); $creditprice = mysql_real_escape_string($_POST['creditprice']); $ItemType = mysql_real_escape_string(isset($_POST['ItemType'])); $description = mysql_real_escape_string($_POST['description']); $image = mysql_real_escape_string($_POST['image']); $name = mysql_real_escape_string($_POST['name']); if($name == ""){ echo "You must enter an item name.<br><br>"; elseif ($description == ""){ echo "You must enter a description for this item.<br><br>"; elseif ($description2 == ""){ echo "You must enter a Character Req for this item.<br><br>"; elseif ($description3 == ""){ echo "You must enter a What item does for this item.<br><br>"; elseif ($ItemType == ""){ echo "You must select a item type.<br><br>"; elseif ($price == ""){ echo "You must select a price for this item.<br><br>"; elseif ($creditprice == ""){ echo "You must select a game credit price.<br><br>"; }else{ $sql = "INSERT INTO items(name,image,description,ItemType) VALUES ('$name', $image', '$description', '$ItemType')"; mysql_query($sql); echo "You have created $name<br /><br />"; ?>
  21. Thanks, went with the first option as wanted to remove the url with it, so you cannot click a banned players name, helped a bunch and fixed, Thanks guys.
  22. Getting an unexpected end error on this and unsure as to why. <?php if($players['is_banned'] == 1) { ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> (BANNED) <? }else{ ?> <a href="profile.php?id=<?php echo $players['id'] ?>"><?php echo $players['name'] ?> <? } ?>
  23. Cheers, it worked! very much appreciate the help guys
  24. That looks good but getting an odd error message from it being; Notice: Undefined variable: delete_ids in C:\Program Files\EasyPHP-5.3.3\www\public_html\inbox.php on line 13 Warning: array_filter() expects parameter 1 to be array, null given in C:\Program Files\EasyPHP-5.3.3\www\public_html\inbox.php on line 13 Invalid ID data passed. line 13 is; //Remove any 'false' value $deleteIDs_ary = array_filter($delete_ids); sorry i'm really new to the whole loop, checkbox thing
  25. Ahh sorry, yea, wasnt aware that * used alot more resources, will take that on board for future reference for sure, and yea i want it to not allow messages to be deleted that don't belong to that user, its a player message system.
×
×
  • 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.