如何在蛋糕烘焙控制台中修复此错误“PHP致命错误:调用未定义函数mysql_query()”

时间:2022-12-03 22:42:57

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

我在许多地方看到过这个错误,但确切的情况。我在运行蛋糕烘焙控制台时遇到此错误,正好在选择C“controller”然后选择默认数据库配置

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

我在Ubuntu 10.10上通过Virtualbox我正在使用xampp - 并通过命令apt-get install cakephp安装了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

4 个解决方案

#1


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.

您的问题很可能是某些Linux发行版对于Apache PHP和PHP-CLI有不同的php.ini,看起来您的PHP-CLI(蛋糕面包师将使用)没有启用mysql_ *功能。

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.

要修复,您需要找到PHP CLI的php.ini并取消注释包含mysql_ * lib的行。应该像“extension = mysql.so”。要找到php.ini的位置,请运行php -r'phpinfo();'在命令行上滚动到顶部以查看php.ini的位置。

#2


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.)

(注意:我的不是现场或系统关键的php安装 - 我只是想让phpsh使用一些mysql代码.ymmv。)

#3


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.

例如,查看另一个线程的ini文件。他已经取消注释了行extension = php_mysql.dll但没有设置相应的extension_dir。

You need this line to be uncommented or added in:

您需要取消注释或添加此行:

extension_dir = "ext"

where ext is the path to the extension directory.

其中ext是扩展目录的路径。

#4


-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.

我使用Ubuntu 10.04和11.04并遇到了相同的障碍,这一直困扰了很长一段时间,因为我想使用烘焙来获得某些解决方案。

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

配置文件(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/

嗯,令人惊讶的是,这不是保存php.ini文件的默认路径,而是/ etc / php5 / cli /

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

现在您只需将php.ini复制到/ usr / local / lib或查看如何修复配置文件路径。

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

我假设您安装了php5-pgsql(使用postgres)或php5-mysql(使用MySql)。否则,您可以以任何方式设置配置文件路径

#1


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.

您的问题很可能是某些Linux发行版对于Apache PHP和PHP-CLI有不同的php.ini,看起来您的PHP-CLI(蛋糕面包师将使用)没有启用mysql_ *功能。

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.

要修复,您需要找到PHP CLI的php.ini并取消注释包含mysql_ * lib的行。应该像“extension = mysql.so”。要找到php.ini的位置,请运行php -r'phpinfo();'在命令行上滚动到顶部以查看php.ini的位置。

#2


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.)

(注意:我的不是现场或系统关键的php安装 - 我只是想让phpsh使用一些mysql代码.ymmv。)

#3


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.

例如,查看另一个线程的ini文件。他已经取消注释了行extension = php_mysql.dll但没有设置相应的extension_dir。

You need this line to be uncommented or added in:

您需要取消注释或添加此行:

extension_dir = "ext"

where ext is the path to the extension directory.

其中ext是扩展目录的路径。

#4


-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.

我使用Ubuntu 10.04和11.04并遇到了相同的障碍,这一直困扰了很长一段时间,因为我想使用烘焙来获得某些解决方案。

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

配置文件(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/

嗯,令人惊讶的是,这不是保存php.ini文件的默认路径,而是/ etc / php5 / cli /

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

现在您只需将php.ini复制到/ usr / local / lib或查看如何修复配置文件路径。

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

我假设您安装了php5-pgsql(使用postgres)或php5-mysql(使用MySql)。否则,您可以以任何方式设置配置文件路径