Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. The reason for this is because you'll need to pass $errors[$i], passing just $errors into empty will be checking the $errors array, and not specific elements.
  2. I'd suggest getting a good PHP editor, they can match brackets and make things much easier. You can find a bunch in this topic: http://www.phpfreaks.com/forums/index.php/topic,54859.0.html Also, don't forget the mark the topic as solved, there's a button to do so in the bottom left.
  3. You're missing a closing bracket '}'
  4. See http://www.phpfreaks.com/forums/index.php/topic,125759.0.html
  5. You have an infinite loop there. If you want to loop through an array like that you have to set $value to the current element that's pointed to by the internal array pointer using current(), then every loop move that pointer using next() Like this: while($value = current($errors)) { // Do whatever you want with $value here next($errors); } Alternatively here are some other examples on how to loop through arrays. for($i = 0;$i < count($errors);$i++) { // $errors[$i]; } foreach($errors as $key => $val) { } Or even something like: for(;$value = current($errors);next($errors)) { // Do something with $value }
  6. He might be referring to the notice thrown if you use an undefined index in the $_GET superglobal, or any variable for that matter, which you might not see depending on your error reporting level. To get around this use isset()
  7. Clearly the OP is looking for something different.
  8. SELECT * FROM table ORDER BY star DESC, RAND()
  9. $id['id']; Assuming your column name is 'id'.
  10. This website is pretty early in development, but I figured I'd post anyway. Just looking for tips and such, mostly in terms of the design as the actual functionality is quite premature. http://www.imagechat.org/ Note: If you can't connect to the socket server it's because I'm running it locally atm and it might be down at times until I move it to a permanent location. But it doesn't matter much in this case anyway because I'm just asking for advise on the UI.
  11. What do you mean "declaring static arrays on multiple lines"? Can you explain what you're trying to accomplish a bit better?
  12. You can grab the hash through document.location.hash. But why would the page the user is on be a hash anyway, wouldn't it be another .php file? That makes more sense to me, and in that case you should use php session variables to store the name of the page they were on previous to login so once they're verified they can be redirected.
  13. oic. I thought you were trying to get 'The' (the first word in the string) and use that as the charlist in ltrim(). Just wasn't thinking.
  14. Do you mean ltrim($string, strstr(' ', $foo, true)) ? That'll only work in PHP 5.3+ though.
  15. I tested it, str_word_count seems to be ~1.05 times slower.
  16. That won't work, you forgot the delimiter '~^[^\s]*\s~' I was curious so I tested: $words = str_word_count($string, 1); array_shift($words); implode(' ', $words); vs $string = preg_replace('~^[^\s]*\s~','',$string); regex takes about ~1.6 times longer. Not that it matters at this scale.
  17. Having to store values like this in mysql is usually a sign of poor database design, that being said.. The reason why you're getting 'Array' is because explode() returns an Array. If all you want to do is to echo out all the values separated by a space instead of a comma, why don't you just do: echo str_replace(',', ' ', $row['some_value']);
  18. <?php $string = "The Scarlet Pimpernel"; $words = str_word_count($string, 1); array_shift($words); echo implode(' ', $words);
  19. Seems to work, http://www.rubular.com/regexes/11559
  20. I guess it depends what type of file it is. Putting key files outside of your document root is usually the best idea, but there are other ways. For example, if you're using a .ini file you could rename it with a .php extension, and do something like this: ; <?php exit; ?> ... Because in .ini files lines starting with ';' are comments when you load that configuration file that won't be included, but if you try to run it from your web browser the php will be executed and it'll stop the script from executing.
  21. Put it outside of your document root.
  22. You can just use current() and array_search <?php $array = Array( 'something' => 'value' ); $val = current($array); $key = array_search($val, $array); echo "$key => $val"; ?>
  23. The only difference is that require() will produce a fatal error if it couldn't include the file. Check the manual: require(), include()
  24. Assuming that $_GET['app'] contains the name of the file you're trying to get the content of, that should work fine. But it is a security risk, you should at least perform some kind of check on the input.
×
×
  • 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.