MySQL is running (I can connect to it from the command line), Apache is compiled with PHP 4.1.1 (the phpinfo() function works), and PHP is compiled with MySQL support and bc_math enabled.
I can not connect to the MySQL db via PHP code.
Here is the code:
$link = @mysql_connect("localhost","vet_anon") or die("Could not connect to MySQL server!");
Here is the error:
Fatal error: Call to undefined function: mysql_connect() in /var/www/conx_01.php on line 4
What's going on? I see this error mentioned in other postings, but no clear explanation in any of the replies 🙁
----notes about my configuration-------
1.
Here is my PHP compile command:
Command '../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=system' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--disable-debug' '--enable-memory-limit' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db2' '--with-iconv' '--with-ndbm' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--with-xml=/usr' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--disable-static' '--with-layout=GNU' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mm' '--with-mysql=shared,/usr' '--with-recode=shared,/usr' '--enable-xslt' '--with-xslt-sablot=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr'
2.
The user vet_anon does not require a password to connect successfully from the command line (so the lack of a password argument to the mysql_connect is not the problem).
3.
php's compile command has:
'--with-mysql=shared,/usr'
which is correct if this value should equal that of basedir
and wrong if it should equal datadir, in
/etc/mysql/my.cnf, which has:
basedir = /usr
datadir = /var/lib/mysql
4.
I thought that adding these values to php.ini might help:
mysql.default_port = 3306
; Default socket name for local MySQL connects.
If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/run/mysqld/mysqld.sock