[Sussex] FC5 - PHP not connecting to MySQL

Ronan Chilvers ronan at thelittledot.com
Fri May 5 07:30:22 UTC 2006


Hi Brendan

On Thu, 4 May 2006 20:43:41 +0100
"Brendan Whelan" <b_whelan at mistral.co.uk> wrote:

> I have a clean installation of Fedora Core 5 where PHP cannot connect
> to the MySQL database. phpinfo shows that PHP was built
> "--without-mysql" so I suppose that I have to rebuild PHP with :
> 
> ./configure --with-mysql
> make
> make install
> 

A few things:-

1. Exactly what error messages are you getting?  Can you post the error
output?

2. Check that mysql is running ( :-) )and that you can connect to it on
localhost with the mysql client, using the username and password you're
using in your scripts.

3. Do a phpinfo() page and check that the mysql extension is present.
I take it your built it in core rather than as a module?  Did the
configure script show that the mysqlclient libs were found and the
extension was enabled?

4. If all that passes, do something like this in a script:-

<?php
if (function_exists("mysql_connect"))
{
	echo "Yes";
}
else
{
	echo "No";
}
?>

and see what it comes back with.

When you're compiling PHP (or anything for that matter) you do
the ./configure, make, make install mantra in the root of the untarred
source tarball.  You can trap the configure output for
later review by doing something like this:-
	
./configure > configure.output &

which will dump the stdout of the configure script to configure.output
so you can flick through it to check everything is happening as it
should.

As far as the code being automatically there, it depends how you build
your extensions.  If you build them into the PHP core itself as you
seem to be doing, then yes, the extra functionality will just appear.
However, if you build them as modules then you need to explicitly load
them, usually in php.ini.  I always build everything as a module,
firstly because it avoids bloating the php core module and secondly,
because its easier to add and remove modules later (you just build the
module rather than having to compile php as well).

Building extensions as modules is easy - instead of 

./configure --with-mysql

you do

./configure --with-mysql=shared

which will create a mysql.so file in the installations module dir.

Cheers
-- 
Ronan
e: ronan at thelittledot.com
t: 01903 739 997

This email has been digitally signed using GNUPG to verify the identity
of the sender. Please see http://www.gnupg.org/ for further information.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20060505/4818726a/attachment.pgp 


More information about the Sussex mailing list