Jul 24, 2008

Can Php Interact With A Visual Basic App On A Server

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Can Php Interact With A Visual Basic App On A Server

it01y2
I am currently making a game. And I want to use a command through php to ineract with a visual basic app on my server. Is it possible? and how?

Reply

ghostrider
I've been programming in VB for ten years, can you describe what you are trying to do with a little more detail? I think it is possible to do. PM me or post back and I'll help you out.

Reply

Plenoptic
I was pretty sure that only ASP can interact with Visual Basic which would mean no unless you have a Windows Server for your hosting that supports ASP. I don't know really though I'm still relatively new to Visual Basic. Last I knew though it was only ASP.

Reply

ghostrider
If what I think he is thinking about is right, its a simple enough concept. This is how I would approach it.

1. The PHP program writes some data to a file in some format.
2. The VB program constantly sees if a file is there for it to read.
3. The VB program processes it and puts the result back in another file.
4. The VB program deletes the original file. (so that the PHP program can create a new one later)
5. The PHP program opens the file the VB program wrote, and has the results.
6. The PHP program deletes the file.

Another way I could see this working is using a Winsock control in the VB program, and then using the socket functions of PHP to connect to it and process the request. This technique seems more practical now that I think about it. Here is how I would write this one.

1. The VB program is constantly listening for connections.
2. The PHP program connects to the IP address 127.0.0.1 (your computers IP) or localhost
3. The PHP program sends what needs to be done to the VB one.
4. The VB program returns the data and closes the connection.

The technique I wrote above seems more practical because it can handle multiple requests, instead of just one file. It probably is slightly faster (by a very small amount) because the computer doesn't need to write to the hard disk constantly.

The opposite, using VB and calling a PHP program can be done. I am currently writing a game that will use this technique for match making. It works like this.

1. You have a PHP program that does a certain function and accepts its data through GET

CODE

<?PHP
$variable = $_GET['mode'];
// if you have the url, http://www.whateversite.com/phpprogram.php?mode=1, the $variable = 1.
PHP?>


2. The VB program uses the Inet control, and sends the request.
3. The PHP program would output its result using the print() or echo() variable.


I hope this helps you guys out a lot. I'll be happy to guide you along and answer any other questions you have.

 

 

 


Reply

matak
You might find this question strange, but well, i'm a noob.. So it is possible to write programs in C, VB, put them on server and make them "work" and intereact to PHP ?!
Any good tutorials on that, or any good simple free programs that do the same? (open source possibly...)

Reply

QuickSilva
I also thought ASP was the only language that could interact with VB. I may be mistaken though.

Have a great day!

-Tom.

Reply

Galahad
ASP is written in a language that has BASIC as it's foundation...

Traditionaly, Microsoft IIS web server, was used to host ASP pages, and Apache was used to host PHP pages... There is a plugin (or module) for IIS and PWS that allows processing of PHP, but it's not that good, and it is very limiting in power, i believe PHP works only in CGI mode... Anyways, not to stray from the topic...

There are few ways to connect VB with PHP scripts...

Least efficient is through file, as ghostrider said... It's inefficient, since it consumes much CPU time, and thus we'll forget about it (I tried similar approach once, for connecting VB program, with QB program... Not good)

Second method is by using MySQL for exchange of information... Connect VB to MySQL server, connect PHP script to MySQL server, and voila... Easy setup of information... This could be a good method, I'm using it for displaying some info on my site... May be non-efficient though, if too frequent queries should occur...

Third method, again mentioned by ghostrider, involves using socket functions of PHP, to connect it directly to your VB application... A good method, probably the best option... The second part of it, transmitting data to PHP script, I would use POST method, not GET... First, GET metod has a limitation to its length (2K I believe), and POST is used to transfer large quantities of data...

Here, I'm including code used to send data via POST methid, using Microsoft Internet Controls OCX... Just add it to your project, and use the following code:

CODE
Public Sub SendData(ByRef wb As WebBrowser, ByVal Params As String)
Dim vPost     As Variant
Dim vFlags    As Variant
Dim vTarget   As Variant
Dim vHeaders  As Variant
Dim aByte()   As Byte
Dim i         As Long

