Desparately trying to get php/apache to work with MYSQL

I’ve read just about every article and book I can lay my hands on, and yet still can’t get apache/php/MYSQL to work together. Tried so many combinations of advice and software versions and I’m so close but so far. The closest I’ve got so far is using the book “Build your own database driven website” by Kevin Yank v3. I have MYSQL v5.1, Apache v2.0 and php v5.2 installed. MYSQL is working, and Apache and php are working together, but I simply cannot get php to connect with MYSQL.

The configurations I created are exactly as Kevin described in his book apart from one, which through trial and error I realised made Apache and php not work together (page 9 of the book) - “AddModule mod_php5.c” which I was supposed to add to the Apache config. Everything else is exactly as prescribed.

Whatever changes I’ve made, when I’ve run a very simple program to connect to MYSQL such as the following, I always end up with the same error:

<html>
<head>
<title>My test</title>
</head>
<body>
<?php
mysqli_connect(“localhost”, “username”, “password”) or die(mysql_error());
echo “Connected to MySQL<br />”;
?>
</body>
</html>

Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Group\Apache2\htdocs\ est\ esting.php on line 2

So it seems like php is not connecting to the relevant MYSQL functions?

P.S. I did place the “libmysql.dll” in my system32 subfolder as directed as well, and made all the relevant changes to my php.ini file as directed…

Can anyone help? Please, before I go mad trying!!! :frowning:

Are you sure that you made the changes in the correct php.ini file as php.ini files breed like rabbits. If you run phpinfo() look for the value near the top for “Loaded Configuration File” as that is the actual php.ini file that is being used.

Thanks. Yes, I checked, and there is only one php.ini …

What server program are you using? A quick and easy fix would just be to install a very simple all-in-one server program such as XAMPP where everything is set up (I use XAMPP too).

http://www.apachefriends.org/en/xampp.html

That’s what I would have done from the start. Installing XAMPP or WAMP takes about 3 minutes and gives you a known working Apache/PHP/MySQL stack all configured to work with each other.

At this point, what you’re missing is the mysqli library…

Perhaps you can try adding “extension=mysqli.so” to your php.ini and restarting apache.

Many thanks to everyone for their suggestions. For others who might be interested (have similar problems), I took up the suggestion of installing XAMPP. After getting used to the interface and choosing to start Apache and MYSQL as part of my services (as Apache seemed to just drop everytime I started it from within the XAMPP interface), everything is now working perfectly!!! :slight_smile: Another happy camper.
FYI, using XAMPP to do a port check, I found that Skype uses port 80 as an alternative port for incoming connections. Killed this (which you can easily do via Options/Advanced/Connections). Everything works perfectly now. Just have to get used to phpmyadmin now, rather than command line interaction with MYSQL.

XamppLite, from the same source, takes up less disk space for a test server like this.

You still have the mysql client, and learning to write queries yourself is immensely more useful than learning someone’s PHP script.