Page 1 of 3

Running PHP 5.1.2; MySQL installed, but not 'seen'

Posted: Fri Jan 05, 2007 7:15 pm
by lorikay4
Dear folks --

I am running PHP 5.1.2 on my local dev machine, running Windows XP and Apache/2.0.55 (Win32). The PHP part runs fine, and has for months. At the same time that I installed the PHP, I installed MySQL, back in April, but haven't used it at all, and want to use it now.

I can't figure out how to make PHP 'believe' that I have MySQL running. I did the PHP installation with a script from Zend, I am not a command line unix person, I'm a UI developer, and I can't figure this out AT ALL. I uncommented some lines in the PHP.ini file, such as:

extension=msql.dll

and

extension=php_mysql.dll

When I view the php test page, there is no section on MySQL, so I know that PHP is not 'seeing' it. Please help I am totally stuck.

Posted: Fri Jan 05, 2007 8:57 pm
by feyd
Did you restart Apache?

Posted: Fri Jan 05, 2007 8:59 pm
by lorikay4
Yes, every time.

When I view the test page that calls phpinfo(), it shows NO additional modules. Nada. None.

This is my extension_dir statement in the php.ini file:

extension_dir = "c:\php\ext"

should it not have quotes? I have tried it without, but am desperate.

Edited to add, that is the directory where all the extension .dll files are stored.

Posted: Fri Jan 05, 2007 9:08 pm
by feyd
Okay, so you've verified that the php_mysql.dll (and it's required libraries) are there?

Are you sure you're editing the correct php.ini? phpinfo() will list (near the beginning) where it found php.ini. If it lists your Windows directory and the file isn't there, it means it didn't find the file and is instead using defaults across the board.

Did you set the PHPIniDir directive in your httpd.conf?

Posted: Fri Jan 05, 2007 9:15 pm
by lorikay4
Check on the .dll files being located in c:\php\ext

Check on editing the version of php.ini that phpinfo is looking at.

After googling, I added these lines to my httpd.conf:

PHPIniDir "C:/php"
LoadFile "C:/php/php5ts.dll"

It already had:

LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php .php

which at least as far as running PHP went, worked fine, I've been making and running PHP pages locally since April with no problems.

Posted: Fri Jan 05, 2007 9:37 pm
by feyd
If you open up command line, change directories to the php folder and type

Code: Select all

