简体   繁体   中英

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

Running Apache with PHP and mysql5 on a mac (snow leopard)...

Apache is running

PHP is running ( works fine)

mysql is running (can connect)

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

Make a phpinfo() page to see if you have working mysql support in php.

It will have a section called mysql, and the table header will be: mysql support | enabled. Otherwise it means your php installation has no mysql support. 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; eg a 32-bit mysql client library in a 64-bit apache installation (or the other way around).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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