Error when connecting to MySql via php4

I installed apache-ssl, php4 and mysql 3.23.49 using apt-get. They all work fine by themselves, and apache has no problem with the usual php functions, e.g. phpinfo(). But when I try to connect to mysql with a script using

mysql_connect("localhost", "root", "*") or exit();

I get the error message:

Fatal error: Call to undefined function: mysql_connect() in /var/www/htdocs/index.php on line 36

Then I tried:

apt-get install php4-mysql

but I still get the same error message.

Any ideas?? Thanks.

4 Replies

When you run phpinfo(), what do you get for "Configure Command" values? Sounds like you have php version in apache that don't have mysql built in.

Risto

Here's what I get from phpinfo():

'../configure' '–prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=php' '--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-unixODBC=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'

You can see it has '--with-mysql=shared,/usr' in there. Dunno if that's sufficient….

In your php.ini, have you load the mysql.so extension?

I compiled php manually and I have to load the extension manually in php.ini in order to get it work.

You should have a line like:

extension=mysql.so

in your ini file. Be sure to point the extension_dir to the dir where your extensions are located.

Hope this help.

Kevin

I was sure that I had already put the

extension=mysql.so

line in php.ini. But when I just checked it, it wasn't there. I must have forgot to save it…..hmmm. It works fine now. Thanks.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct