Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=341125.0
  2. Something like.. $referer = $_SERVER['HTTP_REFERER']; if(empty($referer) || strpos($referer, 'linkportal') !== false) { echo "Hello my friend!"; } empty strpos
  3. I haven't been able to get into it much either, but I didn't give it too much time. I do understand some of the appeal though, you can make some pretty cool things, .
  4. What you're looking for is called pagination. You can find a good tutorial for it here.
  5. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=340919.0
  6. The PHP_SELF element can in fact be altered by the user to include any kind of malicious XSS code he/she desires What an exagerated statement... You can simply filter the element. That's not exaggerated at all. It can be altered to include any malicious XSS code. Whether or not you sanitize it is a irrelevant, the statement says nothing about that. The whole point of it anyway is that people don't sanitize it and use it on form actions. Just leave it blank.
  7. What you should be doing is using a salt. $pass = md5('your salt here' . $password);
  8. http://www.php.net/manual/en/reserved.variables.request.php
  9. I'm not really sure what you mean. Maybe I didn't make my point clear enough. The whole concept behind my idea is that you keep the data separate from the output. I wouldn't suggest that you format the data in the string, then have to edit it like that later on, that's unnecessary. But if you keep the data separate from the formatting, then you can change the formatting however you want in the future without having to deal with the logic. This is pretty much the whole idea behind template engines.
  10. Yeah, I got the pm, but I'd prefer to keep the discussion in the thread.
  11. I'm not sure what you're asking for. Printing out what exactly? You're making claims without any justification...
  12. I think it's flexible. I was only arguing that my solution would produce the same output, and would work for even a single result, but I would also argue that my solution is just as flexible, and maybe a bit more clean. If you wanted to edit the data, you would do it beforehand, that's kind of the point. You separate your pre-processing from the outputting, it makes it cleaner and gives your output a single point instead of all over the place. $titles = array(); while($row = mysql_fetch_array( $result )) { $titles[] = $row['title']; // edit title here before inserting it into $titles. } echo '{' . implode('|', $titles) . '}'; The logic behind your code and the output are two completely different things, and it's much cleaner and easier to read if you keep them separated. Instead of having tons of echos everywhere and having to look through 50 lines of code to piece together what happens when the echos get combined, you can simply look at a single line and see it right there.
  13. I understand that, but whether you output them one at a time, or all at once afterwards is irrelevant. The output is exactly the same.
  14. Um.. what? My solution would work if there is only a single result. Plus, the whole premise of the question is there will be multiple rows returned, otherwise the whole question is pretty moot. You wouldn't need the while loop, and could just do: echo '{' . $the_single_result . '}';
  15. One way: $titles = array(); while($row = mysql_fetch_array( $result )) { $titles[] = $row['title']; } echo '{' . implode('|', $titles) . '}'; implode
  16. http://www.php.net/manual/en/reserved.variables.globals.php
  17. You don't need regex for this. You can just use explode: $str = 'This-is-an-example-sentence-right-here'; echo implode('-', explode('-', $str, -3)); Note: This requires PHP 5.1.0 (when support for a negative limit parameter was added).
  18. You have a few problems. First, your function is outputting the text, not returning it. Second, '$assemblelist' is a literal string, not a variable. To simplify things, you can just have the function return it in the format you want. Something like this: function this($array) { $str = ''; foreach($array as $fruits) { $str .= "I like to eat ".$fruits.","; } return substr($str, 0, -1); } $assemblelist = this($list); print_r($assemblelist);
  19. Just a small comment: In the way you're using substr() there (you also put substring() instead of substr()), the third parameter is superfluous. In fact, you'd be trying to take one extract character that doesn't exist from the string. $string = substr($string, 1); Would suffice.
  20. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=339298.0
  21. The & part of the string, so it should be in the quotes. You also need another period. Try: <?php echo $page."?aid=".$aid."&uid=".$urbid; ?>
  22. Yeah, pretty much. Something like: url: image.php?file=someimage.jpg Then use $_GET['file'] to know what file to load. Don't forget to sanitize that input.
  23. That's how it works. You have it in a separate file, and then you use that php file as you would any other image resource: <img src="thatphpfile.php" alt="..." />
×
×
  • 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.