Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using LAMPP with Ubuntu 64 bit. When I try to execute php file using terminal,undefined mysql_connect error is given.But everything works fine when I'm using browser to load my php file. I tried to edit the php.ini with remove the semicolon in front of then restart lampp,but with a error "unable to load dynamic library". What can I do to solve this problem? This is important for me because I need to run my php script using crontab.

Thank you.

PHP Fatal error: Call to undefined function mysql_connect() in /opt/lampp/htdocs/setrandomport-message.php on line 15

PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/ cannot open shared object file: No such file or directory in Unknown on line 0

share|improve this question

migrated from Nov 22 '11 at 22:38

This question came from our site for professional and enthusiast programmers.

closed as not a real question by Iain, mailq, Scott Pack, Ward, MDMarra Dec 7 '11 at 23:21

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you post the exact error message? – nickgrim Nov 22 '11 at 23:46
@nickgrim Thanks for your reply,I edit the question. – Irene Ling Nov 23 '11 at 0:06
That error message is for msql not mysql - they're different. – nickgrim Nov 23 '11 at 0:07
@nickgrim So what should I do now?I just having the "undefined mysql_connect" in terminal but not browser.. – Irene Ling Nov 23 '11 at 0:08
How did you install the php cli? – Zoredache Nov 23 '11 at 1:05
up vote 3 down vote accepted

So it sounds like you are confused because you have two separate versions of php.

You have the version that came as part of your lampp package in /opt/lampp/ and you have the php-cli that you installed via the package manager. The short answer is simply install the php5-mysql module via the package manager as well apt-get install php5-mysql.

You cannot mix and match modules between different versions of PHP. If you choose to have two separate installations, you must maintain them separately.

share|improve this answer
Thank you so much Zoredache. so now I have 2 seperate PHP...sorry I'm new in Ubuntu and PHP so I don't know much about I going to use one only(LAMP) for running in terminal and browser? – Irene Ling Nov 23 '11 at 5:11
@IreneLing My suggestion would be to keep the one you're using and uninstall the other. If you are unfamiliar with how to install/remove software on your chosen operating system refer to the vendor's instructions/support forums... – voretaq7 Nov 23 '11 at 16:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.