Page 1 of 1

php-switch.bat does not work on xp sp2

PostPosted: 20. April 2005 10:21
by hanpedro
I could not switch php5 to 4 with php-switch.bat.

my machine is xp sp2.

PostPosted: 22. April 2005 00:50
by prathapml
no idea what could be wrong with your machine.
I am on XPSP2, and the switching and paths-refreshing and all other functions work just fine.

Maybe giving detailed and deeper description of the underlying software environment, and the exact error noticed, could help us to help you.

Re: PHP Switch Does Not Work

PostPosted: 30. April 2005 13:40
by New10
I just installed Xampp on Windows XP Home Edition with SP2 installed.
The PHP switch will not switch from PHP5 down to PHP4.
The PHP-switch.bat always says "The Apache is running."
But, Apache is not running. I have even removed Xampp, rebooted, re-installed Xampp, and PHP-switch.bat still says Apache is running. I turn off Apache, and PHP-switch.bat still says Apache is running.

I note that this is a dual boot PC with Linux & Windows XP. When I boot in Linux and install Xampp, I can switch between PHP5 and PHP4 with no problem.

PostPosted: 02. July 2005 19:45
by MPeace
Hi,

I have the same problem, so what I tried was to change the following in instal/php-switch.php

Code: Select all
<?php

/*
#### Installer PHP  1.4 RC2  ####
#### Author: Kay Vogelgesang for www.apachefriends.org 2004 #### 
*/   

print "\r\n  ########################################################################\n
  # ApacheFriends XAMPP PHP Switch win32 Version 1.0                     #\r\n
  #----------------------------------------------------------------------#\r\n
  # Copyright (c) 2002-2004 Apachefriends                                #\r\n
  #----------------------------------------------------------------------#\r\n
  # Authors: Kay Vogelgesang <kvo@apachefriends.org>                     #\r\n
  #          Oswald Kai Seidler <oswald@apachefriends.org>               #\r\n
  ########################################################################\r\n\r\n";

$host="127.0.0.1";
$timeout="1";
if (($handle = @fsockopen($host, 80, $errno, $errstr, $timeout)) == true)


to this

Code: Select all
<?php

/*
#### Installer PHP  1.4 RC2  ####
#### Author: Kay Vogelgesang for www.apachefriends.org 2004 #### 
*/   

print "\r\n  ########################################################################\n
  # ApacheFriends XAMPP PHP Switch win32 Version 1.0                     #\r\n
  #----------------------------------------------------------------------#\r\n
  # Copyright (c) 2002-2004 Apachefriends                                #\r\n
  #----------------------------------------------------------------------#\r\n
  # Authors: Kay Vogelgesang <kvo@apachefriends.org>                     #\r\n
  #          Oswald Kai Seidler <oswald@apachefriends.org>               #\r\n
  ########################################################################\r\n\r\n";

$host="127.0.0.1";
$timeout="1";
if (($handle = @fsockopen($host, 80, $errno, $errstr, $timeout)) == "Hello")


And then ran the php-switch again, making sure that Apache was not running and it worked a treat. I am now able to switch between the two. be careful when swtiching I have made this quick fix because I am using osCommerce which doesn't work with PHP5 so I will not be switching.

Maybe adding in a "Are you sure Apache is not running statement would be a good idea instead of forcing the exit when the is port 80 open check is made."

PostPosted: 02. July 2005 20:19
by Wiedmann
That's really quick 'n dirty ;-)

We have a fix for this problem:

replace:
Code: Select all
$host="127.0.0.1";
$timeout="1";
if (($handle = @fsockopen($host, 80, $errno, $errstr, $timeout)) == true)
{
@fclose($handle);
echo "   The Apache is running! Please stop the Apache before make this procedure!\r\n";
echo "   Der Apache laeuft gerade! Bitte den Apache fuer diese Prozedur stoppen!\r\n";
echo "   PHP Switch exit ...\r\n\r\n";
exit();
}
else
{
@fclose($handle);


with:
Code: Select all
ini_set('default_socket_timeout', '3');
if (false !== ($handle = @fopen('http://127.0.0.1/', 'r'))) {
   fclose($handle);
   echo '   The Apache is running! Please stop the Apache before make this procedure!'."\n";
   echo '   Der Apache laeuft gerade! Bitte den Apache fuer diese Prozedur stoppen!'."\n";
   echo '   PHP Switch exit ...'."\n\n";
   exit;
} else {
   unset($handle);

PostPosted: 04. July 2005 15:08
by MPeace
Quick 'n dirty just like my woman :wink:

Thanks for the correction to my workaround :coughs: it works nicely.