Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Whoops, there is a serious problem with this in php4. Reference counts are 16 bit, so it's easy to overflow. This is fixed in php5 however. The 32 bit reference count there means you can reference the bool until your memory runs out without running into the reference count limit.
  2. Try this .. you'll need to make a similar change for games() function scores() { $get = mysql_query('SELECT popular_week FROM vg_games ORDER BY popular_week DESC LIMIT 0,100'); $all_values = '|'; while($show = mysql_fetch_array($get)) { $all_values .= $show['popular_week'].'|'; } return $all_values; } $games = games(); $scores = scores(); mysql_query('INSERT INTO vg_popular (games, scores) VALUES ("'.$games.'", "'.$scores.'")');
  3. Have you looked at sessions? With those, you can store the user id on the server instead of in $_GET
  4. Apparently mediawiki stores the entire text of each revision, in the text table here: Mediawiki db schema
  5. Try adding this: curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla');
  6. I think it's fine. The amount of processing you do there is nothing compared to some sites I've seen If your navigation has hundreds or thousands of entries then you might need to do it another way.
  7. It's very odd that you have \r and \n literally in your database strings. How did this happen? Also, there is no need to store the backslash in the database. It looks like you have 2 levels of escaping there when you only need 1. I suspect that what you need is this: $title = mysql_real_escape_string(stripslashes($_POST['title'])); Then your input will not have the extra backslashes in the first place.
  8. Can you give us the messages you see, exactly as you see them? It's difficult to guess what's happening from the description you've given. If there's no option for linux, then unix is next best. Unix is to Linux as Windows is to Windows XP. Unix is the general class, and Linux is the specific version. Windows is the general class, and Windows XP is the specific version. It's a little different since all Windows are made by microsoft, but the different types of Unix are made all by different organizations.
  9. If you're thinking of wikipedia, they use the mediawiki package. Other wikis use different software, and each package represents the data in its own way. So there's no single answer to your question..
  10. I just discovered a cute way to save memory in php. One of my favorite data structures is an inverted array where the interesting values are the keys, and the array values are meaningless. For example: array( 0 => "bunny", 1 => "paboom", 2 => "mummy", ); becomes array( "bunny" => true, "paboom" => true, "mummy" => true, ); The idea is that I can check for array values in constant time now. The loss of the indices is not important because the data was not ordered to begin with, even though it was represented as an ordered array. Basically it's a hash table. The only problem here is that I'm storing a copy of true for every single array entery. What can we do about that? $start_mem = memory_get_usage(); $arr2 = array(); $bool = true; for ($i = 0; $i < 10000; $i++) { $arr2[$i] =& $bool; } $end_mem = memory_get_usage(); print "Used " . ($end_mem - $start_mem) . " bytes for 10000 references to \$bool with integer keys\n"; $start_mem = memory_get_usage(); $arr = array(); for ($i = 0; $i < 10000; $i++) { $arr[$i] = true; } $end_mem = memory_get_usage(); print "Used " . ($end_mem - $start_mem) . " bytes for 10000 copies of true with integer keys\n"; Used 465776 bytes for 10000 references to $bool with integer keys Used 625600 bytes for 10000 copies of true with integer keys There you have it. Instead of storing a copy of true for every array element, I simply use one copy of true and create many references to it. The memory savings are around 25% I'm interested in hearing about any other data structures in use by php programmers out there.
  11. That's code is too complex to look through.. what you can do is add print statements to show each value throughout your script. You can remove the prints once the script works. For example: //make it only 5 decimal places $ValidateStrength = number_format($GainTotalStrength,5); print "Converted $GainTotalStrength to $ValidateStrength (5 decimal places)<br>"; If there's a problem, then you will see it as the print statement will not match what you expected. Then you fix the bug and continue debugging I'm suspicious that you divide $PercentageHappyAddOn by 100 when it's already so small. Is that intended?
  12. pg_escape_string() is not the problem. It's necessary for adding data to the database, and does not modify the actual data. Can you post your code so we can debug it?
  13. SERP = Search Engine Result Page When you do a search and get a list of results, that list of results is the "SERP" (as well as everything else on that page)
  14. n cannot be greater than 6, so there's no issue with brute force taking a long time. The fact that only 6 jobs need be handled indicates that a brute force solution is expected (unless they learnt a particular algorithm in the course, which they are expected to apply).
  15. Here's another option (just to confuse you) echo "<font color='#660000'>{$row['title']}</font>"; The {} protects the variable inside so it is interpreted correctly.
  16. What data type are those columns? If they are varchar or char then you will need to convert them to integers each time you order, which can be done like this: SELECT * from leaguetable ORDER BY point + 0 DESC, gd + 0 DESC
  17. Try adding some print statements throughout your code. These can show you what the values of variables are. They can also tell you if your script dies at some point. Also try adding this at the start of your script: ini_set('display_errors', 1);
  18. Whenever you do a query, do it like this: mysql_query($isql, $con2) or die("Error in $isql:\n" . mysql_error()); That will tell you if there's a problem with your query. You should also add an "or die" to your mysql_connect().
  19. markjoe has got it .. not goes with and, and equals goes with or in this case. Regarding the array solution, have you tried it? It works with any number of values. Every value in the array is checked. The logic is inverted though - you are checking for equals rather than not equals. It's the same logic as markjoe's first example.
  20. Try ob_implicit_flush() and ensure that zlib output compression and mod_gzip are not active on your page. You can check that by checking the headers in your browser (For example, using live http headers extension in firefox) Simply printing at 5 second intervals is not enough, as php will cache the data and send it in larger chunks by default.
  21. If you want to check many urls: $urls = array( 'http://www.blah.com/post1.php', 'http://www.blah.com/post2.php', ); if (in_array($test_url, $urls)) { print "Allowed"; } else { print "Not allowed"; }
  22. I would say that brute force is the easiest approach. Using a more efficient algorithm will be harder.
  23. The bytea type stores binary data. The representation of the data (in the sql statement) is not very compact though. In general, I would recommend storing your media in the filesystem and storing only metadata in the database, unless your media happens to be quite small.
  24. btherl

    Error 502

    What OS does your web server run on?
×
×
  • 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.