Jump to content

No ending delimiter ''' found in


Nagaho1234

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/248705-no-ending-delimiter-found-in/
Share on other sites

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.

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

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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.