Forum Moderators: coopster
win xp sp2
Apache2 up and running
php 5.1.1
apache to php connection:
the apache httpd.conf file contains
LoadModule php5_module "C:\php\php5apache2.dll"
<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
Action application/x-httpd-php "/php/php-cgi.exe"
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
SetEnv PHPRC C:/php
PHPIniDir "C:\php\"
So apache knows about the php setup.
php to mysql connection
mysql is running at port 3306 - via mysqld --console
There is a root user which can connect to mysql via "mysql".
php.ini is present in c:\php and it contains:
extension_dir = "c:\php\ext"
extension=php_mysql.dll
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
So Apache knows about php, and php knows about mysql
Now, apache is up and mysqld is up.
When I run this script to connect to the database,
<php
$username = "<whatever>";
$password = "<whatever>";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to Mysql");
print "Connected";
?>
I get the error
Fatal error: Call to undefined function mysql_connect() in D:\htdocs\mysql.php on line x
which means that php is not able to identify the mysql extension.
What do I need to do?
libmysql.dllis included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows [php.net]" for information on how to do this. Although copying
libmysql.dllto the Windows system directory also works (because the system directory is by default in the system's PATH), it's not recommended.
Resource: MySQL Functions [php.net]
[webmasterworld.com...]
we have Our Own Tutorial! [webmasterworld.com]
did you copy the MySQL DLLs releated to the root of apache2?
The mysql dll's are currently located at
c:\php\ext
and
c:\php
but that has no effect.
Should they present in any other location as well?
Sorry I didn't understand what is meant by "to the root of apache2" - Do you mean the
C:\Program Files\Apache Group\Apache2\bin
directory?
Or some other?
Thanks to everybody for the help.
Hope I'll be in a position to ask more questions now that I have the setup ready - and eventually be able to help others too.