連接代碼
<?php
echo 'a';
$cn = mysql_connect("localhost",'你的mysql用戶名','你的mysql用戶密碼') or die(mysql_error());
if( $cn )
{
echo phpinfo();
}
else
{
echo 'mysql connect fail';
}
?>
因為服務器使用的是安全php.ini所在沒有錯誤顯示,於時相看了apache安裝目錄的logs的errors.log日志文
件發現如下錯誤
PHP Warning: PHP Startup: Unable to load dynamic library
'D:myserverphpextphp_mysql.dll' - xd5xd2xb2xbbxb5xbdxd6xb8xb6xa8xb5xc4xc4
xa3xbfxe9xa1xa3rn in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library
'D:myserverphpextphp_mysqli.dll' - xd5xd2xb2xbbxb5xbdxd6xb8xb6xa8xb5xc4
xc4xa3xbfxe9xa1xa3rn in Unknown on line 0
[Tue Dec 31 09:05:15 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 2, referer: http://localhost/
[Tue Dec 31 09:05:16 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 2, referer: http://localhost/
[Tue Dec 31 09:05:17 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 2, referer: http://localhost/
[Tue Dec 31 09:06:04 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
[Tue Dec 31 09:06:05 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
[Tue Dec 31 09:06:05 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
[Tue Dec 31 09:06:05 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
[Tue Dec 31 09:06:06 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
[Tue Dec 31 09:06:06 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined
function mysql_connect() in E:wwwa.php on line 3, referer: http://localhost/
日志中有這麼一句
PHP Startup: Unable to load dynamic library 'D:myserverphpextphp_mysql.dll' 這個意思是
沒有加載成功php_mysql文件了,還有一點是提示 PHP Fatal error: Call to undefined function
mysql_connect(),,這個是mysql沒有連接成功也就是加載mysql庫失敗了,根據分析有兩種可能一是文件不
存在,這個問題不存因為我以前用的是這個php解壓包,2是服務器環境變量問題,如果是環境變量有兩種解
決辦法
1,是直接在windows增加環境變量
2,直接把在d:PHP裡找到php5ts.dll,libmysql.dll將其復制到c:/winnt/system32下(winNT/2000的機器),
而winXP/2003是復制到c:/windows/system32下即可