Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Everything posted by Wolphie

  1. Possibly a good idea to enable some form of caching too.
  2. Please, when posting code remember to use the code BB Code.
  3. Well, I still don't entirely understand what you're trying to achieve, but this is my best guess: <?php $validate = array('var1', 'var2'); foreach ($validate as $key) { if (!isset($_REQUEST[$key]) || empty($_REQUEST[$key])) { // empty or not set } else { // They're fine } ?>
  4. Oh, sorry I misunderstood. As alpine pointed out, using $_REQUEST will do both if you're unsure which to expect.
  5. Well as you know, isset() literally just checks if the variable has been set, it has no kind of input validation on it. For example you would use it to check to see if a session variable had been set when a user logs in, the value may not be important. However, in a user-submitted form the value is important, i'd prefer to use the empty() function to check against form element inputs. But on the other hand, I would use isset() to check for checkboxes, and radio buttons.
  6. Alpines solution is currently the most widely-used and elegant way of doing what you're trying to achieve.
  7. http://php.net/manual/en/function.shuffle.php
  8. Of course there is, first check that it's an array you're trying to loop using http://php.net/manual/en/function.is-array.php
  9. http://php.net/manual/en/control-structures.foreach.php
  10. Personally, I'd recommend taking a look at how regular expressions work and how they could help you accomplish what you're trying to do. I've looked at your code, and this works for me although I'm not entirely sure if it's exactly what you're after. <?php $content = "Crazy Random Apple 43 Left Apple Truck Plane Turtle Duck"; $needles = array("Random", "Apple", "Duck"); $words = split(" ", $content); foreach($words as $word) { foreach ($needles as $needle) { if ($word == $needle) { // Flag regular word flag($word); $alert = 1; } } if ($alert == 1) { if (is_numeric($word)) { $alert = 0; } else { flag($word); } } } ?> [code]
  11. Before looking behind the scenes at the code of a content management system and getting into the complexities, I suggest you install one locally and play around with it so that you can understand the processes in which content is dynamically added and changed/removed.
  12. I can't really see a shorter way except concatenating it into a single string.
  13. This isn't really possible unless you have shell access, or telnet access... and even then I think it would be difficult. Those are the only 2 ways without actually downloading the file to the local machine, whether it's an automated process or not. FTP would require a connection, retrieving the file, opening it, making the changes and then uploading it again. I hope someone can correct me on that, because I'd be interested to know also.
  14. Honestly, there are so many bulletin board softwares out there, it's pointless writing one yourself unless it has a unique feature which none other has. Which is unlikely since most bulletin boards support plug-ins etc... I'd stick with one that's maintained, open-source and supported.
  15. <?php $sql = mysql_query("SELECT * FROM starters"); echo '<table>'; while ($item = mysql_fetch_object($sql)) { echo '<td>'. $item->starter .'</td>'; echo '<td><input type="checkbox" name="selected[\''. $item->starter .'\']" />'; } echo '</table>'; ?>
  16. Why can't you just place a check box next to it? <?php $sql = mysql_query("SELECT * FROM menu"); echo '<table>'; while ($item = mysql_fetch_object($sql)) { echo '<td>'. $item->name .'</td>'; echo '<td><input type="checkbox" name="selected[\''. $item->name .'\']" />'; } echo '</table>'; ?>
  17. Well first, what are you trying to achieve?
  18. You'd need to get the values from the database and put them in the $offline array. E.g. <?php $offline = array(); // Execute query $sql = mysql_query("SELECT a, b, c FROM some_table LIMIT 1"); // Get the key and the corresponding value and place them into the $offline array foreach (mysql_fetch_assoc($sql) as $key => $val) { $offline[$key] = $val; } ?> I think that's what you're looking for.
  19. Wolphie

    proxys

    <?php if (get_env("HTTP_X_FORWARDED_FOR")) { $ip = get_env("HTTP_X_FORWARDED_FOR"); // They're behind a proxy } else { $ip = getenv("REMOTE_ADDR"); // Proxy doesn't exist } ?>
  20. Where is the HTML coming from? Are you opening a different file and reading the contents or is it hard coded as a string in the PHP script itself? or perhaps somewhere in a database?
  21. Sorry, no I didn't see that. I'm assuming, $theme_parssed contained all of the HTML to begin with?
  22. {username} is not the same as {=username}
  23. Well, first of all $images_total should be an integer, not a string. Adding the quotes make it a string so using the greater than or less than comparison operators won't work here. <tr> <td colspan="2"><input type="submit" class="button" value="<?php if ( $images_total < 3 ) { echo "_UPLOAD_SUBMIT"; { else { echo "You have reached your upload limit"; } { } ?>" /></td> </tr>
×
×
  • 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.