Jump to content

requinix

Administrators
  • Posts

    15,227
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. You can tell the web server to treat .php files as something different (like text). For Apache it's AddType text/plain .php in a .htaccess file (that's for PHP-as-a-module setups).
  2. Your "maybe this will work" is causing the problem. $form_month is a string, not an array, and when you [] a string you get one of its characters...
  3. You'd save using something that depends on how you're creating the images. GD has a few image*() functions while ImageMagick has a writeImage() function. But I'm not sure you want to do that. How much can the colors change? Could they be anything? That would mean 281 trillion possible images you'd be saving, and that doesn't include the varying square_size...
  4. I can't tell what it is. Accented characters are represented by some kind of a control character (like a semicolon or 0x10) followed by two hex digits but I don't see a correlation between those and the original character. 0x3B 0x65 0x30 = ã 0x10 0x32 0x63 = á I suggest you contact the people who own the web service and ask them about this. Short of that you can manually substitute those sequences with (for example) strtr() like $string = strtr($string, array( "\x3B\x65\x30" => "ã", "\x10\x32\x63" => "á" )); If you do this, be sure to save the file with this code in whatever encoding you want the characters to be. So save the file as UTF-8 if you want that, or ISO 8859-1 if you want that.
  5. This topic has been passed by-reference to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=355874.0
  6. Normally mojibake shows as unusual characters, not things you'd find on a keyboard. Can you post what you get when you run echo bin2hex($string); (if $string is the response)? Without any modifications to it. Also try using mb_detect_encoding on that response. Sometimes it can tell you what encoding the string is, other times it doesn't know.
  7. Also url() can be used with quotes.
  8. if ($query = mysqli_prepare($conn, "SELECT FirstName, LastName, Age, Hometown, Job FROM people WHERE age With prepared statements you don't stick the values right into the query. For mysqli substitute the variable with a question mark. No quotes, even for strings. Speaking of quotes, don't use quotes for numbers. Prepared statement or not. [code=php:0] if ($query = mysqli_prepare($conn, "SELECT FirstName, LastName, Age, Hometown, Job FROM people WHERE age
  9. There's some kind of output in one of those files that shouldn't be there. Do a View Source on a bad page and see what's wrong. Odds are it's an error message but it could be something as innocent as whitespace in a bad place.
  10. The mechanism is basically the same every time you want to do alternating anything in a loop: $color = the first color you want to use loop { print whatever you want using that $color $color = ($color == first color ? second color : first color); } That ?: line alternates the color: when it's one color it sets it to the other.
  11. There might be a couple easy things you can do. Find the place that phpMyAdmin lets you run queries and enter EXPLAIN SELECT * FROM pp_photos WHERE approved=1 AND cat IN (501,511,502,503,562,504,506,505,508,2,510,509) What do you get?
  12. ...but not PHP 5.3 apparently. Check the manual page.
  13. That while loop is great, but you have to wrap it around the stuff that outputs the table rows. while ($row = mysql_fetch_array($get_members)) { ?>
  14. Look at .checked. And unless you like using ==false you can just use a not (!): !document.forms["form"]["unknownname"].checked
  15. strtok($_SERVER["REQUEST_URI"], "?") That's the method I use.
  16. Why aren't you using a DATE or DATETIME column?
  17. It hasn't changed. Generally, it's a good idea to have . on your include path. Not that. That's still relative to the CWD (and I tested this). The fact that it eventually searches the current file's directory regardless of the include_path is new.
  18. You did remember to instantiate the class and call the function, right? $one = new One(); $one->main();
  19. Huh. If you could see me now I'd have egg on my face It seems they've changed the behavior of include() and its friends to what everybody's expected they did. Now it does search the current file's directory at some point in the process and after it tries the CWD. In my defense I know I'm correct... but apparently for previous versions of PHP before 5.3.6 (what I have on-hand to test with). And going through the user comments, for starters, reaffirms that it's changed in the relatively recent past. In other words, DISREGARD THAT I SUCK EGGS. But it's still best to use absolute paths. That hasn't changed.
  20. I've made it my personal mission to point out this issue: It's not relative to the file that's doing the requiring. It's relative to the current working directory. Generally it is the same directory as the first file that was executed, but not necessarily. Generally it doesn't change, but not necessarily.
  21. Almost. The first is an absolute location and will always work. The second is relative and will only work if the current working directory is the same directory running that code (and containing config.php).
  22. I love delving into these sorts of problems and I think I know what it is so I figure I might as well share: (this is all according to the PHP 5.4.0 source code but I'm sure the relevant bits haven't changed in a while) (note that ksort() and sort() and friends work exactly the same way except for what bits they're looking at - ksort() looks at keys while sort() looks at values) When built-in sorting functions do a normal sort they run a comparison function against pairs of values - exactly how the u*sort()s work with your own comparison function. The default function (sort_flags=SORT_REGULAR) is the first half of the issue. It has a long list of actions it takes based on the types of the arguments. For instance, if the two are long* then it compares them as longs, and if one's double* while the other is long then it compares them as doubles. There is nothing that compares strings versus longs so that case falls into the default action. Said default is to cast both to numbers (either long or double as needed) and compare that way. The second half of the issue is how PHP (Zend, actually) does sorting: quicksort**. Basically the list is sorted into two parts where the first is all the pivot. The pivot then gets placed right in the middle. The two parts are sorted the same way recursively until the base case where there are only a couple items. Here's where it gets unpredictable. When the array consists of mixed strings and numbers the comparisons may contradict each other. The simplest example is an array of three items: array("ABC", 123, "789") There are three different comparisons: "ABC" 123 "789" Thus a contradiction: ABC Quite reasonable, quicksort does not look for contradictions like this because it assumes that the comparison function cannot possibly create any. Once compared it doesn't go back over the list, thus there are no infinite loops of constantly moving list items around as the function dictates. The end result is undefined behavior because the same array items in varying orders will create different results. [code]"ABC", 123, "789" => "ABC", 123, "789" "ABC", "789", 123 => 123, "789", "ABC 123, "ABC", "789" => "789", "ABC", 123
  23. You might be missing out on the A in AJAX. ...Uh, the first one. You can't do anything with the result unless you put it in that success function. If you try anywhere else you're going to get a null/undefined because the AJAX hasn't happened yet. Pretend that it takes 5 minutes for anything to happen: you can't get the answer immediately so you have to put in some function that'll execute later (ie, in five minutes) when it does have the answer. Meanwhile you just wait for it to come back.
  24. Known bug. But it's not about the plus - it has to do partly with the "0" key (try sorting without it). ksort() has problems of the "undefined behavior" type when you mix integer/integer-string and string keys* but there's more to it than just that. You can work around it by passing in a sort flag. ksort($array, SORT_STRING); * Array keys that are integer strings, like "0" and "123", are silently converted to actual numeric keys (0 and 123). var_dump(array_keys(array("0" => "zero"))); // [0]=>int(0)
  25. Then... asking your hosting provider how you can change permissions on files. Or use a database instead of a file.
×
×
  • 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.