S75 Posted June 18, 2013 Share Posted June 18, 2013 Hi, i'm having this error on my page, but i cant get it solved. Can some please help me ? I am searching for almost 2 weeks now. Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /home/simonky109/domains/gunstreet.nl/public_html/ubb.php on line 46 Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found in /home/simonky109/domains/gunstreet.nl/public_html/ubb.php on line 47 This is what the lines says : $bericht = preg_replace('/\*)]([^[]*)\[\/email]', '<a href="mailto:info@gunstreet.nl">2</a>', $bericht); $bericht = preg_replace("/\*)\]([^[]*)\[\/url\]", "<a href='1' target='_blank'/>\\2</a>", $bericht); Thank you for your help. Greetings Simone. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 18, 2013 Share Posted June 18, 2013 (edited) You're missing the ending / delimiters. [edit] Which is exactly what the error message says. Weird, huh? Edited June 18, 2013 by requinix Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 18, 2013 Share Posted June 18, 2013 (edited) The error is exactly as it says - you are missing the ending delimiter. When defining your regular expression it needs to be enclosed within delimiters (in addition to the quote marks). This is because a regular expression can have additional parameters that are not part of the matching expression. You start your regular expression with a / so, it must have a closing / as well. I typically use # instead of the slashes because those are more often used in the matching characters. So, here are your expressions corrected: $bericht = preg_replace('/\[email=([^[]*)]([^[]*)\[\/email]/', '<a href="mailto:info@gunstreet.nl">2</a>', $bericht); $bericht = preg_replace("/\[url=([^[]*)\]([^[]*)\[\/url\]/", "<a href='1' target='_blank'/>\\2</a>", $bericht); But, you probably didn't realize those expressions won't work if the BB code had uppercase characters. That is one of the reasons you would add an additional parameter after the last delimiter. In this case you would add the parameter 'i' to be case insensitive. Here are the expressions adding case insensitivity AND fixing the dynamic replacements. $bericht = preg_replace('#\[email=([^]]*)\]([^[]*)\[\/email\]#i', '<a href="mailto:\\1">\\2</a>', $bericht); $bericht = preg_replace('#\[url=([^]]*)\]([^[]*)\[\/url\]#i', '<a href="\\1" target="_blank">\\2</a>', $bericht); Edited June 18, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
S75 Posted June 18, 2013 Author Share Posted June 18, 2013 i dont get it i'm just a beginner in php. Must i put the / after the word "bericht" ? sorry but i really dont understand what you mean and sorry for my bad english i come from the netherlands. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 18, 2013 Share Posted June 18, 2013 preg_replace('#\]*)\]([^[]*)\[\/email\]#i', '<a href="mailto:\\1">\\2</a>', $bericht); The two # in red are the beginning and ending delimiters for the matching part of the regular expression above. The part in bllue is the matching part of the expression and the green "i" at the end is a parameter to make the expression case insensitive (i.e. "word" = "WoRd"). Your original code had a / for the beginning delimiter, but there was no corresponding / for the end of the matching part of the expression. There were /'s in the expression but they were not the ending delimiter. I used # because it is not used in the matching expression and is more obvious. Quote Link to comment Share on other sites More sharing options...
S75 Posted June 18, 2013 Author Share Posted June 18, 2013 Thank you verry much the problem is solved now Now i'm going to look for the last error permission denied in : $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); Thanks again !! 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.