SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,027
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Function eregi() is deprecated Error message

    Hello,

    We have switched to a new server with latest Php version and all of a sudden are getting Error message:

    Function eregi() is deprecated in......

    We are using eregi() in this way to see that Fotos uploaded have filetype JPG, GIF PNG:

    if (eregi('^image/p?jpeg(;.*)?$', $_FILES['uploadedfile']['type'])) {
    $filetype = 'jpg';
    }

    The documentation says replace eregi with preg_match, which we did as here:

    if (preg_match('^image/p?jpeg(;.*)?$', $_FILES['uploadedfile']['type'])) {
    $filetype = 'jpg';
    }


    but when we do this produces Error message:

    Warning: preg_match(): No ending delimiter '^' found in


    So what is the right method for replacing the eregi() is deprecated?

    ThanX.

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by WorldNews View Post
    if (preg_match('^image/p?jpeg(;.*)?$', $_FILES['uploadedfile']['type'])) {
    Surround the expression in the preg_match within delimiters - any character not in the string makes a good delimiter for example

    Code:
    if (preg_match('@^image/p?jpeg(;.*)?$@', $_FILES['uploadedfile']['type'])) {
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,027
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Your suggestion seems to be working just fine.
    You are the Php man

    Anoox search engine volunteer

    www.anoox.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •