Page 1 of 1
PHP + MySQL On Windows w/ IIS
Posted: Mon Sep 17, 2007 9:26 pm
by aliasxneo
Well I recently reformatted and have decided to sit down and go through the dreadful process of setting up PHP and MySQL with IIS. As usual I am running into problems that I can't seem to fix.
I have successfully gotten PHP 5.4 to work with ISS (Thank goodness) and can run scripts fine. I have also gotten MySQL 5 (latest version) installed and working correctly. The part I am having problem with is getting PHP to work with MySQL. So far I have done the following things:
1. Copied libmysql.dll from C:\Program Files\MySQL 5\...\lib to the main PHP directory
2. Overwrote the installed php.ini file in the core directory (C:\Program Files\PHP) with the php.ini-recommended
3. Edited php.ini and uncommented the line "extension=php_mysql.dll"
I am getting the following error with the following code:
Code:
Code: Select all
mysql_connect("localhost", "root", "password");
mysql_select_db("eve");
Error:
Fatal error: Call to undefined function mysql_connect() in C:\webpages\test1.php on line 1
Any idea on what I missed/am doing wrong? Thanks in advance.
Posted: Mon Sep 17, 2007 9:34 pm
by feyd
I would suspect PHP is loading a different initialization file. Run the following in a new file and tell us the results please.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>
Posted: Tue Sep 18, 2007 12:30 am
by aliasxneo
http://img231.imageshack.us/img231/6214/screentg2.jpg
I really don't understand it. As you can see I have the mysql uncommented, I'm editing the php.ini in C:\Program Files\PHP, the ext directory is the main directory, and php_mysql.dll is in the main directory. What am I missing?
Posted: Tue Sep 18, 2007 12:36 am
by timvw
Have you restarted your webserver after the editing?
Posted: Tue Sep 18, 2007 1:49 pm
by aliasxneo
timvw wrote:Have you restarted your webserver after the editing?
Yes, and restarted my computer.
Posted: Wed Sep 19, 2007 1:29 pm
by Doug G
Run phpinfo() and see where the php binary thinks php.ini is located. I recently did a manual installation of php on W2003 and had to put php.ini in c:\windows, apparently the distributed binary was compiled to use that location.
Posted: Wed Sep 19, 2007 4:56 pm
by aliasxneo
Doug G wrote:Run phpinfo() and see where the php binary thinks php.ini is located. I recently did a manual installation of php on W2003 and had to put php.ini in c:\windows, apparently the distributed binary was compiled to use that location.
I did, check out the screenshot I posted, shows where it's loading php.ini from and it shows me editing php.ini and uncommenting the mysql extension.