Nagaho1234 Posted October 8, 2011 Share Posted October 8, 2011 Hi New to php code, been trown in at the deep end. Keep getting error message Warning: preg_replace(): No ending delimiter it is to do with these 3 lines only $is_sera = preg_replace("'","\"", $is_sera); $is_sera = preg_replace("%","", $is_sera); $is_sera = preg_replace("\?","", $is_sera); can any one tell me what the ending delimiter error means/is thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/ Share on other sites More sharing options...
silkfire Posted October 8, 2011 Share Posted October 8, 2011 Every PHP regex expression needs to have a delimiter character. It's used so that after it you can put flags to manipulate your regex (it's like options of sort). Common practice is to use a rare character, something that's not bound to occur in the expression itself, f.ex. "%", "/" or "¤". Correct would be: $is_sera = preg_replace('%\?%', '', $is_sera); Just a warning. You have a very simple regex that you dont need regex for. Use str_replace instead. Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277284 Share on other sites More sharing options...
Nagaho1234 Posted October 8, 2011 Author Share Posted October 8, 2011 Every PHP regex expression needs to have a delimiter character. It's used so that after it you can put flags to manipulate your regex (it's like options of sort). Common practice is to use a rare character, something that's not bound to occur in the expression itself, f.ex. "%", "/" or "¤". Correct would be: $is_sera = preg_replace('%\?%', '', $is_sera); Just a warning. You have a very simple regex that you dont need regex for. Use str_replace instead. I wouldn't know were to begin editing it or replacing code, I was hoping it was a simple typo mistake the code use to work fine up to a week ago, unfortunately the guy who wrote it has died and I'm trying to get rid of these error messages. Its a database and it is set to back itself up daily but has begun to throw up these 3 errors last cpl of days. so these 3 lines can be omitted and changed to that single line - $is_sera = preg_replace('%\?%', '', $is_sera); ?? as I say I'm out of my depth Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277290 Share on other sites More sharing options...
Nagaho1234 Posted October 8, 2011 Author Share Posted October 8, 2011 thanks, that seemed to do the trick much appreaciated Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277292 Share on other sites More sharing options...
silkfire Posted October 8, 2011 Share Posted October 8, 2011 Want a solution? Do this: $is_sera = str_replace(array('\'', '%', '?'), array('"'), $is_sera); Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277307 Share on other sites More sharing options...
Nagaho1234 Posted October 9, 2011 Author Share Posted October 9, 2011 Want a solution? Do this: $is_sera = str_replace(array('\'', '%', '?'), array('"'), $is_sera); Thank you that works as well, there are 2 more error lines given in another part of the search function which was there before if you could explain where the code is going wrong - Deprecated: Function split() is deprecated on line 1100 $fls = split(" ",$sysinf["comments"]); Deprecated: Function ereg_replace() is deprecated on line 1103 $flcom = ereg_replace($fsize,"", $sysinf["comments"]); thanks Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277379 Share on other sites More sharing options...
Buddski Posted October 9, 2011 Share Posted October 9, 2011 Both of those 2 functions rely on the POSIX regrex, which has been deprecated in your version of PHP. You should use preg_split and preg_replace respectively. Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277382 Share on other sites More sharing options...
Nagaho1234 Posted October 9, 2011 Author Share Posted October 9, 2011 I replaced $fls = split(" ",$sysinf["comments"]); with $fls = preg_split(" ",$sysinf["comments"]); also $flcom = ereg_replace($fsize,"", $sysinf["comments"]); with $flcom = preg_replace($fsize,"", $sysinf["comments"]); im getting new error messages for those lines Warning: preg_split() [function.preg-split]: Empty regular expression on line 1100 Warning: preg_replace() [function.preg-replace]: Empty regular expression on line 1103 do I need to replace all these same commands in the code ? I think it all started when code was updated, so I am told anyway. Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277383 Share on other sites More sharing options...
Buddski Posted October 9, 2011 Share Posted October 9, 2011 You have to update your pattern to be PCRE compatible. Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277385 Share on other sites More sharing options...
Nagaho1234 Posted October 9, 2011 Author Share Posted October 9, 2011 ok, so does that mean rewriting the code itself ? Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277389 Share on other sites More sharing options...
Buddski Posted October 9, 2011 Share Posted October 9, 2011 No, just updating each of the deprecated functions. You could use explode() instead of split()/preg_split() And str_replace() instead of ereg_replace()/preg_replace() Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277394 Share on other sites More sharing options...
Nagaho1234 Posted October 9, 2011 Author Share Posted October 9, 2011 Thank you it is all working now, very much appreciated. Excellent feedback Quote Link to comment https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/#findComment-1277396 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.