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!
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
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
Remove the "#" That is muting the error messages that mysql_pconnect is throwing.
Documentation
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.
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.
Related
Background:
I'm trying to get tweets from a specified username using PHP and OAuth. This example seems very useful. My problem is that my code doesn't return from the $feed = curl_init(); line near the bottom. There are no errors displayed, I only know that it stops because my debug statements after that line are not executed.
I didn't have cURL installed so I installed it on my Windows machine (using this example). It still doesn't produce any errors, it just leaves and never comes back.
Question:
How do I access cURL from my PHP program where I want to use it?
You need to download the windows php zipped manual installer from windows.php.net, the manual zip comes with all the extensions. Once php has been installed, enable the CURL extensions.. and any other extension that you need in the php.ini file. Copy the php-production.ini to %systemroot% directory and rename it to php.ini.
Hope that helps !!!
I have apache2 installed on my PC.
And php5 and all the stuffs.
The php is also running fine. I checked commands INSERT INTO myTable etc and it's working fine.
I've phpMyAdmin installed and it's also working fine.
The problem is that I'm not getting any error when there is actually error.
for e.g.
PHP :
<?php
<?php
$umair = 1
echo $umair;
echo 'asdf';
?>
This code isn't outputting anything. As you can see there is error of semicolon here and the PHP must show some error.
And if I put the semicolon then the PHP runs as usual and get the output 1asdf
Set your php.ini settings to display errors :
- error_reporting to E_ALL
- display_errors to on
(those are developement environment settings of course ; more about error_reporting levels here)
You can find your php.ini location using phpinfo() in a PHP script.
EDIT In case it isn't that, try to execute a valid script, and tell us if it runs correctly. If it doesn't, it probably means that your php module installation failed somehow.
EDIT 2 Restarting Apache will be necessary after editing such parameters.
You can try to show the errors for the current file that you're working on right now by adding
error_reporting(E_ALL);
and try to check this
The problem is that the missing ";" is a parser error - and parsing is done before execution.
PHP will simply not even start executing an invalid script - so you don't see anything.
Try to include this script in another script and run that - then you will get a clear error-msg!
Here's more on that topic and also my script to do this: How to get useful error messages in PHP?
I am attempting to install PHP onto Windows Server 2008 R2. I have followed the instructions here but when I try to load phpinfo.php I get a blank page.
There are no errors in the Event Viewer.
The server is used to host multiple other Asp.Net websites but I am using PHP so that I can install MediaWiki.
UPDATE:
When trying to load simple HTML (with no PHP) it also loads as blank. The fix for this seems to be to enable "Static Content" in the "Turn Windows features On/Off" manager - but this is already in place.
This happened to me as well just running the handy dandy php installer microsoft has on their site using their Web Platform Installer and it turned out in the php.ini file by default short_open_tag by default is off so my code
<?
print("hello world!");
?>
would not work because it was expecting
<?php
print("hello world!");
?>
.... so yea ... just go and change that if this is your problem too!
If copying over an old Wordpress installation from an old server - make sure you copy ALL the files. Oops... <embarassed>
A blank page is also possible when there is an PHP error and error reporting is of. Try to run the script below to see what happens.
<html>
<body>
Hello HTML
<?php
error_reporting(E_ALL);
echo "Hello PHP";
?>
</body>
</html>
You could also try to see if a normal HTML page with PHP extentions runs fine. Perhaps your server is setup to disallow PHP extention.
You have to configure fastCGI for each PHP website, more details you can find here - Best Practices for Configuring FastCGI and PHP
So I found the solution after hours of randomly trying things. I removed and re-added the Static Content role in Windows - still same result. Then I edited the Error Pages feature of the website in IIS to say return Detailed Error Messages. At this point PHP started to complain about the timezone so I set to "Europe\London" - for this to take effect you need to restart IIS.
After that it worked, phpinfo now loads!
I had this issue; at "turn Windows features on or off", I enabled:
HTTP Errors
Server-Side Includes
Directory Browsing
Windows Authentication
I also set these options in C:\Program Files (x86)\PHP\v5.3\php.ini:
display_errors = On
display_startup_errors = On
After that, a 401 Unauthorized error was displayed. I added 'Everyone' and 'Users' groups to the folder to fix.
I'm trying to get xdebug working on my Mac. I'm using OS 10.6 with the built-in versions of Apache (2.2.1) and PHP (5.3.8). I followed the "tailored installation instructions" on the xdebug website, which basically consisted of these steps:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Restart the webserver.
From what I understand, that should be it. I know most people use xdebug with an IDE like PHPEclipse, but it doesn't sound like that's necessary just to get debugging output on the page. And a lot of old instructions involve installing MAMP, but it looks like that's no longer necessary.
Signs xdebug is working: When I run php -m and phpinfo() I get the expected information on xdebug. In scripts I'm able to call functions like xdebug_is_enabled() (returns 1) and xdebug_get_function_stack() (returns the stack).
Ways xdebug is not working: The main reason I installed xdebug was to get a stack trace when there's an error, and that's not happening. According to this documentation page, I should get a stack trace as long as display_errors is set to On in php.ini, (which it is). I've tried code that should evoke a warning (e.g., echo(hello)) as well as code that produces a fatal error (e.g., $x->awesomefunction() when $x isn't an object). Neither one produces any xdebug output, and the fatal error just causes the page to die silently. The test code given in the documentation I linked to also produces nothing.
UPDATE: It turns out that if I run a script with a fatal error from the terminal, I do get a stack trace from xdebug. However, it's still not showing up when I run the script from a browser
Also, regular error reporting is now broken: Previously, I'd get error output by including the commands:
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
Now, putting those lines in my script doesn't produce any error reporting either. (in the browser. It does cause errors to be shown when I run the script from the terminal.)
So, what's wrong here? Did I leave something out of the xcode installation? Do I have a setting hanging around somewhere else on my system, suppressing errors? I've tried everything I can think of, but I'd be happy to test any ideas you have.
If it is working on console and not on browser, it's probably a xdebug configuration issue.
I'm not a Mac user, but on Ubuntu there are 2 different php.ini files, one for console and one for apache. If that's the case for Mac also, you can check if xdebug is enabled and properly set up in both php.ini files.
Also you can check the xdebug settings mentioned in the guide.
After several more hours of thrashing, I discovered that one of my test files actually was including another file that set display_errors to 0. The other test file was straight off of the xdebug site, but I think that at the time I was using it I'd introduced some other config error that prevented it from working properly. I'm truly embarrassed! Let this be today's object lesson in the importance of systematic, repeatable tests during debugging. On the bright side, xdebug is now working like a peach.
To summarize, the series of steps that worked was:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Add to php.ini: display_errors = On
Restart the webserver.
UPDATE (5/21/2010) SUCCESS!
So after MUCH $head->desk()'ing, I've solved it.
Remember kids, be wary of the instant client version you use, dependent on the virtualization settings!
I had been installing the generic Instant Client (not aware our ESX servers sit on AMD processors, not Intel) and that worked fine internally (the CentOS install was 32-bit since our internal ESXi servers aren't 64-bit). Well lo-and-behold, even if you have a 32-bit install running on a virtualized server which is sitting on an AMD64, it still matters what instant client you install.
It was the last thing I thought to check but as it appears, everything is running fine now.
I would like to thank everyone who helped me run through every possible test to figure this out but in the end, it was my fault for not realizing the differences in the virtualizations.
UPDATE (5/21/2010)
I thought this bug had escaped me when I installed it on a new VM internally but I have now found a narrowing link.
I was trying to install this on our production server when I posted this. After a week of no progress and in need to get back to development, I outfitted a VM on our internal server with a brand new install of Crap... CentOS, and fresh installs of instant client and oci8.
Worked perfectly.
However we just uploaded an exact copy of the VM to our production servers and it magically no longer works. Tried reinstalling everything, no avail.
So the only things I could narrow it down to is a firewall issue (although I get the same issue when trying 127.0.0.1) or possibly an ESX (our production servers) server issue, internal servers are running ESXi.
Any thoughts?
UPDATE (3/8/2010) I installed Xdebug and have it tracing my code. This is the output I am getting:
TRACE START [2010-03-08 17:53:05]
0.2090 327864 -> {main}() /data/aims3/http/octest.php:0
0.2091 327988 -> ini_set(string(14), string(1)) /data/aims3/http/octest.php:3
0.2093 327920 -> error_reporting(long) /data/aims3/http/octest.php:4
0.2094 328048 -> oci_connect(string(8), string(8), string(25)) /data/aims3/http/octest.php:6
The trace halts at that point.
I have installed everything the same way on a local server and it works fine. To say I am at a complete loss would be putting it lightly.
*NOTE: I ran make test and it returned FAIL on every test. I never ran this on my working machine to see if it reports the same errors. Any idea why make test would report FAIL but make doesn't report any error?
I've installed the Oracle Instantclient with no reported errors along with the OCI8 PECL package and at a loss. Whenever I try to open a connection with oci_connect, it halts my entire PHP script.
EXAMPLE:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
$conn = oci_connect("username", "password", "host");
echo "after";
?>
Returns a complete blank page. The module is loaded (seen in phpinfo) and everything installed with no errors.
I am at a complete loss.
CentOS: 5.4
Apache: 2.2.3
PHP: 5.3.1
InstantClient: 11.2
oci8: 1.4.1
Any thoughts?
NOTES
Apache Error Log reports nothing
Attempted Debugging:
1:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
echo "before";
if(!function_exists('oci_connect')) die('Oracle Not Installed');
echo "after";
?>
Returns:
beforeafter
2:
Changing host to //host
Returns:
Same error
Is there anything in Apache's error_log? Is this mod_php or FastCGI or normal CGI PHP? What happens if you run the script via the command line?
You could also try setting PHP's error log and looking in there.
EDIT1: Try:
echo "before";
if(!function_exists('oci_connect')) die('Oracle Not Installed');
And post the results...
EDIT2: I'm really not sure. My best bet is this info from the PHP manual:
The most common problem with
installing OCI8 is not having the
Oracle environment correctly set. This
typically appears as a problem using
oci_connect() or oci_pconnect(). The
error may be a PHP error such as Call
to undefined function oci_connect(),
an Oracle error such as ORA-12705, or
even an Apache crash. Check the Apache
log files for startup errors and see
the sections above to resolve this
problem.
Anyone else have any ideas to help out Bryan?
Bryan,
I am going to be honest: I tried this two years ago and failed miserably. :) I could not get the OCI functions to work for anything by compiling myself.
But in the interest of getting it done I looked for an alternate solution and found it in Zend Core for Oracle. All I did was download, run the installer, and it was done. It installs Apache/PHP, MySQL (optional), and the InstantClient for you.
Now as Zend Server, it is basically the same product. I realize that this may not be the solution you hoped for, but if it works...
Zend Server
are you connecting to remote or to local db? i think, for localhost you must replace "host" with "false". I hope, this will help you...
edit: i think, you are missing a parameter...my last suggestions are: 1. you must set the port (default 1521) AND/OR 2. You must enter db name AND/OR you must set the instance name (the ORACLE_SID parameter)
You never check the return value of oci_connect() or call oci_error() but it doesn't look relevant to your problem since you seem to be suffering from a PHP crash. There's an open bug for RHEL that may affect you too:
http://pecl.php.net/bugs/bug.php?id=16626
Did you build the oci8 package yourself? Are you using a third-party binary?
It has been fixed. See the top for details but here is the cliff notes: virtualiztion environments matter.