Jump to content

Vettel

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vettel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is what you need to do: <input type="hidden" name="user" value="<?php echo $user; ?>" />
  2. khile could you post your entire code please?
  3. I'm pretty sure that there should be nothing wrong with this: mysql_query("INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL, 'admin', '1', {$_POST['YanViau']}, {$_POST['YanViau2']}, {$_POST['YanViau3']})") or die(mysql_error());
  4. Try this: require FORUM_ROOT.'footer.php'; if($action == 'delete_avatar'){ if($forum_user['id'] != $id && $forum_user['g_id'] > USER_MOD){ xBB_Message($lang_common['No permission']); xBB_Confirm_Referrer('profile.php'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.jpg'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.png'); @unlink($configuration['o_avatars_dir'].'/'.$id.'.gif'); $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or xBB_Error('Unable to update avatar state', __FILE__, __LINE__, $db->error()); xBB_Redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar deleted redirect']); } }
  5. Thanks Crayon Violet- just what I was looking for
  6. Thanks Gizmola. Your solution certainly works, but having it in the form of a preg_replace() function would make it a lot easier for me to implement. Do you, or anyone else, have any other ideas?
  7. I have the following string: $str = +15.865s I need to use preg_replace() to remove the 's' from the end of the string. However 's' should only be removed if it is immediately preceded by a number. I started with the following code, but obviously it also removed the number that comes before the 's'. $new = preg_replace('/[0-9]s/', '', $str); How do remove the 's' but keep the number? Also I can't use str_replace(), just in case it's suggested. Thanks.
  8. Source: preg_replace('/(?!^.?)[0-9](?!(.){0,3}$)/', '*', '3456-7890-1234-5678');
  9. Thank you jcbones- your solution almost work- it got the arrays right, but it jumbled up the values a bit. Thanks also Alex- I've never heard of array_chunk() before- very useful Much appreciated both of you
  10. I have an array with 192 items in it (0-191) and I want to rearrange them into a multidimensional array with 24 sets of 8. If I wasn't very clear there, here's an abbreviated version of what I want: $arr1 = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); $arr2 = array(array(0, 1, 2, 3, 4, 5, 6, 7), array(8, 9, 10, 11, 12, 13, 14, 15), array(16, 17, 18, 19, 20, 21, 22, 23)); Thank you in advance!
  11. I have a .gz file on my server, and I need to extract its contents, I think with ZLib. How can I achieve this in as simple a way as possible? I've tried the example on the php.com website, and it doesn't work- probably me doing something wrong. Thanks in advance.
  12. Thank you Alex- great help ANSWERED
  13. The script I have currently uses GD library to create a png image. The only problem is that the URL for this is www.mysite.com/image.php. I really need this image to have a .png extension. I know it's possible, but am having difficulty in finding how to achieve it. Thanks in advance.
  14. I have this code for creating an array of all the tables in a database: $tables = array(); $rows = mysql_query("SHOW TABLES FROM {$database}"); while ($row = mysql_fetch_array($rows)) { $tables[] = $row[0]; } What I need to do now is take the names of each of those tables (in the array) and insert them into this code: function getStats($tables) { // Create an array of skills $skills = array('Overall', 'Attack', 'Defence', 'Strength', 'Hitpoints', 'Ranged', 'Prayer', 'Magic', 'Cooking', 'Woodcutting', 'Fletching', 'Fishing', 'Firemaking', 'Crafting', 'Smithing', 'Mining', 'Herblore', 'Agility', 'Thieving', 'Slayer', 'Farming', 'Runecraft', 'Hunter', 'Construction', 'Summoning', 'Duel Tournament', 'Bounty Hunters', 'Bounty Hunter Rogues', 'Fist of Guthix'); $hs = @file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $tables); $out = Array(); if (! $hs) return null; if (strpos($hs, '404 - Page not found')) return null; $stats = explode("\n", $hs); // Loop through the skills for($i = 0; $i<count($skills);$i++) { // Explode each skill into 3 values - rank, level, exp $stat = explode(',', $stats[$i]); $out[$skills[$i]] = Array(); $out[$skills[$i]]['rank'] = $stat[0]; $out[$skills[$i]]['level'] = $stat[1]; $out[$skills[$i]]['xp'] = $stat[2]; } return $out; } $out = getStats($row['username']); if (!empty($out)){ $now = time(); $user = $row['id']; $overallrank = $out['Overall']['rank']; $overalllevel = $out['Overall']['level']; $overallexp = $out['Overall']['xp']; $overallpercent = ($overallexp / $overallexp) * 100; $attackrank = $out['Attack']['rank']; $attacklevel = $out['Attack']['level']; $attackexp = $out['Attack']['xp']; $attackpercent = ($attackexp / $overallexp) * 100; $strengthrank = $out['Strength']['rank']; $strengthlevel = $out['Strength']['level']; $strengthexp = $out['Strength']['xp']; $strengthpercent = ($strengthexp / $overallexp) * 100; $defencerank = $out['Defence']['rank']; $defencelevel = $out['Defence']['level']; $defenceexp = $out['Defence']['xp']; $defencepercent = ($defenceexp / $overallexp) * 100; $hitpointsrank = $out['Hitpoints']['rank']; $hitpointslevel = $out['Hitpoints']['level']; $hitpointsexp = $out['Hitpoints']['xp']; $hitpointspercent = ($hitpointsexp / $overallexp) * 100; $rangedrank = $out['Ranged']['rank']; $rangedlevel = $out['Ranged']['level']; $rangedexp = $out['Ranged']['xp']; $rangedpercent = ($rangedexp / $overallexp) * 100; $prayerrank = $out['Prayer']['rank']; $prayerlevel = $out['Prayer']['level']; $prayerexp = $out['Prayer']['xp']; $prayerpercent = ($prayerexp / $overallexp) * 100; $magicrank = $out['Magic']['rank']; $magiclevel = $out['Magic']['level']; $magicexp = $out['Magic']['xp']; $magicpercent = ($magicexp / $overallexp) * 100; $cookingrank = $out['Cooking']['rank']; $cookinglevel = $out['Cooking']['level']; $cookingexp = $out['Cooking']['xp']; $cookingpercent = ($cookingexp / $overallexp) * 100; $woodcuttingrank = $out['Woodcutting']['rank']; $woodcuttinglevel = $out['Woodcutting']['level']; $woodcuttingexp = $out['Woodcutting']['xp']; $woodcuttingpercent = ($woodcuttingexp / $overallexp) * 100; $fletchingrank = $out['Fletching']['rank']; $fletchinglevel = $out['Fletching']['level']; $fletchingexp = $out['Fletching']['xp']; $fletchingpercent = ($fletchingexp / $overallexp) * 100; $fishingrank = $out['Fishing']['rank']; $fishinglevel = $out['Fishing']['level']; $fishingexp = $out['Fishing']['xp']; $fishingpercent = ($fishingexp / $overallexp) * 100; $firemakingrank = $out['Firemaking']['rank']; $firemakinglevel = $out['Firemaking']['level']; $firemakingexp = $out['Firemaking']['xp']; $firemakingpercent = ($firemakingexp / $overallexp) * 100; $craftingrank = $out['Crafting']['rank']; $craftinglevel = $out['Crafting']['level']; $craftingexp = $out['Crafting']['xp']; $craftingpercent = ($craftingexp / $overallexp) * 100; $smithingrank = $out['Smithing']['rank']; $smithinglevel = $out['Smithing']['level']; $smithingexp = $out['Smithing']['xp']; $smithingpercent = ($smithingexp / $overallexp) * 100; $miningrank = $out['Mining']['rank']; $mininglevel = $out['Mining']['level']; $miningexp = $out['Mining']['xp']; $miningpercent = ($miningexp / $overallexp) * 100; $herblorerank = $out['Herblore']['rank']; $herblorelevel = $out['Herblore']['level']; $herbloreexp = $out['Herblore']['xp']; $herblorepercent = ($herbloreexp / $overallexp) * 100; $agilityrank = $out['Agility']['rank']; $agilitylevel = $out['Agility']['level']; $agilityexp = $out['Agility']['xp']; $agilitypercent = ($agilityexp / $overallexp) * 100; $thievingrank = $out['Thieving']['rank']; $thievinglevel = $out['Thieving']['level']; $thievingexp = $out['Thieving']['xp']; $thievingpercent = ($thievingexp / $overallexp) * 100; $slayerrank = $out['Slayer']['rank']; $slayerlevel = $out['Slayer']['level']; $slayerexp = $out['Slayer']['xp']; $slayerpercent = ($slayerexp / $overallexp) * 100; $farmingrank = $out['Farming']['rank']; $farminglevel = $out['Farming']['level']; $farmingexp = $out['Farming']['xp']; $farmingpercent = ($farmingexp / $overallexp) * 100; $runecraftrank = $out['Runecraft']['rank']; $runecraftlevel = $out['Runecraft']['level']; $runecraftexp = $out['Runecraft']['xp']; $runecraftpercent = ($runecraftexp / $overallexp) * 100; $hunterrank = $out['Hunter']['rank']; $hunterlevel = $out['Hunter']['level']; $hunterexp = $out['Hunter']['xp']; $hunterpercent = ($hunterexp / $overallexp) * 100; $constructionrank = $out['Construction']['rank']; $constructionlevel = $out['Construction']['level']; $constructionexp = $out['Construction']['xp']; $constructionpercent = ($constructionexp / $overallexp) * 100; $summoningrank = $out['Summoning']['rank']; $summoninglevel = $out['Summoning']['level']; $summoningexp = $out['Summoning']['xp']; $summoningpercent = ($summoningexp / $overallexp) * 100; } function combatLevel($attack, $defence, $strength, $hitpoints, $prayer, $ranged, $magic, $summoning) { $base = ($defence + $hitpoints + floor($prayer / 2) + floor($summoning / 2)) * 0.25; $melee = ($attack + $strength) * 0.325; $ranger = floor($ranged * 1.5) * 0.325; $mage = floor($magic * 1.5) * 0.325; return $base + max($melee, $ranger, $mage); } mysql_query("INSERT INTO $tables (attack, defence, strength, hitpoints, ranged, prayer, magic, cooking, woodcutting, fletching, fishing, firemaking, crafting, smithing, mining, herblore, agility, thieving, slayer, farming, runecraft, hunter, construction, summoning) VALUES ('$attackexp', '$defenceexp', '$strengthexp', '$hitpointsexp', '$rangedexp', '$magicexp', '$prayerexp', '$cookingexp', '$woodcuttingexp', '$fletchingexp', '$fishingexp', '$firemakingexp', '$craftingexp', '$smithingexp', '$miningexp', '$herbloreexp', '$agilityexp', '$thievingexp', '$slayerexp', '$farmingexp', '$runecraftexp', '$hunterexp', '$constructionexp', '$summoningexp')"); mysql_close(); Please don't let that put you off- it works fine. As you can see, where you see "$tables" is where the table name should be. I need to repeat all of that code for each instance of "$tables". Problem: I don't know PHP well enough to use 'while' properly. I also think the complexity of that code may cause problems, what with all the curly brackets already there. Thanks in advance, Vettel.
×
×
  • 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.