简体   繁体   English

雪豹:致命错误:调用未定义的 function mysql_connect()

[英]Snow Leopard: Fatal error: Call to undefined function mysql_connect()

Running Apache with PHP and mysql5 on a mac (snow leopard)...在mac(雪豹)上运行Apache和PHP和mysql5...

Apache is running Apache 正在运行

PHP is running ( works fine) PHP 正在运行(工作正常)

mysql is running (can connect) mysql 正在运行(可以连接)

however, the following code is throwing an error但是,以下代码引发错误

$link = mysql_connect('127.0.0.1', 'user', '****'); 
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

Getting the following error:收到以下错误:

Fatal error: Call to undefined function mysql_connect() in /opt/local/apache2/htdocs/ajax_login.php on line 4致命错误:在第 4 行调用 /opt/local/apache2/htdocs/ajax_login.php 中未定义的 function mysql_connect()

Make a phpinfo() page to see if you have working mysql support in php.创建一个 phpinfo() 页面,查看 php 中是否支持 mysql。

It will have a section called mysql, and the table header will be: mysql support |它将有一个名为 mysql 的部分,表 header 将是: mysql 支持 | enabled.启用。 Otherwise it means your php installation has no mysql support.否则,这意味着您的 php 安装不支持 mysql。 Google a bit to learn how to set it up correctly...谷歌一下以了解如何正确设置它...

If you installed myqsl and apache/php / mysql-library independently, you could have made the mistake to mix different architectures;如果你单独安装了 myqsl 和 apache/php/mysql-library,你可能会犯错混合不同的架构; eg a 32-bit mysql client library in a 64-bit apache installation (or the other way around).例如,在 64 位 apache 安装(或其他方式)中的 32 位 mysql 客户端库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM