faqts : Computers : Programming : Languages : PHP : Installation and Setup

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

32 of 33 people (97%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

php_sam.php error

Jun 24th, 2007 13:30
escape code, Dennis Wickert,


(Quick answer to most PHP problems on Windows...don't use PHP's Windows
installer.  Install and configure manually via the zip package)

Problems:
   PHP files will not show up when running a PHP file in the 
browser. 
   All you get is a blank screen and Apache gives the following 
2 errors in your Apache error log

PHP Warning:  require_once(SAM/php_sam.php) [<a href='function.require-
once'>function.require-once</a>]: failed to open stream: No such file 
or directory in sam_factory on line 1

PHP Fatal error:  require_once() [<a 
href='function.require'>function.require</a>]: Failed opening 
required 'SAM/php_sam.php' (include_path='.;C:\\php5\\pear') in 
sam_factory on line 1

-----------------  Do some research ---------------

The problem has nothing to do with Apache per se, but with PHP.  Getting
PHP type error messages in your Apache log proves connectivity with your
web server to PHP, so we can rule out httpd.conf misconfigurations like:
   ScriptAlias /php/ "c:/php/"
   AddType application/x-httpd-php .php
   Action application/x-httpd-php "/php/php-cgi.exe"

If you drop to DOS/Shell and navigate to your PHP installed directory,
there should be an executable called PHP.exe.  If you execute a command
similar to the following, PHP should start to tell you where the problem is:
   echo "<?php echo 'hi'; ?>" | php

This command will error out telling which PHP extension did not load in
to PHP (I see php_sam.dll in my output)

---------------- Now the Answer -------------

Running the command above I got error messages similar to the ones at
the beginning of this answer.  The key is that I installed PHP via the
Windows installer.  If you manually installed PHP and modified the
default php.ini, you will notice a section with items like the following:
   ;extension=php_sam.dll
   ;extension=php_sdo.dll

What the installer did was leave those extension lines already in the
file AND put entries at the bottom of my php.ini that similar to the
following:
   [PHP_SAM]
   extension=php_sam.dll
   [PHP_SDO]
   extension=php_sdo.dll

So to fix th problem, you have to fix your php.ini.  The best way I
would suggest is remark out (put a semicolon) before ALL of your
"extension=" entries.  Then rerun the echo command that is entered above
in DOS/SHELL.  If you don't get errors in the console, then one by one
unremark the "extension=" entries that your need.

Now here is something interesting.  My problem was not with
php_sam.dll...exactly.  I did have a problem with php_threads.dll if I
had it load.

unloading extensions should get you up and running.  But don't forget to
make sure to set up the rest of you php.ini appropriately (some
extensions need variables set).  And if you are editing your php.ini
file, make sure that "short_open_tag = on" is set, if you program php
using "<?" instead of "<?php".

When your happy with PHP, restart your web server.