tags:

views:

469

answers:

5

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.

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:

<?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?

This has got to be a path problem somewhere. The mysql extension is built nicely at

/usr/lib/php5/20060613+lfs/mysql.so

Answer:

jishi: informed me that the "@" operator suppresses output, including error messages (@echo off, anyone?)

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:

% 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!

A: 

I sometimes have PHP going down a 'black hole' when it finds a function that it can't find.

Can you verify that the mysql extension is installed correctly?

You can do this by creating a php page like this:

<?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.

Phill Sacre
+5  A: 

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.

Otherwise:

Check your php.ini, should be in /etc/php5/apache2/php.ini for 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).

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):

/var/log/apache2/error.log

jishi
+1  A: 

Remove the "@" That is muting the error messages that mysql_pconnect is throwing.

Documentation

MrChrister
A: 

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

pecl download mysql

Then everything should work as expected.

okoman
this command simply downloads "mysql-1.0.tgz" to the current directory. I tried "pecl install mysql" and get Skipping package "pear/mysql", already installed as version 1.0
David Dombrowsky
A: 

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

extension=mysql.so

If it is commented with a semi-colon, try removing it and restarting apache

Tom Haigh
Fatal error: Call to undefined function mysql_pconnect() in /usr/local/src/phpBB3/d.php on line 4
David Dombrowsky