Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. good idea JBS, thanks. I guess I will switch it to an error surpressed include for now and not check if the file exists. That way if they try to mess with it the most they'll get is a blank page :/
  2. My smartass answer wasn't there until you had replied to Archadian. You act like a two-year old, I'll reply like a two-year old. It's the internets. Get used to it. Or I'll take your lunch monies.
  3. if(count($values)){ //foreach in here }
  4. Yeah but did it print anything on the print_r($values)? What about for $copy? If not, your $value[_posts] thing isn't set.
  5. I'd have to be constantly updating the array then...that would get annoying fast Thanks for the idea though
  6. Ah I see, I read too fast. Do this: <?php $copy = $value['_posts_content']; print $copy; while(strpos($value['_posts_content'], ':') !== FALSE){ $value['_posts_content'] = substr($value['_posts_content'], (strpos($value['_posts_content'], ':')+1)); $values[] = substr($value['_posts_content'], 0, strpos($value['_posts_content'], ':')); $value['_posts_content'] = substr($value['_posts_content'], (strpos($value['_posts_content'], ':')+1)); } print_r($values); foreach($values AS $v){ $copy = str_replace(":$v:", '<img src="images/smileys/'.$v.'.gif" />', $copy); } $value['_posts_content'] = $copy; ?> And see what it puts out
  7. You used $value and $values, pick one or the other.
  8. That's only on one page, my base.php file which includes the other stuff, it's not on every page literally. I'm not talking about lines of code, but rather code efficiency.
  9. What I've got works, but I'm concerned about the fact that the only reason the file wouldn't exist is if the user messed with the url. ($in is a url variable, properly sanitized, etc.). I don't want users to see "Warning: require_once(xxx) [function.require-once]: failed to open stream: etc, etc." if they're just poking around and messing with the url, but it seems like such overkill to check every time if the file exists when most of the time it will. There's probably a better way to do this...thoughts? <?php if(file_exists($in.'.php')){ require_once($in.'.php')){ }else{ print 'Woops!'; }?>
  10. Try this one. <?php $str = ":bad::happy::mdr::tongue::wink::zzz::whip::^^:"; $copy = $str; while(strpos($str, ':') !== FALSE){ $str = substr($str, (strpos($str, ':')+1)); $values[] = substr($str, 0, strpos($str, ':')); $str = substr($str, (strpos($str, ':')+1)); } foreach($values AS $v){ $copy = str_replace(":$v:", '<img src="images/smileys/'.$v.'.gif" />', $copy); //Or you could do $copy = str_replace(":$v:", "<img src=\"images/smileys/$v.gif\" />", $copy); } print $copy; ?>
  11. Can you show the actual code, because what you've posted doesn't make much sense...
  12. Okay...and the code I posted works perfectly fine.
  13. You're trying to use register_globals, you need to define $id before using it. $id = $_GET['id'];
  14. Yes, you can...I started to write you an example but then firefox crashed. I wrote you an example. You could also try explode, and other similar functions. <?php $str = "This :is: a string :with: values :in it:"; while(strpos($str, ':') !== FALSE){ print 'String: '.$str.'<br />'; $str = substr($str, (strpos($str, ':')+1)); $value = substr($str, 0, strpos($str, ':')); $str = substr($str, (strpos($str, ':')+1)); print 'Found Value: '.$value.'<br />'; }?>
  15. Well obviously he values OUR opinions so highly that it's very important he know what we all would use, even though it actually has nothing to do with PHP, we're obviously the smartest people around, so what we think is a big part in his decision making process.
  16. So there's an unexpected if...because something very important is missing from the line above it;
  17. Also add this to the very top: ini_set('display_errors', 1); error_reporting(E_ALL);
  18. http://www.phpfreaks.com/forums/index.php/topic,117475.0.html Anyone can also use the forum search feature, and see how many times this question has been asked before.
  19. Barand, everyone knows there are 10 types of people, gosh.
  20. Is the problem still that the code is displaying, or that the code is not working? Use the <?php tag. Edit: That is not how to properly access a variable. If the form's method is post, you need to do $submit = $_POST['submit']; before using it.
  21. How did you do so? Also, is it your computer or a shared host?
  22. You /your host have short tags turned off.
  23. You need to use strtotime() as well echo 'Newly formatted: '.date("d.m.Y",strtotime($mydate))
×
×
  • 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.