0

I'm trying to run this simple script:

<?php

$PHP_PATH = "c:\Program Files (x86)\PHP\\";
$CLIENTPATH = dirname(__FILE__)."\Client.php";
$SERVER = "http://localhost:8080/mobile/Server";

$handle = popen("C:\WINDOWS\system32\cmd /C start ".$PHP_PATH." -f ".$CLIENTPATH." ".$SERVER, 'r');

?>

But I always get this Windows messagebox error:

Windows cannot find c:\program. Please make sure you typed the name correctly and then try again.

Searching on google I also find this thread about this error, but the meassures are I litlle drastic I guess.
So the problem its in my code ? Or there can be something else wrong ?

Thanks.

1 Answer 1

1

You need to escape the whitespaces in $PHP_PATH = "c:\Program Files (x86)\PHP\\";!

Sign up to request clarification or add additional context in comments.

4 Comments

and can u also tell me how ? I dont normally program in php , thanks
@vBx addcslashes($path, ' ')
@Linus Kleen: I did this addcslashes($PHP_PATH, ' '); after PHP_PATH, but still getting the same error
Ok. I'm spelling it out: $PHP_PATH = addcslashes($PHP_PATH, ' '). Optionally, you can enclose the path in quotes (i.e. popen("C:\... '".$PHP_PATH."' -f ...")).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.