Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
rsort() and arsort()
-
sort() or if you wish to retain the key associations asort()
-
Uh, well what do you mean with parameters?
-
Use the PCRE functions, they're faster than ereg.
-
Is this a good way of connecting to a database?
Daniel0 replied to papaface's topic in PHP Coding Help
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. -
Is this a good way of connecting to a database?
Daniel0 replied to papaface's topic in PHP Coding Help
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. -
Check if it's empty() instead. Even if it is set it can still be empty.
-
How can you possibly answer that question if you don't know what OOP is all about?
-
if(in_array(pathinfo('/path/to/file', PATHINFO_EXTENSION), $extensions)) ?
-
Change $borid = mysql_fetch_assoc($bor2); to list($borid) = mysql_fetch_row($bor2);
-
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.
-
Are you referring to my or Daukan's code or his own suggested solutions?
-
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.
-
Run user submitted data through htmlentities() before outputting.
-
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;
-
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
-
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.
-
The latest Windows installer is located here: http://downloads.sourceforge.net/gimp-win/gimp-2.4.2-i686-setup.exe
-
Please tell me if you think Aplus.net has lied to me - register_globals
Daniel0 replied to Aldebaran's topic in Miscellaneous
Just put it in your document root. -
Please tell me if you think Aplus.net has lied to me - register_globals
Daniel0 replied to Aldebaran's topic in Miscellaneous
Try this: In .htaccess: php_value register_globals off -
You can just pass it directly to exec(). I.e. exec('SHUTDOWN -S -T 30 -C "GOOD BYE" -F');
-
No you didn't. We need to know your expected result.
-
All content as in all rows or all content as in all columns for a single/couple (of) row(s)?
-
So you're having trouble posting the code here, or...?
-
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.