I have searched everywhere for the answer but cant find any reference anywhere
i am building a local database and like to include a page that shows a piece of software that will be installed on windows is there away so show this such as a iframe.
sorry if this question is very vague but i am not sure what this would be called.
There will be no interaction within php to the application and the server is ran of the same windows machine.
it is not possible.
what you can do, and only if the software supports it, is to send arguments by the command line using exec function and show the user the response.
exec("path/to/software.exe -argA -argB",$result,$error);
var_dump($result); //<--the software response.
Related
Introduction
Before getting started with the actual question, I’d like to make a notice of being an extreme beginner to the world of web sockets using PHP. As a matter of fact, I’m still trying to grasp the very basics of it. I do however have lots of experience with sockets overall, from languages such as Java.
Upon doing my research, I stumbled upon the tutorial from PHP builder, whereas I think myself to having learned how to set socket connections up using this simple library.
Problem
Unto the problem we go. For a development server, I have chosen to go with XAMPP—it’ss sort of stayed with me from my Windows days, many years ago. At this very moment, I am using the terminal UI for XAMPP in Ubuntu—meaning, I launch the XAMPP server and then do a killall should I ever wish to close it.
In the tutorial mentioned above, you enter this information into your PHP document where you keep your server socket:
$server = new Server('192.168.0.8', '8000');
The Server class being a class extended by the WebSocketServer provided in the aforementioned library. You’re then supposed to run the PHP server socket using (with the dollar sign symbolizing terminal input):
$ php -q serversocket.php
It was suggested somewhere else on Stackoverflow that you run the server socket with the -f flag instead, but both of them—instead of starting the server socket—prints out the file contents in the terminal.
The PHP I’m using (to attempt running the server socket) is the one you get from running (on Ubuntu):
$ sudo apt-get install php
I’d assume this to be the regular version of PHP.
I’m honestly probably just being a huge moron, but truly do need help to solve this problem. Have I missed something?
The problem that was occurring at the time was the PHP code being displayed as raw data in the terminal whenever run. I was using short opening tags at the time <? and did have them enabled in the configuration.
I did however, resolve the issue, by rewriting the code to use the full opening PHP tags <?php. Perhaps there was more things to configure, maybe the version of PHP I was using was broken. Who knows?
I'm trying to update a site that's using php. I built the site and tested it on this machine. But today, the Php won't run on my local machine.
To test, I went back to the most basic php page I have:
<?php
phpinfo();
?>
When I navigate to this file, in Firefox (28), the result is a blank page. (The page source shows just my code.) In IE 11, I'm asking whether I want to open or save the file.
Searching for my original problem (which was that my php code was showing up rather than running), it was suggested that php wasn't installed. I don't know how it would have gotten uninstalled, but I went ahead and installed it again (from http://www.microsoft.com/web/platform/phponwindows.aspx) and still no joy.
Windows 7 SP1
Updates in response to suggestions:
Pardon the beginning stuff, but I'm not primarily a web developer. (I do databases.) This is stuff I'm doing for an organization I'm involved in. I don't actually remember having installed/configured a web server in the first place, nor do I remember having installed php before yesterday (though maybe my son did that for me).
After seeing the replies here, I followed the instructions on this page: http://webmasterjuice.com/how-to-activate-built-in-web-server-windows, but I'm still seeing the same thing.
Update:
I've confirmed that IIS is running and the php was installed. I've followed instructions I found online for getting php working in Windows 7 with IIS. However, it still doesn't make sense to me to have to do this. I'm sure I didn't do any of this when I started working with php. I'm not trying to use my computer as a web server. No interest in working through localhost.
I'm creating the file in a simple web-oriented editor (Crimson Editor). Until recently, I could use the editor's preview function on a file, whether HTML or PHP, and it would run correctly. I'm baffled as to why this stopped working.
A few things to look for:
It's php running besides been installed? (obvious, but maybe it got killed by some reason)
Have you included the phpinfo() call inside a html document?
Obviously you named the file with a .php extension and saved it within the document root of the server..?
This may sound a bit strange but I need this to happen like this for a reason.
I need python to be able to post data to a local PHP file on a linux server and then get a response from the PHP.
I have tried this:
p = subprocess.Popen("curl --data 'param1=value1¶m2=value2' /home/hbmukwm/temp/receive.php", shell=True, stdout=subprocess.PIPE)
reply = p.stdout.read()
But when I do this, as it's a local file I get this curl error: curl: (3) malformed
I also tried it this way (found on a stackoverflow answer)
mydata=[('one','1'),('two','2')]
mydata=urllib.urlencode(mydata)
path='file:/home/hbmukwm/temp/receive.php'
req=urllib2.Request(path, mydata)
req.add_header("Content-type", "application/x-www-form-urlencoded")
reply=urllib2.urlopen(req).read()
But in this case I get the php response as plain text like I'm just trying to read the PHP file, again I think this is happening because the PHP file is local, like this:
<?php echo "test"; ?>
Rather than just
test
Hope this is making sense so far. All I need to do is POST the data to the local PHP file, and then get the PHP response back to python... Is this possible...
Any response is highly appreciated, sorry for my ignorance!
Thanks everyone for your responses, I have learnt something at least! The reason I wanted to have it as a local file is because I didn't want the PHP files to be publicly accessible, though data needed to be sent to them from any location the application was run. So my idea was to create a small python application that runs on a port on the linux server that takes commands and passes them to the PHP files local to the server.
Anyway, the way I have got this working is by using a command line (Like my first example) except using:
p = subprocess.Popen("php /path/to/file 'data=this'", shell=True, stdout=subprocess.PIPE)
And then in the PHP files grabbing the argument like this
$data = $argv[1];
This isn't posting the data to the PHP files like I initially was asking for but I guess I mis-understood what I needed to do. So thank you for all your help guys! I can't really figure out which one of your answers was the definitive answer because you were all correct in what you said, but the answer I am posting now is how I overcome the problem.
Thanks again guys, Stack Overflow is the best :)
You need a web server to run PHP code. You can't just refer to it as a filesystem location. I recommend that you install [WML]AMP web server bundle on your machine which will install Apache, PHP, MySQL and it's easy to setup and configure for beginners. Here are the links for the AMP family. Use the one that
Windows : WAMP
Linux: LAMP
MacOSX: MAMP
You will need a web server to actually parse and interpret the PHP scripts. However, in case you want to do it via the command line this page should give you some details:PHP Command line usage. You have not mentioned which version of PHP you are using, however this appears to be supported since PHP 4.3.0
I guess it is a matter of taste, but I am using "xammp" from www.apachefriends.org
You can easily setup a webserver from there with php5, sql and so on. Wit BitNami you are also able to easily install joomla and other stuff.
I'm creating a PHP script in other to automate a browser performance test. One of the key features is to be able to enable / disable a plugin in Internet Explorer or Firefox.
Reading about it online, I saw I have to execute a similar command to :
[HKLM\Software\Microsoft\Internet Explorer\Extensions\{6D53EC84-6AAE-4787-AEEE-F4628F01010C}]
“Flags”=dword:00000001
In otehr to accomplish what I need. However, my question is: how can I accomplish that through PHP? I thought about using exec('cmd') but I'm not sure whether that's the correct way.
Does someone have done that before? The script is local only, and always going to work on Windows environment.
Thank you
Obviously, you can only do this running a PHP script locally on a Windows machine, it is not possible* to modify the Windows Registry of some other machine that just sends a request to a PHP script on your server.
But you should be able to run exec in order to change the local machine, some quick googling returned how to delete and add registry keys from the command line which seems promising.
Something like:
<?php
// Write the value you want to save to a .reg file
exec('reg import tweakExtension.reg');
?>
Ought to work. A little more instruction on using the reg command can be gleaned by running reg /?.
* we hope...
Do I need a special library to run PHP on Windows environment Vista?
I can write simple message like echo "hello" but whenever I try to run any these scripts no error nothing display on the page http://php.net/manual/en/function.crypt.php.
I'm new to PHP please help
When in doubt...
<?php echo phpinfo(); ?>
If that code outputs information regarding your PHP version and settings, PHP is installed correctly.
There would be errors in your code if nothing is displaying. Post the code you are having trouble with and we can help you out.
Have you actually set up a local server? You'll need this to run PHP scripts. For a newbie I'd recommend WampServer since it's really easy and handles all the complexity of installing a server. Once installed and running, try http://localhost/ in your web browser.
Based on your comment though, I think the problem is that the sample code on the page you posted won't work on their own, you'd need to combine them with other things. For example the first one references a variable $user_input which you'd replace with a variable taken from user input (eg a form) on your site.
I suggest finding some tutorials online (or buy a book) and walk through various proper examples to familiarise yourself with PHP.
Do you have PHP / Apache installed at the moment? If you don't, try XAMPP. It comes with an easy and convenient installer.
Like most languages your computer must have the language/compiler installed in order develop and run scripts/applications. PHP was originally designed for web development so you won't usually find it installed on PCs by default.
The easiest way to develop PHP is to upload the scripts to a web server that has PHP installed and then test in your browser in the same fashion that you'd test an HTML page.
Otherwise to do it locally on your computer you can install a web development environment which acts like a web server. Essentially eliminating the upload step.
I believe the most popular for Windows is Wamp Server