' Params are in the following format <param-name>=<param-value>[&<param-name>=<param-value>[&...]]
PackBytes aByte(), Params
vPost = aByte
vFlags = &H2 Or &H4 Or &H8 Or &H10
vHeaders = "(anti-spam-(anti-spam-content-type:)) application/x-www-form-urlencoded" & vbCrLf
wb.Navigate "http://your-server/php-script.php", vFlags, vTarget, vPost, vHeaders
End Sub

Private Sub PackBytes(ByRef ByteArray() As Byte, ByVal PostData As String)
Dim i As Long
Dim j As Long
Dim c As String

j = Len(PostData) - 1
If j < 0 Then
Exit Sub
End If
ReDim ByteArray(j)
For i = 0 To j
c = Mid(PostData, i + 1, 1)
If c = Space(1) Then
    c = "+"
End If
ByteArray(i) = Asc(c)
Next
End Sub


This code is sure to send data to your script, via POST methid. You can ofcourse parse resulting webpage, and control your VB application taht way too...

If you want, I can send you a DLL that you can use to connect with MySQL server, and read and write do MySQL databases, just PM me...

Hope this helped a bit...

Oh yeah, just remembered... Since Apache works (mostly, and preferably) on Linux, and VB applications can't do that (sadly laugh.gif), and I'm sure you won't be setting up PHP support on IIS or PWS, your applicayion would have to run on a separate server, running Windows, probably the best method would be to use combination of socket functions in PHP, and, depending on update rate you need, MySQL, or POST method of returning data to your script...

Cheers smile.gif

Reply

matak
QUOTE(Galahad)
Oh yeah, just remembered... Since Apache works (mostly, and preferably) on Linux, and VB applications can't do that


i'm kinda noob programmer, but i found this post very interesting. i didn't remember that VB aps can be run only in windows environment so i posted this question. i won't learn Vb but C and C++ since it can be compiled both for linux and windows environments.
My logic suggests me that C programs could be written to interact with php, and it's kinda logical couse php is written in C (i guess). So if at any time of my life i want to make an application in C to interact with PHP what would be the right way to do that!? It is so soon to talk about that for me, but you don't need to answer right now, and maybe there is more ppl interested in this subject so you could writte anyway.
What is the difference between running PHP as Module or as CGI script, how is all of that conected with basic root program of PHP (what is root program of PHP, how can i start modifiying php, and is it smart to do that, just for fun, and for learning purposes)
thanks

Reply

farsiscript
Dear it01y2 You can transfer Data between VisualBasic and PHP via URL Like this :
CODE
$Somename = $_GET['someurl name'];

or
CODE
$Somename = $_POST['someurl name'];