php -r "var_export(get_loaded_extensions());"
does it show errors or do you find a screen looking like the following? (Don't worry if yours isnt' the same, but it should include mysql in there.

Code: Select all

array (
  0 => 'bcmath',
  1 => 'calendar',
  2 => 'com_dotnet',
  3 => 'ctype',
  4 => 'date',
  5 => 'ftp',
  6 => 'hash',
  7 => 'iconv',
  8 => 'odbc',
  9 => 'pcre',
  10 => 'Reflection',
  11 => 'session',
  12 => 'libxml',
  13 => 'standard',
  14 => 'tokenizer',
  15 => 'zlib',
  16 => 'SimpleXML',
  17 => 'dom',
  18 => 'SPL',
  19 => 'wddx',
  20 => 'xml',
  21 => 'xmlreader',
  22 => 'xmlwriter',
  23 => 'mbstring',
  24 => 'bcompiler',
  25 => 'bitset',
  26 => 'blenc',
  27 => 'bz2',
  28 => 'bz2_filter',
  29 => 'cpdf',
  30 => 'curl',
  31 => 'cvsclient',
  32 => 'docblock',
  33 => 'event',
  34 => 'exif',
  35 => 'gd',
  36 => 'gmp',
  37 => 'id3',
  38 => 'imap',
  39 => 'json',
  40 => 'lzf',
  41 => 'mailparse',
  42 => 'mcrypt',
  43 => 'mcrypt_filter',
  44 => 'memcache',
  45 => 'mhash',
  46 => 'mime_magic',
  47 => 'ming',
  48 => 'mysql',
  49 => 'mysqli',
  50 => 'oggvorbis',
  51 => 'openssl',
  52 => 'pdf',
  53 => 'PDO',
  54 => 'pdo_mysql',
  55 => 'pdo_sqlite',
  56 => 'phpdoc',
  57 => 'pop3',
  58 => 'runkit',
  59 => 'shmop',
  60 => 'smtp',
  61 => 'soap',
  62 => 'sockets',
  63 => 'SQLite',
  64 => 'ssh2',
  65 => 'svn',
  66 => 'timezonedb',
  67 => 'win32ps',
  68 => 'win32scheduler',
  69 => 'win32std',
  70 => 'xmlrpc',
  71 => 'xsl',
  72 => 'zip',
  73 => 'zlib_filter',
  74 => 'xdebug',
)

Posted: Fri Jan 05, 2007 10:45 pm
by lorikay4
I'm home now, will try this first thing Monday a.m. Thanks so much for your help.

Re: Running PHP 5.1.2; MySQL installed, but not 'seen'

Posted: Fri Jan 05, 2007 10:48 pm
by volka
lorikay4 wrote:I uncommented some lines in the PHP.ini file
Please use

Code: Select all

<?php phpinfo(); ?>
to check wether you've edited the right file.

Posted: Sat Jan 06, 2007 12:06 am
by lorikay4
volka, I've been doing that all along. I am quite sure that I've been editing the correct php.ini file.

my test file contains that command.

thanks, though.

Posted: Mon Jan 08, 2007 9:10 am
by lorikay4
Feyd, I do get a list like the one you show for the command you told me to try. And yes, 'mysql' is on the list. But when I view phpinfo() via my test page, it doesn't have ANYTHING listed under 'Additional Modules'. And mysql should be there, right?

Posted: Mon Jan 08, 2007 9:40 am
by feyd
That would suggest that your Apache loaded one isn't finding the php.ini that your command line is finding; the one you are apparently editing.

It may just be more simple to ditch trying to set these up yourself and use an installer package such as Xampp.

Posted: Mon Jan 08, 2007 10:20 am
by lorikay4
I was thinking of that, but I already have Apache and PHP running my local dev sites without any difficulties, and I don't want to screw them up. Also, I searched my hard drive again, and I don't find any other copies of php.ini, so I don't know where it would be coming from.

Posted: Mon Jan 08, 2007 10:28 am
by RobertGonzalez
Do you have a MySQL administration tool of any sort on your computer? If not, you can download MySQL administrator and query browser from the mysql site.

My suggestion would be to make sure that the database server is running and that you can actually connect to it from the client tool. Then I would check your version and make sure you are using at least version 4.1 of MySQL as PHP 5 will have loaded the new MySQL client API.

Also, can you 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');
}
$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: Mon Jan 08, 2007 10:45 am
by lorikay4
I was trying to install phpMyAdmin, and the test for whether IT had installed told me it couldn't see mySQL, which has lead me down this path of trying to understand whether PHP could tell I had MySQL installed or not.

The return from your file is as follows:

PHP Version: 5.1.2
PHP OS: WINNT
Error Reporting: 2039 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Loaded Extensions:
bcmath calendar com_dotnet ctype
date ftp iconv odbc
pcre Reflection session libxml
standard tokenizer zlib SimpleXML
dom SPL wddx xml
xmlreader xmlwriter apache2handler

As you can see, there is no MySQL in that list of loaded extensions. :-(

And as for this question:
My suggestion would be to make sure that the database server is running and that you can actually connect to it from the client tool.
I don't know how to make sure the database server is running, and I don't know how to connect to it from the client tool. Are there any EASY client tools out there that don't assume a ton of command line and config knowledge, with clear instructions for installation?

[/quote]

Posted: Mon Jan 08, 2007 11:19 am
by RobertGonzalez
Yes, there are. Download the MySQL GUI Tools from the MySQL website, install them and try to connect. Report back when you have done that.

Also, have you made sure to read this information from the PHP manual on installing the MySQL extension on Windows? You might also want to look into the mysqli extension as well.