Open-source PHP CMS and Blog

Create and manage your website with MemHT in few and easy steps.

It's customizable, expandable and suitable for all your needs.

Download MemHT 5.0.1.0 Stable
eregi to pre_match
Jesse Lockard
Jesse Lockard
Registered
Monday 17 Feb 2014 02:27
2 Posts
My hosting servers updated their PHP to 5.4 and my site has alot of errors.
The version is 4.0 and I have corrected most of the errors but I can not figure this one out: inc_functions.php line 385

Orginal Code:function validate($string,$regex='^[^<>\'\"`%\$\\\/#]*$') {
if ($regex=="url") { $regex = "^[http://]*[a-zA-Z0-9~\._-]*\.*[a-zA-Z0-9~\._-]*\.[A-Za-z]{2,4}/*[a-zA-Z0-9?\.+&@#/%=~_|-]*"; }
return (eregi($regex,$string)) ? true : false ;}.....................................

So I modified the code:function validate($string,$regex='^[^<>\'\"`%\$\\\/#]*$') {
if ($regex=="url") { $regex = "^[http://]*[a-zA-Z0-9~\._-]*\.*[a-zA-Z0-9~\._-]*\.[A-Za-z]{2,4}/*[a-zA-Z0-9?\.+&@#/%=~_|-]*"; }
return (preg_match('/$regex/i', $string)) ? true : false ;}.....................................

So now my pages dont show up and this error appears:
Errno: 2

File: /homepages/7/00000000/htdocs/inc/inc_functions.php

Line: 385

Function: preg_match

Note: preg_match(): Unknown modifier '#'

Does anyone knnow the proper structure for the delimiters.
Modified by Jesse Lockard on Monday 17 Feb 2014 03:05
Re: eregi to pre_match
Manojlo Miltenovikj
Manojlo Miltenovikj
Administrator
Friday 28 Feb 2014 12:10
73 Posts
This is the inc_functions.php modified to work with PHP 5.3

http://pastebin.com/vdDV79BE

Don't just copy and paste it, because i can't remember if this file is the original one with just the preg_match modifications, use it as a guide.

Anyway the preg_match (and preg_replace) is the correct alternative to the eregi and the modifier you should use is alt+96 `

example:
preg_match("`[a-z]`is"

preg_replace("`[a-z]`is"
Modified by Manojlo Miltenovikj on Friday 28 Feb 2014 12:10
Re: eregi to pre_match
Jesse Lockard
Jesse Lockard
Registered
Saturday 08 Mar 2014 02:15
2 Posts
Thank you for your help.

Replacing the code on line 385(preg_match("`".$regex."`is",$string)) ? true : false ; still gave me error:

Errno: 2

File: /homepages/7/d327907304/htdocs/inc/inc_functions.php

Line: 385

Function: preg_match

Note: preg_match(): Unknown modifier '%'

But when I went to: http://pastebin.com/vdDV79BE# and "Download" the code. Then opened it up and saved as inc_functions.php.
No errors and all is working well. By far the easiest and fastes way of correction this issue.

Thanks again
Re: eregi to pre_match
Manojlo Miltenovikj
Manojlo Miltenovikj
Administrator
Wednesday 18 Jun 2014 20:25
73 Posts
No problem.
Copyright © 2005-2014 by Miltenovikj Manojlo - All rights reserved
Powered by MemHT
Powered by MemHT
Made with PhpStorm
Made with PhpStorm