5

I've seen this error in many places but the exact case. I got this error while running the cake bake console, exactly after choosing C " controller " then choosing the default database config

i'm on Ubuntu 10.10 through Virtualbox i'm using xampp - and installed the cakephp through the command apt-get install cakephp

here is the error

Use Database Config: (default/test) 
[default] > 
PHP Fatal error:  Call to undefined function mysql_query() in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 588

Fatal error: Call to undefined function mysql_query() in /usr/share/php/cake/libs/model/datasources/dbo/dbo_mysql.php on line 588
msheshtawy
  • 415
  • 4
  • 12
  • 17

4 Answers4

4

Your issue is more than likely that some Linux distros have different php.ini's for Apache PHP and and PHP-CLI, it appears that your PHP-CLI (which cake baker will use) doesn't have the mysql_* functions enabled.

To fix, you'll need to locate the php.ini for the PHP CLI and uncomment the line which includes the mysql_* lib. should be something like "extension=mysql.so". To find the location of php.ini, run php -r 'phpinfo();' on the command line and scroll to the top to see the location of php.ini.

Dunhamzzz
  • 14,682
  • 4
  • 50
  • 74
1

Reinstalling did the trick for me:

sudo apt-get remove php5-common
sudo apt-get install --reinstall php5-mysql
sudo apt-get install --reinstall php5-cli

(note: mine was not a live or system-critical php install - I was just trying to get phpsh working with some mysql code. ymmv.)

Mike McCabe
  • 1,015
  • 9
  • 9
0

Another thing people usually miss out is to set the path of extension directory itself.

For example, look at the ini file at another thread. He had already uncommented the line extension=php_mysql.dll but had not set the appropriate extension_dir.

You need this line to be uncommented or added in:

extension_dir = "ext"

where ext is the path to the extension directory.

Community
  • 1
  • 1
Pacerier
  • 86,231
  • 106
  • 366
  • 634
-1

I used Ubuntu 10.04 and 11.04 and faced the same obstacle which has been annoying for quite a while, since I want to use bake for certain solutions.

To fix it you can open a terminal and type here:

php -i | grep 'Configuration File'

which yields something like this:

Configuration File (php.ini) Path => /usr/local/lib

Well and surprisingly enough this is not the default path to keep you php.ini file, it is rather /etc/php5/cli/

Now you can simply copy your php.ini into /usr/local/lib or see how to fix the Configuration File Path.

I assume you have php5-pgsql (using postgres) or php5-mysql (using MySql) installed. Otherwise you might set your Configuration File Path in any way

Matvey Aksenov
  • 3,802
  • 3
  • 23
  • 45