Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts

    deprecated: Function eregi() is deprecated in

    Hello

    I have a Guestbook but after i have move my webhotel to a new
    server i get this error, After what i can read is it because that the "eregi" dont work in the new PHP version and it shall change to "preg"

    But i have no idea how to change it so good i am not to PHP

    Deprecated: Function eregi() is deprecated in /mnt/webf/e2/35/53159135/htdocs/images/guestbook/include/funct_utiles.php on line 512

    Line 512 : if (eregi("^[a-z0-9]$", $chr))

    The whole code is this

    function generatePwdGuest3($chrs=10){
    $pwd = "";
    mt_srand ((double) microtime() * 1000000);
    while (strlen($pwd)<$chrs){
    $chr = chr(mt_rand (0,255));
    if (eregi("^[a-z0-9]$", $chr))
    $pwd = $pwd.$chr;
    };
    return $pwd;
    }

    //----------
    Last edited by Inigoesdr; 01-26-2012 at 06:09 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    this is what i use for passwords:

    PHP Code:
    function generatePW() {
      
    $validpw='12345qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM67890';
      
    $strPW='';
      for (
    $i=0;$i<8;++$i) {
        
    $strPW.=$validpw[mt_rand(0,strlen($validpw))];
      }
      return 
    $strPW;

    so replace all the $strPW in this one to $pwd and replace function generatePW with generatePwdGuest3

    this is based on me assuming this is to make a random password for the user
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • Users who have thanked Dan13071992 for this post:

    mitsucats (01-26-2012)

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hello

    Then i get a new error in another file ...

    eprecated: Function eregi_replace() is deprecated in /mnt/webf/e2/35/53159135/htdocs/images/guestbook/index.php on line 166 Deprecated

    $chaine_smileys .= "<img src=\"".$chem_absolu."images/smileys/".$alex_livre_smileys_smiley[$i]."\" alt=\"\" title=\"".ucfirst(str_replace("_", " ", eregi_replace("[.]{1}(.)*$", "", $alex_livre_smileys_smiley[$i]))).

  • #4
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    did that last one work? also, is this to do with smiles? aka bbcoding?
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • Users who have thanked Dan13071992 for this post:

    mitsucats (01-26-2012)

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    The las one worked fine with the text but give me a error in the index.php

    but that i fix

    was just to change generatePwdGuest3 to generatePW

    Then now i get the new error as you can see in my topic or look at
    my link

    http://www.mitsucats.de/images/guestbook/guestbook.php

  • #6
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    change all of the:

    PHP Code:
    eregi_replace() 
    to

    PHP Code:
    preg_replace() 
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • Users who have thanked Dan13071992 for this post:

    mitsucats (01-26-2012)

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That dident work

    $chaine_smileys .= "<img src=\"".$chem_absolu."images/smileys/".$alex_livre_smileys_smiley[$i]."\" alt=\"\" title=\"".ucfirst(str_replace("_", " ", preg_replace(("[.]{1}(.)*$", "", $alex_livre_smileys_smiley[$i]))).

    Parse error: syntax error, unexpected ',' in /mnt/webf/e2/35/53159135/htdocs/images/guestbook/index.php on line 166

  • #8
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That dident work

    if i try with only one ( and not ((

    $chaine_smileys .= "<img src=\"".$chem_absolu."images/smileys/".$alex_livre_smileys_smiley[$i]."\" alt=\"\" title=\"".ucfirst(str_replace("_", " ", preg_replace("[.]{1}(.)*$", "", $alex_livre_smileys_smiley[$i]))).

    Warning: preg_replace(): Unknown modifier '{' in /mnt/webf/e2/35/53159135/htdocs/images/guestbook/index.php on line 166

  • #9
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    Quote Originally Posted by Dan13071992 View Post
    this is what i use for passwords:

    PHP Code:
    function generatePW() {
      
    $validpw='12345qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM67890';
      
    $strPW='';
      for (
    $i=0;$i<8;++$i) {
        
    $strPW.=$validpw[mt_rand(0,strlen($validpw))];
      }
      return 
    $strPW;

    so replace all the $strPW in this one to $pwd and replace function generatePW with generatePwdGuest3

    this is based on me assuming this is to make a random password for the user
    Just a personal though on password generators, you should remove 1(one) & l(lowercase L) & 0(zero) & O(capital o) & probably o(lowercase O) from the string as these are very similar characters and can cause confusion with the user if they are typing passwords in manually.

    These days there are a lot of mobile users typing in passwords manually...

    Just my thoughts..

  • #10
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I have download the complete script for the guestbok and i like it much and i have also
    wrote to the owner of the script if he could help but nothing yet...

    I am not so good to php. i am best to use dreamweaver.

    Therefore i hope i can get help to fix this problem.

    I thank you all for trying to help me

  • #11
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Dan13071992 View Post
    change all of the:

    PHP Code:
    eregi_replace() 
    to

    PHP Code:
    preg_replace() 
    PREG and EREG do not use the same syntax. There are some simple patterns that work with both, but you can't simply change the name of the function and expect it to always work properly.
    Quote Originally Posted by jmj001 View Post
    Just a personal though on password generators, you should remove 1(one) & l(lowercase L) & 0(zero) & O(capital o) & probably o(lowercase O) from the string as these are very similar characters and can cause confusion with the user if they are typing passwords in manually.

    These days there are a lot of mobile users typing in passwords manually...
    Limiting the characters in your random password generator isn't necessary since anyone on a desktop/laptop/smartphone is going to be able to copy/paste it and likely change it to something they can remember anyway.

    Quote Originally Posted by mitsucats View Post
    That dident work

    if i try with only one ( and not ((

    $chaine_smileys .= "<img src=\"".$chem_absolu."images/smileys/".$alex_livre_smileys_smiley[$i]."\" alt=\"\" title=\"".ucfirst(str_replace("_", " ", preg_replace("[.]{1}(.)*$", "", $alex_livre_smileys_smiley[$i]))).

    Warning: preg_replace(): Unknown modifier '{' in /mnt/webf/e2/35/53159135/htdocs/images/guestbook/index.php on line 166
    Try something like this:
    PHP Code:
    $chaine_smileys .= '<img src="' $chem_absolu 'images/smileys/' $alex_livre_smileys_smiley[$i] . '" ' .
                            
    'alt="" ' .
                            
    'title="' ucfirst(str_replace('_'' 'preg_replace('/\..*$/s'''$alex_livre_smileys_smiley[$i]))) . '" ' .
                            
    '/>'
    I separated the img tag's attributes on to different lines to make it clearer.

    Edit: here is what that regular expression does(removes the file extension):
    Code:
    \..*$
    
    Match the character “.” literally «\.»
    Match any single character «.*»
    `- Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
    Assert position at the end of the string (or before the line break at the end of the string, if any) «$»
    Last edited by Inigoesdr; 01-26-2012 at 06:12 PM.

  • Users who have thanked Inigoesdr for this post:

    mitsucats (01-27-2012)


  •  

    Posting Permissions

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