How can I run a PHP file from Within Visual basic

I have a VB6 Application  and a PHP application on 2 different PCs

I want to take a PHP script  (attached) and run it within the Visual Basic Code

My first thought was that since the PHP Script feels like an HTML  file

there may be a  way  to run it with the Shell command

Can any one help out with this

I attach the PHP Script


O.A.  Oluwole
Olukayode OluwoleSystems AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
Both PHP and VB are server side scripting languages.  You can't "run" a PHP file from VB.  You could convert the PHP code to VB.  Or, call the webpage that the PHP renders from VB (so that the server runs the PHP code and outputs the web page).  So, for example, launch/open http://localhost/index.php from VB

Which approach you take depends on your ultimate goal.  If you just want to display index.php, you can simply open the webpage like any other website from VB.  If you want to get results, etc that the PHP code provides and do something with them in VB, you'll need to convert the code to VB.
Ryan ChongSoftware Team LeadCommented:
Both PHP and VB are server side scripting languages.

this is somehow not true since VB6 Application is not really categorized as server side scripting languages.

To enable VB6 Application to call a html or php page, you can try:

VBA Web Requests
Julian HansenCommented:
A bit of misinformation going around.

PHP is a scripting language in its own right - which means if you have a PHP interpreter installed on your computer you can run a php script at the commend line like so
Script: test.php
echo "Hello World";

Open in new window

> php test.php

Open in new window

And you will get
Hello World

Open in new window

However in this case the php file provided is a web page - which means its output is going to be HTML most likely intended for a browser.

The script in question - the first thing it does is throw you to a login page because you are not logged in - so already you have a speed bump right there. For this page to do anything it
a) Needs access to a server SESSION - which you won't have when you run the file locally
b) That session needs to be primed with an empno value that will allow you to continue

So the question is really - what are you hoping to achieve here? What is it you actually want to do - because I don't think you are going to get the answer you want based on the information you have given us so far.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
To expand on Julian's answer.

You can easily hand off any file to it's processor - php/perl/python/bash - have each interpreter run the code + return data via STDOUT/STDERR.

And as Julian also said, the problem occurs when you're trying to manage sessions, as your code does.

To accomplish what you're trying to accomplish, you have to reverse your logic.

You'd likely run a LAMP Stack + then call Visual Basic to perform some functions, from your LAMP Stack, so your session is maintained correctly.

And, unless you've written this type of code repeatedly, there are many subtle problems you'll requiring handling.

Likely you'll save yourself a huge amount of time using WordPress + writing your code as a WordPress (PHP) plugin.

This will also mean your code will run anywhere.

If you use Visual Basic, you're stuck with a Windows runtime environment or trying to use one of the public domain interpreters which attempts to correctly parse + execute Visual Basic.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.