Jump to content

Phpfr3ak

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Phpfr3ak's Achievements

Member

Member (2/5)

0

Reputation

  1. Sorry basically its something along the lines of, Player A buys x amount from player B, the cron runs every :10 on the hour, and essentially sells that resource, resourses have different values, for example at :10 player A sells 100 resourses, 50 of those resources would be in 1 row, and 50 in another, if that makes sense it can vary, hope that explains it somewhat better?
  2. Sorry maybe the wrong section, looking for a tutorial or something along those lines if anybody knows where i can find one, just to loop until a certain value is met from a column, any help would be great cheers.
  3. also tried: $addIDs_ary = array_filter($addIDs_ary); foreach ($result as $hit_id) { $req = "SELECT * FROM hitlist WHERE hit_id ='$addIDs_ary' and player_id = '$playerID'"; $result = mysql_query($req) or die ('Error :'.mysql_error()); if (mysql_num_rows($result)){ $str = ""; } else For some odd reason that just loops the whole results about 500x :/ (4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.(4,17),(5,17)2 of 2 Investigated player(s) were successfully Removed.
  4. Example of the page, 3 boxes ticker, the id's vary (the first number is $addIDs_ary, the second $playerID) (2,17),(3,17),(4,17)3 of 3 Investigated player(s) were successfully added. before inserting them into the database, id like to check each $addIDs_ary to see if its already in the database, $addIDs_ary is stored under hit_id in hitlist, if it already exists id like to set $str = ""; if it doesnt exist it will go to else and continue with the other validation, best i can explain it really, unsure if that will fill you in more or not? worth a try anyhow
  5. Sorry basically for a page with checkboxes, where you can "investigate" multiple people on the page, all that works fine, id just like to throw it in so you cannot "investigate" the same person twice, the said code is supposed to loop and check if each id, in this case the variable for the id's is $addIDs_ary is already present under the hit_id column in the table hitlist. error wise i'm getting Warning: mysql_query() expects parameter 1 to be string, resource given in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 21 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 22 which would be the lines $result = mysql_query($query); while ($result = mysql_fetch_assoc($result)) sorry for the terrible explanation hope this clears it up a bit more? as i say im terrible with loops and such so it is potentially wrong, id just like to confirm, and if its incorrect know what im doing wrong, Thanks
  6. Does anybody know how to make the following code correct? real sorry but its just absolutely blowing my mind im awful with loops and have pretty much no clue what the hell im doing in honesty, any help would be great, Thanks $addIDs_ary = array_map('intval', $_POST['chkInv']); $addIDs_ary = array_filter($addIDs_ary); $value = $addIDs_ary; //Check if hit_id is already in hitlist $query = mysql_query("SELECT * FROM hitlist WHERE player_id = '$playerID'"); $result = mysql_query($query); while ($result = mysql_fetch_assoc($result)) foreach ($result as $hit_id => $value){ if($result[$hit_id] == $value); $str = ""; } } else
  7. I dont know what im looking for is the honest truth, i just want to look it to see if $addIDs_ary is already set as hit_id in the table hitlist where the players_id = $playersID,, i get how to do it normally buy doing it for multiple results just baffles my mind
  8. Getting the following error Parse error: syntax error, unexpected T_AS in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 22, really unsure as to why any insight please? Thanks $sql = "SELECT * FROM hitlist WHERE player_id = '$playerID'"; $que = mysql_query($sql) or die(mysql_error()); if (is_array($que['hit_id'] as $hits) { foreach ($que['hit_id'] as $hits) { //do somthing } } else
  9. Went with the following and still got an error, Warning: Invalid argument supplied for foreach() in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 23, sorry not meaning to be a pain this is just blowing my mind. $sql = "SELECT * FROM hitlist WHERE player_id = '$playerID'"; $que = mysql_query($sql) or die(mysql_error()); $hitid = $que['hit_id']; foreach($hitid as $hits) if ($addIDs_ary == '$hits'){ } else
  10. Sorry really bad with this type of stuff, tried the following and got Parse error: syntax error, unexpected T_FOREACH in C:\Program Files\EasyPHP-5.3.3\www\public_html\PlayerRanks.php on line 20, exactly how am i going about that wrong, Thanks $sql = foreach"SELECT * FROM hitlist WHERE player_id = '$playerID' AND hit_id = '$addIDs_ary'"; $que = mysql_query($sql) or die(mysql_error()); if ($que['hit_id'] == '$addIDs_ary'){ $str = ""; } else
  11. Yea i moved it up one and it worked, maybe a silly question but do you have any clue how you can see if $addIDs_ary is already in the table hitlists under the column hit_id? Unsure as of how to check this in a loop, Thanks. if (isset($_POST["submit"]) && $_POST["submit"] == "Investigate Players") { //Force POST values to be INTs $addIDs_ary = array_map('intval', $_POST['chkInv']); //Remove any 'false' value $addIDs_ary = array_filter($addIDs_ary); //Check that there was at least one valid value if ($playerdata['Informants'] <= count($addIDs_ary)){ $attempt = count($addIDs_ary); echo "You are trying to investigate $attempt player(s) and only have $playerdata[informants] Informants available"; } else if(count($addIDs_ary) > 0) { $str = ""; foreach($addIDs_ary as $val) if(end($addIDs_ary) == $val) { $str .= "({$val},{$playerID})"; } else { $str .= "({$val},{$playerID}),"; if(end($addIDs_ary) == $val) { $str .= "({$val},{$playerID})"; } } echo $str; // (val,val), (val,val), (val,val) etc.. $query = "INSERT INTO hitlist (hit_id,player_id) values $str";
  12. Basically the following code works fine, exepct when it comes to the last result it inserts it twice, example: (3,17),(4,17),(5,17),(5,17) Any clues as to why? Thanks if(count($addIDs_ary) > 0) { $str = ""; foreach($addIDs_ary as $val) { $str .= "({$val},{$playerID}),"; if(end($addIDs_ary) == $val) { $str .= "({$val},{$playerID})"; } } echo $str; // (val,val), (val,val), (val,val) etc.. $query = "INSERT INTO hitlist (hit_id,player_id) values $str";
  13. Ahh sorry i guess i'm unsure as to how to go about an insert the code bwlow this deletes multiple results, id just like to add them instead: $query = "DELETE FROM hitlist WHERE hit_id IN ($deleteIDs_str) AND player_id = '$playerID'"; if(mysql_query($query)) Any clue how i could make that an insert? as when ive tried something along the lines of: $query = "INSERT INTO hitlist SET hit_id = IN ($deleteIDs_str) AND player_id = '$playerID'"; if(mysql_query($query)) I've error'd out any help would be great thanks
  14. Playerid is set in the header file, it works fine, and no, i mean its not inserting multiple people (its meant to its a checkbox multi adder)
  15. Hey, Basically the script runs fine except for the fact its just inserting one user instead of multiple users, anyone have a clue as to why? would be a huge hand, Cheers <?php if (isset($_POST["submit"]) && $_POST["submit"] == "Recall Selected Informants") { //Force POST values to be INTs $addIDs_ary = array_map('intval', $_POST['chkInv']); //Remove any 'false' value $addIDs_ary = array_filter($addIDs_ary); //Check that there was at least one valid value if(count($addIDs_ary)) { //Create comma separated string of the IDs $addIDs_str = implode(',', $addIDs_ary); //Create and run one query to perform all the adds (of the user) $query = "INSERT INTO hitlist SET hit_id = '($addIDs_str)' AND player_id = '$playerID'"; $sql = "UPDATE players SET Informants = Informants - 1 WHERE id = '$playerID'"; mysql_query($sql) or die(mysql_error()); if(mysql_query($query)) { $selectedCount = count($addIDs_ary); $adddCount = mysql_affected_rows(); echo "{$adddCount} of {$selectedCount} Investigated player(s) were successfully added."; }else{ echo "There was a problem running the query.<br>" . mysql_error(); } }else{ echo "Invalid ID data passed."; } }
×
×
  • 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.