I'm painfully new to PHP, and was trying to set up phpBB on my local site. I have a stock debian install of apache2 and php5. The phpBB installer ran fine, connected to the database and created all its tables with no problem. But when I tried to open the login page, I got a 0-byte response.
我是PHP的新手,并试图在我的本地网站上设置phpBB。我有一个apache2和php5的股票debian安装。 phpBB安装程序运行正常,连接到数据库并创建其所有表没有问题。但是当我尝试打开登录页面时,我得到了一个0字节的响应。
A little digging showed that it was never making it past the call to mysql_pconnect(). The php binary just quits without error or message. Nothing at all. I tried running the following code:
一点点挖掘表明它永远不会超过对mysql_pconnect()的调用。 php二进制文件只是退出而没有错误或消息。什么都没有。我尝试运行以下代码:
<?php
$id = @mysql_pconnect('localhost','myusername', 'mypassword', true);
print "id=".$id."\n";
?>
and the "id=" string never prints. It just does nothing. I don't know where to look to see what error happened, or what is going on at all. All i've installed is "mysql" using pear... perhaps I'm missing something else?
并且“id =”字符串永远不会打印。它什么都不做。我不知道在哪里可以看到发生了什么错误,或者发生了什么。所有我安装的都是使用pear的“mysql”...也许我错过了其他的东西?
This has got to be a path problem somewhere. The mysql extension is built nicely at
这必须是某个地方的路径问题。 mysql扩展很好地构建了
/usr/lib/php5/20060613+lfs/mysql.so
Answer:
jishi: informed me that the "@" operator suppresses output, including error messages (@echo off, anyone?)
jishi:告诉我“@”运算符会抑制输出,包括错误消息(@echo off,any?)
tomhaigh: extensions must be explicitly enabled in php.ini file. After adding the line "extension=mysql.so" to php.ini, the following code runs fine:
tomhaigh:必须在php.ini文件中显式启用扩展。将行“extension = mysql.so”添加到php.ini后,以下代码运行正常:
% cat d.php
<?php
ini_set('display_errors', true);
error_reporting(E_ALL | E_NOTICE);
$id = mysql_pconnect('localhost','myusername', 'mypassword', true);
print "id=".$id."\n";
?>
% php -c /etc/php5/apache2/php.ini d.php
id=Resource id #4
JOY!
5 个解决方案
#1
1
try doing this:
试着这样做:
<?php
ini_set('display_errors', true);
error_reporting(E_ALL | E_NOTICE);
$id = mysql_pconnect('localhost','myusername', 'mypassword', true);
print "id=".$id."\n";
?>
and see what the response is
并看看响应是什么
edit
From your comment it looks like the mysql module is not installed or enabled. You could have a look in your php.ini file and see if there is a line like
从您的评论看起来似乎没有安装或启用mysql模块。你可以查看你的php.ini文件,看看是否有像这样的行
extension=mysql.so
If it is commented with a semi-colon, try removing it and restarting apache
如果用分号评论,请尝试删除它并重新启动apache
#2
6
Just noted that you're using a @ in front of mysql_pconnect(). That suppresses all errors, which in this case is a pretty bad idea. Remove that and you would probably see the output.
刚刚注意到你在mysql_pconnect()前面使用了@。这可以抑制所有错误,在这种情况下这是一个非常糟糕的主意。删除它,你可能会看到输出。
Otherwise:
Check your php.ini, should be in /etc/php5/apache2/php.ini for debian.
检查你的php.ini,应该是/etc/php5/apache2/php.ini中的debian。
Check for a line called display_errors, set that to true if you want error-output in your browser (not recommended for a production-system, but is useful during debugging and development).
检查名为display_errors的行,如果要在浏览器中输出错误,则将其设置为true(不建议用于生产系统,但在调试和开发期间非常有用)。
Specify log_errors on for apache to log your errors to apaches error logfile, which by default in debian would be (unless other error-file is specified for the phpBB-site):
为apache指定log_errors以将您的错误记录到apach错误日志文件,默认情况下在debian中将是(除非为phpBB站点指定了其他错误文件):
/var/log/apache2/error.log
#3
1
Remove the "@" That is muting the error messages that mysql_pconnect is throwing.
删除“@”即可将mysql_pconnect抛出的错误消息静音。
#4
0
I sometimes have PHP going down a 'black hole' when it finds a function that it can't find.
当我找到一个无法找到的功能时,我有时会让PHP陷入“黑洞”。
Can you verify that the mysql extension is installed correctly?
你能验证mysql扩展是否正确安装?
You can do this by creating a php page like this:
您可以通过创建这样的php页面来完成此操作:
<?php
phpinfo();
?>
Saving it in your webroot, and then accessing it. It should contain all the information about what your server is currently running in terms of PHP modules.
将其保存在您的webroot中,然后访问它。它应包含有关PHP模块方面当前运行的服务器的所有信息。
#5
0
I think you have no mysql extensions installed for your PHP. Since PHP5 I think it is a PECL extension. If you are working on windows, there should be a pecl.bat or something like this in your php directory. Just go there via console and enter
我认为你的PHP没有安装mysql扩展。从PHP5开始,我认为它是PECL扩展。如果您正在使用Windows,那么在您的php目录中应该有一个pecl.bat或类似的东西。只需通过控制台进入,然后输入
pecl download mysql
Then everything should work as expected.
然后一切都应该按预期工作。
#1
1
try doing this:
试着这样做:
<?php
ini_set('display_errors', true);
error_reporting(E_ALL | E_NOTICE);
$id = mysql_pconnect('localhost','myusername', 'mypassword', true);
print "id=".$id."\n";
?>
and see what the response is
并看看响应是什么
edit
From your comment it looks like the mysql module is not installed or enabled. You could have a look in your php.ini file and see if there is a line like
从您的评论看起来似乎没有安装或启用mysql模块。你可以查看你的php.ini文件,看看是否有像这样的行
extension=mysql.so
If it is commented with a semi-colon, try removing it and restarting apache
如果用分号评论,请尝试删除它并重新启动apache
#2
6
Just noted that you're using a @ in front of mysql_pconnect(). That suppresses all errors, which in this case is a pretty bad idea. Remove that and you would probably see the output.
刚刚注意到你在mysql_pconnect()前面使用了@。这可以抑制所有错误,在这种情况下这是一个非常糟糕的主意。删除它,你可能会看到输出。
Otherwise:
Check your php.ini, should be in /etc/php5/apache2/php.ini for debian.
检查你的php.ini,应该是/etc/php5/apache2/php.ini中的debian。
Check for a line called display_errors, set that to true if you want error-output in your browser (not recommended for a production-system, but is useful during debugging and development).
检查名为display_errors的行,如果要在浏览器中输出错误,则将其设置为true(不建议用于生产系统,但在调试和开发期间非常有用)。
Specify log_errors on for apache to log your errors to apaches error logfile, which by default in debian would be (unless other error-file is specified for the phpBB-site):
为apache指定log_errors以将您的错误记录到apach错误日志文件,默认情况下在debian中将是(除非为phpBB站点指定了其他错误文件):
/var/log/apache2/error.log
#3
1
Remove the "@" That is muting the error messages that mysql_pconnect is throwing.
删除“@”即可将mysql_pconnect抛出的错误消息静音。
#4
0
I sometimes have PHP going down a 'black hole' when it finds a function that it can't find.
当我找到一个无法找到的功能时,我有时会让PHP陷入“黑洞”。
Can you verify that the mysql extension is installed correctly?
你能验证mysql扩展是否正确安装?
You can do this by creating a php page like this:
您可以通过创建这样的php页面来完成此操作:
<?php
phpinfo();
?>
Saving it in your webroot, and then accessing it. It should contain all the information about what your server is currently running in terms of PHP modules.
将其保存在您的webroot中,然后访问它。它应包含有关PHP模块方面当前运行的服务器的所有信息。
#5
0
I think you have no mysql extensions installed for your PHP. Since PHP5 I think it is a PECL extension. If you are working on windows, there should be a pecl.bat or something like this in your php directory. Just go there via console and enter
我认为你的PHP没有安装mysql扩展。从PHP5开始,我认为它是PECL扩展。如果您正在使用Windows,那么在您的php目录中应该有一个pecl.bat或类似的东西。只需通过控制台进入,然后输入
pecl download mysql
Then everything should work as expected.
然后一切都应该按预期工作。