Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Can you post feedback.php here?  My guess is there's a problem with your quoting (double quotes and single quotes)
  2. Have you tried another browser or another computer? If you get the same behaviour on another browser and/or another computer, then can you post your code here?
  3. get_categories() is not part of standard php.  You might want to try the "third-party php script" forum.
  4. Just check [code=php:0]if (empty($_POST['password'])) {   # Don't update password } else {   # Update password }[/code] Since no-one can set an empty password, this will work fine.  In your situation, you might need to make 2 versions of the query, one which updates the password and another which doesn't.  Or, you can make the optional password update occur in a seperate query.
  5. What happens when you run your code, and what are you expecting to happen?
  6. Why is the newline required?  The simplest way to fix this is to remove the newline.
  7. I think deletion and re-creating is the way to go.  There's always a tradeoff between simplicity of code and efficiency, and since there's no more than 20 songs on a CD, the loss in efficiency is negligible.  There's no point optimizing something that doesn't need optimizing :)
  8. Can you give more detail?  Where are you pressing open?  Give as much detail as possible, like folder names, file names, file icons, file types.
  9. btherl

    captured ports

    A shot in the dark.. apache needs to start with root access in order to bind port 80 (though it will usually change user later on).
  10. You don't specify a return value for allChars() in the case where $this->button is not set.  That could be the problem.
  11. The regular expression "DirectoryName" will do that.  For example: [code=php:0]if (ereg('DirectoryName', $string) == 1) {   print "Match\n"; }[/code] But it would be faster to use strpos: [code=php:0]if (strpos($string, 'DirectoryName') !== false) {   print "Match\n"; }[/code]
  12. [code=php:0]<?php $arrays = array('05' => 'Ted',                     '02' => 'A',                       '04' => 'B',); $max = '0'; # Must be less than all numbers foreach ($arrays as $number => $name) {   $max = max($max, $number); } echo "Maximum is number $max with value {$arrays[$max]}\n"; ?>[/code]
  13. Try this: [code=php:0]$result = mysql_query("SELECT displayname FROM userinfo WHERE username='$_SESSION[sconlineusername]'") or die(mysql_error());[/code] The rest is the same.
  14. emehrkay, it matters because of syntax highlighting on the forum. Supermerc, try adding some debugging output to your script, such as printing out the filename you are testing for existence.  Also, if you have direct access to your files (through ftp or a web interface), take a look to see if the file is really there. In particular I would use: [code=php:0]echo "You Do Not Have An Avatar (looked for $filename)";[/code]
  15. Try [code=php:0]$cmd = "less main.cpp; g++ main.cpp -o test.out &> /tmp/g++.out;";[/code] And see what you get in /tmp/g++.out It might help to give the full path too, [code=php:0]/usr/bin/g++ main.cpp[/code]
  16. If you want more flexibility, you can write it like this: [code=php:0]$result = mysql_query($sql); if ($result === false) {   print "The query to fetch widget ids from the database failed!  Please try again in a few minutes, or send an email to admin@example.com if problems persist.  Thankyou for your patience.\n";   # Do whatever else you want to do..   exit(0); }[/code]
  17. Here are two ways to do it: [code=php:0]SELECT * FROM LatestNews ORDER BY ID DESC LIMIT 1[/code] [code=php:0]SELECT * FROM LatestNews WHERE ID = (SELECT MAX(ID) FROM LatestNews)[/code] The first one is probably faster.  The reason your query doesn't work (apart from missing the "*" after select) is that you cannot use max() as a condition unless you are also using group by.  You can use max() as the result of the query anytime, but not as a condition.
  18. btherl

    MD5 to SHA-1

    Unfortunately you cannot "convert" hashed passwords.  You will need to set all the passwords again, once you have changed over to SHA-1.
  19. Ooh, that subquery looks good.  Very clever.  And the join with the subquery looks fine to me. I would guess that it's either one of the other joins or one of your conditions.  How about removing each of the other joins and conditions one by one until you find which one is excluding the stores that you expect should be in the results?  Or you can start with the subquery and add conditions and joins until one of them doesn't act how you expect.
  20. 1.  You should put quotes around all string constants, like this: [code=php:0]if ($_post['field'] == 'chapter') {[/code] 2.  You should include connect.php only once. 3.  You have a lone "elseif" in the first while loop.  Removing that should fix the "blank page".  Blank page usually means there's a problem with your syntax.
  21. Hmm.. you could use this trick: [code=php:0]SELECT team, SUM(IF(pos<>P,ch+ph+sp,0)) as bvalue, SUM(IF(pos=P,`as`+co+pavg,0)) as pvalue FROM rosters GROUP BY team ORDER BY bvalue+pvalue[/code] My syntax may not be 100% correct but the idea is sound.  Otherwise you can just use 2 queries, if the overhead isn't a large factor.
  22. I have tried several similar caching systems. 1. Fetch the entire query into an array, serialize the array, and store in the database as character data. 2. Fetch the entire query into an array, serialize the array, compress the result and store in db as binary data. 3. Fetch the entire query into an array, and store in db in an array data type (I don't think this is possible in mysql, I was using postgres). In all cases, the caching tables had just key, data and updated (for expiring old results) columns. Of course this means you must fetch and unserialize the array each time.. Another option is to store the data in a text file or text files.  You can split the files into page chunks if you know (or can make an educated guess) as to the page size the user will be using.  The filesystem can be a very effective caching system, much like a hash table.  Lookups of a particular filename are very fast in most filesystems.
  23. For Trouble #1, how about using group_concat() and string comparison functions?  It doesn't seem hugely efficient though, as group_concat() must be called on every matching store before doing the test. A better alternative might be to select all stores with service 1 in a subquery, and all stores with service 2 in another subquery, then do an inner join on idStore.  An inner join is the same as intersection/and instead of union/or, so it is exactly what you want.  Since you're dynamically generating your queries, you can generate as many subqueries as necessary. As for trouble 2, I would go with the many queries followed by php post-processing approach.  It's just too messy to put such complex rules (and rules that match human thinking will always be messy and complex) into SQL.
  24. Aha, you are using strrpos().  That probably doesn't do what you expect.  Use strpos() instead (only one r). Also, check [code=php:0]if (strpos($browser, 'Firefox') !== false)[/code] Otherwise the test will fail is Firefox is found at position 0.
  25. What does "not working at all" look like? Check that there's no html, not even blank lines before that code.  The very top line of the file should be "<?php", followed by that code checking for browser type.
×
×
  • 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.