View Full Version : Newbie - Can not get PHP to connect to SQL

08-17-2005, 10:25 PM
Hi people

I am very new to this, and sorry if my question sounds stupid.

I am trying to get PHP works with MYSQL, but I recive error message:

Fatal error: Call to undefined function mysql_connect()

I am using: WinXP, PHP Version 5.0.4, MYSQL 4.1 and Apache 1.3.33.

Take look at my 2 files:


$db_host = "localhost";
$db_user = "php" ;
$db_password = "f00";
$db_name = "lagerdb";


require ($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_password)
or die ("error connection");
echo "Connection made";

I really hope someone out there can help me out.

PS: I followed this instruction from this link without luck: http://www.dbforums.com/t1044828.html

1. Make sure that you have a valid php.ini in your windows directory.
OR (Per the tut the 'php.ini' can be installed in the 'C:\Program Files\Apache Group\Apache2' folder. This works fine.)

2. copy libmysql.dll to the system32 directory (php_mysql.dll would not load without doing this)

3. set the extension_dir in php.ini to the ext directory of your PHP installation directory (like e.g. extension_dir=C:\php5\ext)

4. enable the MySQL extension in php.ini by uncommenting the line extension=php_mysql.dll

5. Restart Apache Server



08-19-2005, 11:09 AM
Just for the information;

- The solution in my situation was to copy PHP.INI file into Apache main folder. AND WIPS, IT WORKED! :) And do follow this instruction as well: http://www.dbforums.com/t1044828.html

I am happy now

Best regards,