Jump to content

NFreak

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by NFreak

  1. It seems to be working now. I didn't know that the css file would only apply to things after they were loaded. Very strange that it actually worked the first time, though.
  2. I'm working on a new website for a friend (studentsinpolitics.com), and the page loads properly the first time in IE, but if I click any links, it loads the page without the CSS. I don't use frames, and I didn't have this problem with nfreak.net. I don't want to solve this problem for my version of IE, but rather include something in the code to make it work for everyone. Please and thank you. (Also note the problem only occurs in IE. It works fine with everything else. Maybe caching issues?)
  3. I use PHPBB, and I've recently been getting random spam advertisements on my forum now. It seems that there are bots that crawl the site and create an account, create a topic, and link to their website.
  4. Since we're on the topic of including files, is there a way to have a header.php and a footer.php file get processed on every page? Currently, I just put the include lines in my code at the beginning and end manually, but there are some pages on my site that I made before I knew about including, and it would be nice to be able to update them.
  5. If I try and run a PHP script that takes a few hours to run, it will stop after about 25 minutes. I'm pretty sure it's because of a server setting in the php.ini file. I decided to install Apache on my computer, and I got PHP installed as well. Can anyone help me configure PHP so that it doesn't kill the script after 25 minutes. I plan on running a few things locally to take load off of my TCH site. max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) Those are the current settings for things in the php.ini file that may be causing the problem. If you know of a PHP command that let's the script run forever that would be great as well. Thanks.
  6. I don't actually store the values for attack, defense, spy, and sentry in the database. The database stores the values for how many of each item the user has, the number of trained soldiers, etc... It pulls that information and generates the attack, defense, etc... stats as it loads the page. Otherwise grabbing it already sorted would've been easy. Thank you again for all the help. The script is so fast now.
  7. Okay, cool. I'm new to functions and stuff. I've never used return before.
  8. Actually, scratch that. The update takes about 2.5 minutes to update. This owns. I may never have to revise this code again.
  9. Alright, I got my script up and running. You rock! The script takes about 3.5 - 4 minutes to run, but it does a lot. It gives every member of the site some gold and an extra attack turn. Then it proceeds to find out the four minor ranks (attack, defense, spy, sentry). After it writes all of that to the database it adds together the attack, defense, spy, and sentry ranks into a new array. So if my stats are: Attack: Ranked #40 Defense: Ranked #108 Spy: Ranked #1231 Sentry: Ranked #430 It would add (40+108+1231+430) into a new variable. It does that for every user, then sorts it out in reverse to find the overall rank. So the number 1 member will have the lowest number when all the ranks are added. The reason it takes so long is because writing to the database is slow. At least it seems that way. But 3.5 minutes up from 12 clears up a lot of lag, makes it less glitchy, and saves loads of bandwidth. *Bows down.*
  10. Wow, that's amazing. I tested it and it worked. Now I just have to implement that into my script. Thank you very much. I have one question, though. return ($a['defense'] > $b['defense']) ? -1 : 1; What does that line of code do? I don't understand the "? -1 : 1;". I've never seen anything like that before.
  11. I got my update to finish in 5 minutes, up from about 12 - 15. All I did was combine a line of code with another. I had no idea that writing to a database took so much time. I had two lines of code next to each other that updated the users gold, then gave the user an extra turn. I made it give the user gold and a turn in the same line of code, and somehow that cut about 10 minutes off the update time. I suppose that looping a bunch of mysql code 1800 times goes much faster when there aren't two update lines next to each other. I'm satisfied with update time, and I shouldn't have any further problems unless membership reaches about 3500.
  12. Thanks for the suggestions. If you're able to provide some sample code to sort the above array by attack and defense, that would be great. I'm not sure how I would apply the suggested functions to my script. $arrStats=array(); $arrStats[1][username]="Bob"; $arrStats[2][username]="Bill"; $arrStats[3][username]="John"; $arrStats[1][attack]=150; $arrStats[2][attack]=200; $arrStats[3][attack]=75; $arrStats[1][defense]=250; $arrStats[2][defense]=50; $arrStats[3][defense]=980; Basically, John's attack power is 75, and his defense power is 980. He's ranked first for defense, but third for attack. That's what I need to do. The current way I do it involves a massive nested loop that is killing my bandwidth, as it's sorting over 1800 users every 30 minutes. The most basic sorting function, sort($array), works almost perfectly. The only problem is that it sorts by the first type listed in the second dimension. So, since username was first declared, it will sort by username. If there's a way to make it sort by attack and defense, that would work perfectly.
  13. I've looked up various PHP functions like asort() and arsort(), but I can't seem to find a way to sort an array by a specified dimension. For example: $arrStats=array(); $arrStats[1][attack]=150; $arrStats[2][attack]=200; $arrStats[3][attack]=75; $arrStats[1][defense]=250; $arrStats[2][defense]=50; $arrStats[3][defense]=980; I can't seem to find a function that sorts by a specified type. I programmed a game for my website, and every 30 minutes I have a cron script run that ranks all the users by various stats (attack, defense, spy, sentry). The script used to be able to run almost instantly, but then membership grew to 500, and it started slowing down. Now, membership for my game is at about 1800 in the past 2 months, and the update takes literally 15 minutes to load. The update goes every 30 minutes, so that basically means there is a massive script running 50% of the time. This causes a lot of lag near midnight, when the daily update goes off. So, my question is, does anyone know if a quick way to sort out an array. In this example, I'd like to be able to sort the array out by attack power, and then by defense power, as quickly as possible. Any help, or suggestions? Thanks.
  14. <?php $arrTip = array(); $arrTip[1]="Make a tip."; $arrTip[2]="Make a tip."; $arrTip[3]="Make a tip."; $arrTip[4]="Make a tip."; $arrTip[5]="Make a tip."; $arrTip[6]="Make a tip."; $arrTip[7]="Make a tip."; $arrTip[8]="Make a tip."; $arrTip[9]="Make a tip."; $arrTip[10]="Make a tip."; $rand = rand(1,10); // This will pick a random number between 1 and 10. Change the number "10" to however many tips you have. $tip = $arrTip[$rand]; print $tip; ?> There's a short little script to get a random tip. Make sure the page is a .php page so that the code will work. If you intend on having hundreds of tips, it's best to just turn it into a MySQL database, although that should work fine.
  15. Maybe I overlooked it, but I didn't see a "description" META tag in the source code. You should try adding one of them so that when Google or another engine crawls your site, they can make your search results look prettier. <META name="description" content="Welcome to the Jensen Family website."> Maybe add more to it than that. Also, sometimes your quote appears blank. You should add an "if" statement in your PHP so that there is always a quote. if ($quote=="") { $quote = "Put some sort of fixed quote in here for when it turns out blank."; }
  16. Thanks for the information, Andy. I wasn't sure if maybe they paid money to webhosts to get the information or something. My rank jumped to 410,540.
  17. It took me awhile to figure out cron jobs as well, but what I do to execute a PHP script is a lynx dump command: lynx -dump http://www.yoursite.com/script_to_run.php If you don't want to receive emails from the cron thing, then clear the field in the cron section that asks you for the email. Hope that helps, although it seems you have already solved the problem.
  18. Thanks, Alex. That was a big help. I didn't know I had to add the IP to the list of allowed sites. EDIT: It worked! Thank you again very much for your help.
  19. How would I connect to my MySQL database from another server. My friend is also a client of TCH but our attempts to connect to the mysql database have been unsuccessful. My domain name is nfreak.net. Is there a certain port that you need to use to connect? nfreak.net:3307?
  20. If you don't know what Alexa.com is, it's a site that will show you the top rated websites on the internet. You can search for a domain name and it will give you it's ranking relative to other sites. Recently my site has jumped into the top 100,000 websites for the weekly rating, but the overall ranking is 609,345. Can anyone explain how they find the data for site hits and visitors and stuff? Feel free to post your site ranking as well.
  21. I had a similar problem like that. I use the str_replace(); function to filter out certain words on a chatroom page of my site. I decided to change them to eregi_replace(); but it just timed out everytime. I still don't see what the problem was, but it's not too big of a deal to me. Anyways, I agree with you. TCH has been very reliable, and they have helped me with everything I've ever needed. I am really glad that I chose them as my host, and I hope to stick around for years to come.
  22. How much longer? I'm only in study hall for another 20 minutes. ;.;
  23. Two more hours for central time zoners. I wonder what time tomorrow we'll find out.
  24. I can't wait much longer. *Fetal position.*
  25. It's just started to get warm over here in IL. Today was one of the warmest days of the year even though it rained.
×
×
  • Create New...