Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. rsort() and arsort()
  2. sort() or if you wish to retain the key associations asort()
  3. Uh, well what do you mean with parameters?
  4. Use the PCRE functions, they're faster than ereg.
  5. Not really. PHP detects when a resource is not used anymore frees it automatically. It's just a matter of who that does it: you or PHP's garbage collector.
  6. Database connection will be closed by PHP automatically at the end of script execution. There is no need to do it yourself. Also, you shouldn't close important things in destructors (file handles, database connections, sockets etc.) as you cannot control the order of which objects are destroyed. You should only close a database connection if you need it to end before the script ends. Otherwise there is no point in doing it.
  7. Check if it's empty() instead. Even if it is set it can still be empty.
  8. How can you possibly answer that question if you don't know what OOP is all about?
  9. if(in_array(pathinfo('/path/to/file', PATHINFO_EXTENSION), $extensions)) ?
  10. Change $borid = mysql_fetch_assoc($bor2); to list($borid) = mysql_fetch_row($bor2);
  11. redarrow, what the str_reverse('kcuf') are you talking about? Curly braces are not going to be removed from PHP 6. The only thing that will change with curly braces in PHP 6 is that it will be deprecated to use them for single character access. E.g. <?php $string = 'test'; echo $string{2} // "s" - deprecated in PHP 6 echo $string[2] // "s" - not deprecated in PHP 6 ?> Also, ereg will not be removed but moved to PECL and there is no function called preg_regex(). That doesn't make any sense.
  12. Are you referring to my or Daukan's code or his own suggested solutions?
  13. CREATE TABLE `tournaments` ( `id` INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(100) NOT NULL, # etc... ); CREATE TABLE `users` ( `id` INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, `username` VARCHAR(100) NOT NULL, # etc... ); CREATE TABLE `users_tournaments` ( `user_id` INTEGER NOT NULL REFERENCES `user`(`id`), `tournament_id` INTEGER NOT NULL REFERENCES `tournaments`(`id`) ); <?php try { $db = new PDO('mysql:dbname=something;host=localhost', 'username', 'password'); } catch(PDOException $e) { die('Connection failed: ' . $e->getMessage()); } if(empty($_GET['tournament_id'])) { die('No tournament id set'); } $tournament_stmt = $db->prepare('SELECT * FROM `tournament` WHERE `id` = :id LIMIT 1'); $tournament_stmt->exec(array(':id' => $_GET['tournament_id'])); $tournament = $tournament_stmt->fetch(PDO::FETCH_ASSOC); $users_stmt = $db->prepare('SELECT u.* FROM `users_tournaments` AS ut JOIN `users` AS u ON u.`id` = ut.`user_id` WHERE ut.`tournament_id` = :tournament_id ORDER BY u.`username`'); $users_stmt->exec(array(':tournament_id' => $_GET['tournament_id'])); $users = $users_stmt->fetchAll(PDO::FETCH_ASSOC); ?> Not tested.
  14. Run user submitted data through htmlentities() before outputting.
  15. Mobile phone because I can take it with me. DELETE FROM smf_topics WHERE ID_TOPIC = 171689; or UPDATE smf_topics SET locked = 1 WHERE ID_TOPIC = 171689;
  16. http://downloads.sourceforge.net/gimp-win/gimp-2.2.17-i586-setup.exe No, it's a BitTorrent client (although you could probably argue it's a download manager since it manages downloads over the BitTorrent protocol). Here are some different ones to choose from: http://en.wikipedia.org/wiki/Comparison_of_download_managers
  17. There is one without GTK+ bundled which is about 7.5 MB. You can only use that one if you have GTK+ installed though. You could use a download manager. In that way you can pause and resume downloads. I believe Opera and FF3 have that.
  18. The latest Windows installer is located here: http://downloads.sourceforge.net/gimp-win/gimp-2.4.2-i686-setup.exe
  19. Try this: In .htaccess: php_value register_globals off
  20. You can just pass it directly to exec(). I.e. exec('SHUTDOWN -S -T 30 -C "GOOD BYE" -F');
  21. No you didn't. We need to know your expected result.
  22. All content as in all rows or all content as in all columns for a single/couple (of) row(s)?
  23. So you're having trouble posting the code here, or...?
  24. You don't need any hidden fields. <?php $textarea_values = array(); foreach($_POST as $key => $value) { if(preg_match('/^body_[0-9]+$/', $key)) { $textarea_values[] = $value; } } ?> But a better option would be to rename the textareas. <?php $a = mysql_query("SELECT * FROM `table` WHERE `this` = 'that'"); while$b = mysql_fetch_array($a)) { echo '<textarea name="body['.$b['id'].']" cols="50" rows="3"></textarea>'; } ?> In that way you can access $_POST['body'] as an array on the next page.
×
×
  • 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.