2

I get the following 2 errors

Notice: Undefined property: User::$username Fatal error: Call to undefined function mcrypt_create_iv()

And I cannot figure out what it is... I have installed this software on 2 other servers without a problem.

This is the part of script which it should be

function set_user_cookie() {

global $USER_COOKIE,$COOKIE_PATH,$COOKIE_DOMAIN,$COOKIE_KEY;

$cookie = "email=".urlencode($this->email)."&uid=$this->id&seclev=$this->seclev&username=$this->username";

if (isset($COOKIE_KEY)) {

  $iv = mcrypt_create_iv(mcrypt_get_iv_size (MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND);

  $cookie = base64_encode(mcrypt_encrypt (MCRYPT_BLOWFISH, $COOKIE_KEY, $cookie, MCRYPT_MODE_ECB, $iv));

}

$expire = (time() + (3600 * 24 * 365 * 5));

setcookie($USER_COOKIE,$cookie,$expire,$COOKIE_PATH,$COOKIE_DOMAIN,0);

}

I hope someone can help me here there I am quite new to PHP :(

user2376009
  • 31
  • 1
  • 1
  • 3
  • 2
    It sounds like `mcrypt` is not [installed / configured](http://www.php.net/manual/en/mcrypt.setup.php) into PHP. – Jonathon Reinhart Sep 11 '13 at 07:57
  • Have a look at this post: http://stackoverflow.com/questions/12479983/cant-find-mcrypt-call-to-undefined-function-laravel-mcrypt-create-iv – Raja Amer Khan Sep 11 '13 at 08:01
  • 4
    @Jonathon Reinhart: that google.com is a nice thing. Bookmarked it. – zerkms Sep 11 '13 at 08:01
  • I always use Google.com but put between " my error messages which means that not everything shows up, everything post here on Stackoverflow will show up even on top. 99 out of the 100 problems I have I solve that way! – user2376009 Sep 11 '13 at 09:22

2 Answers2

19

First Install php mcrypt module.

sudo apt-get install php5-mcrypt   

Restart Apache.

service apache2 restart

If problem persists after you install mcrypt module,it may because of not enabling the mcrypt module. Try this.

sudo php5enmod mcrypt

again Restart Apache.

service apache2 restart
Mohammed Safeer
  • 20,751
  • 8
  • 75
  • 78
5

You're probably missing the mcrypt PHP extension.

If your server runs on Debian / Ubuntu, install it like this...

sudo apt-get install php5-mcrypt

Then restart your webserver:

sudo /etc/init.d/apache2 restart

On other Linux distros, use the appropriate package installer tool. If things still don't work, you may have to enable the mcrypt extension in your php.ini.

ciruvan
  • 5,143
  • 1
  • 26
  • 32