Monkuar Posted September 20, 2012 Share Posted September 20, 2012 I think I might be over-thinking this.. but let's say a user on my board decides to post [quote=Fred]hello everyone[/quote] Is there a way, I can check server side if no text or characters are used after ""? "Error!, You cannot post just a quote, you need to enter a post". This is because I don't want peeps just posting with a quote, they should atleast reply/say something u know? Or maybe instead of me just asking for help all the time I think a little? So that's what I did, my only solution would be to do something like this: substr("[quote=Fred]hello everyone[/quote]", -1); but this would only return "]", how can I make it return 7 more characters, so I can just check if "" is the last string used, and if it is, then error the user out! or do you think regex would be appropriate here? Which one is better for performance for large body of text, < 12,000 bytes (TEXT) MYSQL field?? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 20, 2012 Share Posted September 20, 2012 I must confess that I'm disappointed that you didn't reference the PHP manual for substr () before posting this, the answer to your question is quite clearly defined in the examples there. That said, you should probably want to use substr_count () in addition, to ensure that there is only one quote tag in the post. Also take into consideration those who start their posts with answering the quote, and then just leave the entire post quoted at the end. Quote Link to comment Share on other sites More sharing options...
Monkuar Posted September 20, 2012 Author Share Posted September 20, 2012 I must confess that I'm disappointed that you didn't reference the PHP manual for substr () before posting this, the answer to your question is quite clearly defined in the examples there. That said, you should probably want to use substr_count () in addition, to ensure that there is only one quote tag in the post. Also take into consideration those who start their posts with answering the quote, and then just leave the entire post quoted at the end. BAM substr('[quote=ROFL]hey ChristianF PPHPFREAKSz[/quote]', -8, ; // f echo's . Now how do I check if text is posted above a [quote=hey,January 1th] hey [/quote] tag? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2012 Share Posted September 20, 2012 Maybe use the string functions to remove everything between [ quote] and the next [ /quote] including the tags, and then trim the remaining string, and see what's left. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 20, 2012 Share Posted September 20, 2012 What does substr ($message, 0, 6); return if nothing is posted in front of a quote? Quote Link to comment Share on other sites More sharing options...
Monkuar Posted September 20, 2012 Author Share Posted September 20, 2012 What does substr ($message, 0, 6); return if nothing is posted in front of a quote? FINISHED AND SOLVED BABY!!!! I AM PRO $checkquoteonly = substr($text, -13, 13); $checkquoteonly2 = substr($text, 0, 9); //Check if the first text contains "Quote" $check1 = stripos($checkquoteonly2, 'quote'); /* echo $checkquoteonly .'<br>'; echo $checkquoteonly2; */ if ($check1 == true){ if ($checkquoteonly == '--endquote-->'){ message("You must enter a complete message."); } } --endquote--> is what parses the quote message in my text into HTML, I just put a "<!--endquote-->" at the end of each quote so I can catch it it in the substr. I only substr the --endquote-> part because if I did "<!--endquote-->" it wouldn't return any characters, it's bugged at ! question mark. (PHP BUG) So then I checked if the first 9 characters of the string if it contained "quote" in them using stripos like ChristianF said Then, ya u can see the rest of the code, Thanks ChristianF Topic solved! Only problem now is if someone does: Quote: <--put quote message here --> but I will just make a <!--quotestart--> when the text is being converted and switch it up just people don't say Quote: then link to a quote... topic solved ty Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2012 Share Posted September 20, 2012 So what happens if a user posts A quote Their response Another Quote Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 20, 2012 Share Posted September 20, 2012 Good to see that you got it solved, and glad I could help. Though, as Jesi pointed out above, it seems as if you missed the second half of my first post. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.