[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Call to undefined function  mcrypt_module_open() in CLI only, works fine when in browser

Posted on 2008-11-07
Medium Priority
Last Modified: 2013-12-13

I'm encountering a weird problem.

I'm using xampp 1.6.4 on a  windows box. I'm trying encryption using the CLI for PHP and gets the error: "Call to undefined function  mcrypt_module_open() in ...."

Running phpinfo (php.exe -r phpinfo();) in the cli does not show mcrypt as enabled. Viewing the same script thru the browser, however, shows mcrypt as enabled.

Please help me in enabling mcrypt in CLI.

Question by:SWB-Consulting
  • 3
  • 2
LVL 34

Expert Comment

by:Beverley Portlock
ID: 22909008
Mcrypt does not always install properly on Windows. Try copying libmcrypt.dll from your PHP root folder (presumably C:\PHP) to \Windows\System32

Author Comment

ID: 22909127
Thanks bportlock,

I tried this but still got the same error. I copied libmcypt.dll from my xampp\php to C:\Windows\system32 and restarted apache.

Any more thoughts ?
LVL 34

Accepted Solution

Beverley Portlock earned 2000 total points
ID: 22909611
Ensure that the CLI version can see php.ini or copy php.ini to the CLI folder. From what you report it seems like the CLI version is not loading the mcrypt module.

Author Comment

ID: 22910079
Hi bportlock,

Thanks You! I was finally able to make it work. The fact is, php cli in xampp has a separate php.ini file inside xampp/php where it gets the config from when using CLI. ( It usese the one in xampp/apache/bin when serving to a browser). Weird, huh ?

Nevertheless, I am giving you the points because you helped me find the solution.
LVL 34

Expert Comment

by:Beverley Portlock
ID: 22913659
Thanks for the comment. It's always nice to know .... good luck with whatever you're doing.

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 6 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question