Windows XP path problem - php

My Environmental Variables (& I crosschecked every possible place in the Registry) show my PHP include path as: "C:\PHP\" --and PHP (5.2.9-2) works fine on the system, so that is correct. However, running
ini_get("include_path")
shows the path as "C:\PHP5\". This causes problems with PEAR, etc. I've searched the system (i.e. php.ini files, httpd.conf, & everywhere else I can think of--there are no .htaccess files) & can find nothing that points at PHP5. Where in the world is this coming from??

Try searching for the literal PHP5 using a grep search tool (like windows grep http://www.wingrep.com/) it will take a while, but I think it's the best approach after you've checked all config files and environment variables.
Cheers

If you run a script with a call to phpinfo() PHP will tell you where the values come from:
<php
phpinfo();
?>
The top table will tell you what php.ini files it's reading and you'll find the value of the include_path directive in the Core table.

Something could be setting it using ini_set.
Or, after running the aforementioned grep on the whole system, you can try these:
Debug PHP to see what causes this.
Use Filemon from Sysinternals to see what files PHP is accessing.

This isn't really an answer to your problem however if you install WAMP or XAMPP you can usually avoid all of these annoying configuration issues.

Related

PHP session.save_path ignored

I was having problems with my PHP website (SuiteCRM) not being able to log users in and I found it was due to not being able to write on the sessions directory.
I am able to fix it by creating the directory /tmp/php_sessions and giving it write permissions for the Apache user www-data. I see the directory get populated with files as users log in.
However, Ubuntu Xenial is deleting my entire tmp directory on reboots, so I have to redo this all over again every time. I decided to move my save_path elsewhere.
After changing things in my php.ini file, and restarting Apache, I can check that they are effective by running this simple script:
<?php
echo ini_get("session.save_path");
phpinfo();
?>
This shows me a double confirmation of the new path, first echoing /var/tmp/php_sessions and then, in the middle of all the phpinfo information, showing the same value as both Local Value and Master value for directive session.save_path.
BUT the directory that php is using is still the first one, /tmp/php_sessions! It seems that my setting is being ignored.
Am I overlooking something? Where could that old setting be buried? Or how can I make the new one effective?
(P.S. - I am not using a redis handler as in another similar SO question)
Ok, I solved my own problem and the general answer is as follows:
There are two more things that can be changing the path and need to be checked,
the PHP code of the application might be changing the ini directive, search the code for ini_set(session.save_path
the PHP code might be using the session_save_path PHP command to override the ini. Search the code for that also (and notice the two underscores _!)
And the specific answer for my case was that SuiteCRM uses session_save_path command to set its path with a value coming from the file config.php found at the web root. That's where I found the old setting, and changing it solved my problem (for good, I hope).

setting "$PATH" variables for PHP in AMPPS (OSX)

I have a question about setting "$PATH" variables for PHP scripts in AMPPS
(On OSX 10.10 Yosemite).
The PHP in AMPPS seems to run as my user "danny", however the $PATH it sees
is different. Here's what I see from my terminal:
Dannys-MacBook-Air:AMPPS danny$ echo $PATH;
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
And here is what I get within a PHP script by printing out $_ENV:
["PATH"]=> string(29) "/usr/bin:/bin:/usr/sbin:/sbin" ["USER"]=> string(5)
"danny"
I tried doing "putenv()", tried doing "shell_exec" with a different $PATH,
I tried doing SetEnv in .htaccess and in the Apache config file. I tried
editing the systemwide /etc/.bashrc , and my users ~/.bash_profile. Neither
helped so far.
All I need is to have /usr/local/bin as part of my $PATH.
I know this is an older post, but this helped me, (doing this with Ampps, not MAMP, but it should work the same)
From here
Create a variable with the path to your PHP binary (in terminal)
they recommend
export AMPPS_PHP=/Applications/AMPPS/php/bin
mine was export AMPPS_PHP=/Applications/AMPPS/php-7.1/bin
then just
export PATH="$AMPPS_PHP:$PATH"
Test it out with which php or php -v
I don't know if it is even possible, but I wonder why do you need this, i.e. do you need really to change your PATH env variable? Or it would be enough to you using this function and setting the variabile only for the created process?
You can setup your Apache Server to run with your credential and resolve definitively the $PATH problem.
However, you can also do this and it should works :
<?php
putenv('PATH', getenv('PATH') . ';/usr/local/bin');
var_dump(getenv('PATH'));
?>
The modification of $PATH will still available only the duration of your PHP execution, there are other ways to set environment variable permanently
Hope that helps :)
This may not be well received, but I have been in your spot and have come close to throwing my machine across the room trying to properly set the PHP path for MAMP in OSX.
I started using Vagrant and developing from a VM, and found it to be way easier, especially if you want to change languages for other projects. Trust me, it will save you time in the long run.
Download VirtualBox
Download Vagrant
Select what type of box you want via PuPHPet
cd into the puphpet directory and run vagrant up (may take a while!)
The inital setup will take a little bit of time, but be very fast moving forward and makes it really easy to share environments with others.
Cheers
EDIT: I think its a very real solution for the future, but for now what worked for me was adding:
export PATH=/usr/local/php5/bin:$PATH to my .bash_profile
on OSX Yosemite. I believe the folder structure changed in Yosemite.

Is there a setting that allows php variables to be set in an included php script and then reused in the main file?

I have just checked out a project from an SVN and have tried to run the project on my local machine using WAMP and virtual hosts. I'm getting a lot of errors saying variables have not been declared and after further investigation have found that they are set in separate PHP files and then have been included into the page throwing the errors.
This works absolutely fine on live but not on my local which makes me think it must be a PHP setting. I've looked in the PHP.ini file but don't really know what I'm looking for.
There are two things I would like to know...
Firstly is there something I can adjust in my PHP.ini file to solve this and secondly, is it a good idea to have this setting(should there be one), as I have always worked with PHP variables, private to the page unless setting a $_SESSION variable.
Hope this makes sense to someone.
I should also mention I'm using windows and the server that runs the file is using Linux.
Thanks in advance
my guess is: your local and remote server have two different include paths set. you can check that by looking at the output of get_include_path()
then, check if paths are correct, you might want to check paths of these files
are they in the same directory? if no, are the paths in include relative or absolute? and how are the paths defined? these info will help you to get your answer. no php.ini setting can probably help you here.

How can I get apache to interpret <? lines as php lines?

I'm inheriting some html/php code.
I've installed apache and php on my windows box. At first, things sort of worked until I realized that php.ini is not being sourced. When I changed the path to the ini file to somewhere other than the "Program Files (x86)" dir, the file is sourced, but the code I'm running stops working.
The code has a bunch of places that say <? foobar ?> instead of <?php foobar?>
I tried googling for '<?' vs '<?php', but it ignored the <? parts.
What configuration do I need telling apache that <? means php?
you have to set short_open_tag = On in php.ini. However due to conflicts with XML this is generally seen as a bad idea.
It doesn't look like the best idea. What about creating a script to process the files searching for strings containing "<?" without "php" in order to correct them? Using regular expressions it shouldn't be hard.

PHP script not running on browser

I have installed XAMPP server on my system to be able to use PHP. But after installation, when I run any php script on the browser it does not run. I do not see any ouput. No checking the phpinfo() from local host I see that version 5.3.5 is installed
Even when running a a simple php file like where I echo a line;
I do not see anything on my browser. So, my question is do I need to make any configuration changes to my browser or system to get PHP running.
Put your scripts into /XAMPP/htdocs and then point your browser to: http://localhost/your_script.php
Your best bet is taking a look at your log files, and perhaps turning error reporting on. Put a simple script in your webroot that simply echo's a string, for example:
<?php echo "Hello World!";
with the above there is very little that can go wrong. Work from there. Take a look at your phpinfo, and see where your log files are located. Search for
error_log
for the path to your PHP error log file and maybe see if
display_errors
is on.
This is something that has a multitude of possibilities that can be the cause of your problem.
install phpxx-php which is used for creating dynamic web sites
check version of php using php -v
if you have php55 then use:
yum install php55-php.x86_64
Ensure to save file as .php ; e.g. index.php and not index.html
From Troublespy here are the reasons why php might not be working in the browser:
You did not download a local server
You are using the wrong version of php
You put your scripts in the wrong directory
You have a php error and the error didn't get printed
Your php code is wrong or incomplete
Make sure you check all reasons.

Categories