Hello All
I just set up a simple wamp server for a client and PHP version 5.3.0 throws some errors and warnings with my code.

I'm asking if someone can verify that I made the proper fix:

Deprecated: Function ereg() is deprecated in C:\wamp\www\pos\classes\db_functions.php on line 417

Here is line 417:

if(ereg("\"<>",$data_to_check[$k]) or ereg("<",$data_to_check[$k]) or ereg(">",$data_to_check[$k]) )

I replaced this line with:

if(preg_match("/<>\"/",$data_to_check[$k]))

Did I get that right? Is there a better way? Thanks in advance for your help.

Regards
Russ

    Looks like what you want is:

    if(preg_match('/[<>"]/', $data_to_check[$k]))
    

    (It will match if it finds any occurrence of "<" or ">" or '"' within the string.)

      Thanks for the reply yes that seems to work just fine. 😃

        3 years later

        I was wondering if you could help me with this. My host changed their php version and now I am getting this error:
        Deprecated: Function eregi() is deprecated in /data..../htdocs/libraries/joomla/language/help.php on line 80
        When I go there I find this, but I don't know what to do with it.

        if (!eregi( '\.html$', $ref )) {
        				$ref = $ref . '.html';

        Please help.
        Thanks in advance.

          Panol;10998283 wrote:

          I was wondering if you could help me with this. My host changed their php version and now I am getting this error:
          Deprecated: Function eregi()
          ...

          php.net wrote:

          As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.

          check it out 🙂

            Sorry, I am not coder. It does not really make any sense to me. I am just trying to see if you could help me with this...
            Thanks

              Is it OK if I change this:

              if (!eregi( '\.html$', $ref )) {
                              $ref = $ref . '.html'; 

              to this:

              if (preg_match( '\.html$', $ref )) {
                              $ref = $ref . '.html'; 

              Sorry if I am making a huge mistake..just being logic.
              Thanks.

                Forget it. Not working.
                Thanks for your help.

                  if ( ! preg_match( '#\.html$#i', $ref )) {
                  

                    PCRE's (Perl-Compatible Regular Expressions) are a little different than the original ereg_*() versions.

                    The answer to your specific question is:

                    <?php
                    if( !preg_match( '/\.html$/i',$ref ) ){
                        $ref = $ref.'.html';

                    However, there is another issue to consider:

                    If your script uses this function in one spot, it probably uses it in other places as well. You might be chasing and fixing similar errors for some time.

                    Even though you're "not a coder," it would be worth your while to do a little learning if you're the one who has to fix everything. Trust me, if you don't know what you're doing, you can cause a lot of major problems trying to fix a minor one.

                    [edit] dang it! NogDog strikes again! 🙂 [/edit]

                      Write a Reply...