But its better make code with GET Method
In visualBasic You can generate one HTML page and form and make it for send data form game to server
i read Galahad's post You can use it him code for vb

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php, interact, visual, basic, app, server

  1. Php Without Server
    (6)
  2. Php Pages Permission On Apache Server
    PHP pages permission on Apache Server (1)
    Hello, I want to know what permissions for PHP pages should be given on Apache web server so that
    PHP pages can be executed. If PHP pages are in a folder, what permissions should be given for that
    folder? ....
  3. Wappyftp V1.00
    upload to server via ftp from your mobile phone :-) (8)
    wappyFTP v1.00 by wappy --- site: http://cult.trap17.com mail: admin@cult.trap17.com --- -Welcome
    to wappyFTP, with this wap script your users can upload files directly to their server via FTP from
    a mobile phone! --- -Its extremley easy to install, open index.php and put the name of your site
    instead of YOURSITE.COM -Upload the folder wappyFTP_v1.00 to the root directory of your web server
    -Link to it like wappyFTP_v1.00/index.php -Its all done ENJOY --- YOU MAY DISTRIBUTE AND/OR EDIT
    THIS SCRIPT BUT DO NOT REMOVE THE AUTHORS NAME! --- ©2006-2007 wappyCULT /....
  4. I Need Webmail On My Server
    (so admins on my site can access it) (0)
    Right now, if i go to the cpanel of my site, I can access webmail of any of the email addresses I
    have. Unfortunatly, I would prefer it if the administrators did not know the password to the
    cpanel. I want them to be able to access mail from 1 of the email accounts. I have tried letting
    all the admins access the account through their own cliants, but it became a mess, not knowing wich
    admins have responded to which emails, because most emails are hosted localy when received by
    cliants such as outlook. Then I had the idea of making one page, with webmail on it. Where....
  5. Php Server Time
    (4)
    i think i may asked this question awhile back but i never really got it solved. ok..i had a block
    that told me the server time info or whatever. and the GMT wus at 00:00 i wanted to change it to
    -5:00 but i didnt know how, so how can i change it? im not sure of the codes in the php to change it
    to the right GMT time becuase im always gettn the wrong times n day....
  6. Logging Dowload Files From Your Server Onto A Html File
    (1)
    Well, i had the idea of logging the downloads from my web in a html file few weeks ago, and i solved
    it with a lil php page included in my homepage. You could name the links with a name like
    "download.php?file=filename.ext" and then, in the download.php put the next code: (well you put
    the html and head and body tags if u want, i only write the php here) CODE <? if
    (isset($_GET['file']))
    $file=$_GET['file']; //so it gets the GET data from url
    (file=filename.ext); $ip=$_SERVER[....
  7. Parsing Html As Php
    and XAMPP as the server version on Windows (7)
    On my Trap17 account here, I have an .htaccess file with the following declaration which (I think)
    forces all html files to be parsed by the PHP Parsing engine and therefore I can insert snippets of
    php scripts into html files. CODE AddType application/x-httpd-php .html .htm However, when I
    add an .htaccess file to the local directory of the version of XAMPP on my local machine, it fails.
    I have tried to add the .htaccess file to the htdocs folder and elsewhere, but it still doesn't
    work to parse html through the php parser. Any ideas on how to get these htm....
  8. Email Server Help Please
    I need noob detailed help on setting up a email server on windows XP (0)
    Hello I would like to say thank you for any help you might give me. I'm new to Apache / PHP and
    MySQL I have all them up and running propertly I think. I want to make a PHP online game and I need
    to set up an email server so I can have and authincation system. When the player creates an account
    I want the computer to email the player a link the have to click on to make there account active.
    I have a Comcast 8mbits broadband connection My server is running at http://192.168.1.105 My
    PHPinfo file is http://192.168.1.105/phpinfo.php My FormMail File http://192....
  9. Does Gd Use Much Server Ressources?
    (0)
    Well, my topic title is pretty descriptive. Does GD use much server ressources, is it heavy to run,
    or is it light and flawless just like a normal PHP script? If I use GD much, should the images be
    cached? And by the way, I don't know how to cache images. I know how to create them, but I
    can't manage to store them in a folder, and then check that folder to see if the file is already
    cached. If it's not, the PHP script will create it.....
  10. Server Time Help
    (4)
    My Webpage If you check here in my site in my Login block called "user info" at the bottom it
    tells u the "server time". Well that server time for me is wrong. This is what is displayed QUOTE
    Server Time · Time 14:06:53 · Date 19 Feb 2006 · Timezone +0000 The Date is right but the
    Timezone and Time are just way off. My Timezone should be -500. What do i have to do to fix this? Is
    it in my cpanel or do i have to go edit this block itself??....
  11. Php And Asp.net Form
    server control html component (6)
    does this sort of feature can be done in php. http://www.w3schools.com/aspnet/aspnet_forms.asp or
    how and what are the differences.. thanks /huh.gif' border='0' style='vertical-align:middle'
    alt='huh.gif' /> ....
  12. Php & Apache Server
    PHP & Apache Server (7)
    I want to install PHP. For this I have downloaded Apache Server. But I am not able to configure it.
    If anybody knows how to configure it, please let me know. Without Apache Server I am not able to
    configure PHP. I have also tried one of the installation file available on internet which
    automatically performs all installation tasks, but it also does not solve my problem.....
  13. I'm setting up punBB
    Why won't the db server work? (2)
    What is it?....

    1. Looking for php, interact, visual, basic, app, server

Searching Video's for php, interact, visual, basic, app, server
advertisement



Can Php Interact With A Visual Basic App On A Server



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE