Jump to content

andy5000

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

andy5000's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thankyou David, I've been teaching myself PHP for a little while now, but didn't even realise I was supposed to be doing it like this. I think I must have been quite lucky not to have come across this problem before considering that how I always do my relocates! Thanks again - you learn something every day
  2. I don't know if I have been awake too long and im missing something stupidly obvious, but I cannot work out why this script isn't behaving as expected. I have simplified it down as much as I can in my code yet it is still giving me problems: if (1 == 1) { header("location:1.php"); } else { header("location:2.php"); } // other code down here When running this, I would expect to be relocated to 1.php, however, my "other code" is running instead. The weird part is that if I do this: if (1 == 1) { header("location:1.php"); } else { header("location:2.php"); } exit(); // other code down here I do get relocated. Im sure its really simple, but I am just lost. I have been hopping in between PHP and Coldfusion all day so I might just be getting some basic syntax wrong.. I don't know. Any help would be very much appreciated!
  3. Hi Cags, That is absolutely fantastic. Tested it, and it does exactly what i was asking for. I am very grateful for the time you put in to helping me out! Now I have something that works... im going to try and work through it and understand how it works Thanks again, Andy
  4. Hello, Unfortunately, I think when multiple quotes appear in the same post, they share the same ID/code thing. For example: [quote:c123][quote:c123]How are you?[/quote:c123] Good Thanks[/quote:c123] That's good to hear. Argh On a sidenote, though, the single-line mode works a treat. Which just leaves me with the problem mentioned in your previous post... Is there a solution, or am I now firmly up the creek with no paddles in sight?
  5. Hello again, Thanks for posting those! They seem to be doing the trick in some cases, however I have now noticed that it is possible to have the following bbcode: [quote="Persons Username":c123]Quote Body Text[/quote:c123] I have taken the code you posted above and played around with it a bit, and got the following: $messagebody = preg_replace('#\[quote(.*)\].*?\[/quote(.*)\]#','',$messagebody); This appears to cover all possible quotes that could appear, except for ones where the quote body text contains a new line. I have read that the . (period) in regex means any character except for new lines - this is obviously what is causing it to not match. Is there a way I can do any character including new lines? I have played around with changing the .*? bit to [./n]*? and loads of other various possiblities, but no luck. Can you tell I dont really "get" regular expressions?
  6. Hi Cags, Thanks for the reply. I've done a little bit of reading and playing with str_replace but have found that unfortunately in a phpbb3 database, bbcode is stored like [b:12312312] and [i:5633] - i dont know what the numbers represent, but I believe they are unique. Therefore, [ b] isn't actually matching anything. For the "completely stripping out" bit, I would ideally want to remove the whole thing for Quote, URL, IMG, Flash and Youtube tags, including anything in between the opening and close tag. For anything else other than these tags, I would like to remove just the tags, keeping what is between the opening and closing tag. For example, this post: [quote]Introduce Yourself![/quote] Hello my name is [i]Jason[/i], have a look at my [b]COOL[/b] website! [url=http://www.jason.com]My Website[/url] Would become: Hello my name is Jason, have a look at my COOL website! Nesting is a good point. Quote tags could contain a whole host of any other tags. Italics/Bold/Youtube tags could all appear within a quote. As well as quotes within quotes. This is becoming more complicated than I thought it would be. The following tags are the ones I want to basically nuke and remove in their entirity: quote img flash youtube url Out of these, the "Quote", "Flash" and "Youtube" tags can have optional attributes.
  7. Hello, PHP Beginner here. Please go easy on me. My problem is as follows: I want to display latest post from a forum on a webpage. I want to completely strip out [ quote], [ img], [ flash] and [ youtube] tags, including the text between the tags. I then want to simply remove any other bbcode tags. For example, [ b], [ i], [ list], [ code], etc. Leaving the text between the tags in place. I have tried searching the forum and web in general, but most bbcode regex questions seem to be to do with converting bbcode to html instead of simply stripping tags and contents - plus, the fact im a beginner and don't really know what im doing makes things a lot harder to understand. I currently have the following (please excuse me for any awfully written code): $messagebody = $row['post_text']; // Remove [quote] [img] [flash] [youtube] code entirely (including contents) // :-( // Remove [b] [i] [u] [list] [*], etc (just tags) // :-( // Remove any nasty html tags $messagebody = strip_tags($messagebody); print '<p>'.$row['username'].' says: <a href="forum/viewtopic.php?t='.$row['post_id'].'">'.$messagebody.'</a></p>'; The commented out frowny faces represent my failure at knowing what to do. I apologise if this gets asked all the time, I did try searching, honest! Any help, or links to somewhere I can find an answer, would be much appreciated. Thanks, Andy
×
×
  • 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.