...

View Full Version : Can I call asp program from PHP?



rocky10
05-08-2005, 09:42 PM
I have a PHP program that accesses a database, does various functions and then I would like to call and pass data to an ASP program. I have it working via the html <a> command but would like to remove the html from the equation. Any ideas on how to automatically call and pass data to an asp program from PHP???????

Fou-Lu
05-08-2005, 10:32 PM
Hmm, and include perhaps? I remember we had this topic come up awhile ago, but cannot recall what was determined.
Give that a shot, see if it works. Obviously you'll need to create a way to pass this information to be usable within the asp itself, whether it be like a request variable or through something like xml. So yes an no for your question, you cannot directly call asp within a php script, but you can process it however you would like and include it within your php.

rocky10
05-09-2005, 02:27 AM
Hmmm, I included the asp code within the php and it never executed the asp code. What I did was something like this

<?php
echo "This is a test email message<br>";
?>

<%@ Language=VBScript %>
<%
Response.Write "Hello from ASP"
%>

<?php
echo "Hello from PHP";
?>

The output was
This is a test email message


Hello from PHP

It never displayed "Hello from ASP", just a blank line.

rocky10

firepages
05-09-2005, 02:56 AM
you can't do it in the same request (though apache2 filters in theory could (though still not with asp;)))

assuming a PHP enabled webserver with asp running on port 81 (or simply on a remote server)



<?php
echo "This is a test email message<br>";
include( 'http://domain.com:81/asp.asp' ) ;
echo "Hello from PHP";
?>


where asp.asp is your ...
<%@ Language=VBScript %>
<%
Response.Write "Hello from ASP"
%>

mindlessLemming
05-09-2005, 05:22 AM
If this application is something your making for your job/client, or any other developer will ever have to deal with the code; DON'T MIX SERVER ENVIRONMENTS!

I'm not just having a whinge here, I know exactly how it feels to inherit such an application as I am currently responsible for migrating 6 apps which use a foul concoction of PHP, ASP, Oracle and MySQL. I have the enviable task of making them PHP/Oracle apps and I can honestly say that if the developer responsible for these apps was still here (they're 5 years old), I'd happily wrap a very heavy piece of timber around his head with great force :mad:

Please, please PLEASE!!! An extra 5-10 hours of your time now will save 100 hours of someone else's in the future (unless you plan on writing a 50+ page system design manual to accompany the app). If you can't see the value in that; there's no hope :(

..and don't even get me started on the joys of maintaining a multi-language environment!

rocky10
05-11-2005, 04:16 PM
OK, I took mindlessLenning's advice and rewrote the asp code in PHP. It works fine. Thanks for the help!! :thumbsup:

WisTex
05-29-2005, 11:37 AM
While having one language is ideal, some websites are made with a variety of pre-made scripts that need to be integrated together. It's much cheaper to pay $50 for a forum script, $50 for a directory script, $50 for a banner advertising script, use an open source shopping cart, etc. than to pay a programmer to build such common applications from scratch. All these programs need to be "integrated" to work together and it is quite easy to do in most cases if they are the same language. For example, I have integrated many of the above mentioned apps together on one website, creating one login that works for the entire website.

All those applications are in ASP and I would like to start using some PHP applications on the website as well, but I would need to be able to pass variables back and forth between ASP and PHP to do so. Or the other alternative is to either figure out how or hire a more experienced programmer to write a PHP script that checks to see if they logged into the ASP portion of the website (i.e. making a PHP version of the ASP code that checks if a user is logged in).

I know its a mess using several pre-made scripts for a website, but not everyone has a budget to hire a programmer or time to write yet another version of thousands of common applications. Plus, there are many good PHP scripts that I would like to use that I currently can't because the rest of the site is in ASP.

If anyone has figured out how to work PHP and ASP together effectively, I would appreciate it if you post your ideas and solutions here. Thanks.

delinear
05-29-2005, 01:31 PM
If all you need to do is pas the variables back and forth between ASP and PHP then it shouldn't be too difficult, depending what you're trying to do that is.

I don't know much about ASP but it uses cookies and so does PHP so that's the first thing that springs to mind. I also believe that they both handle query strings the same way (?var1=value&var2=value etc) so if you don't have much data to pass, using the URL could be the answer.

Finding a way to maintain session state would be more difficult although still not impossible if you wrote your own custom session handler for each system, stored the session id in a database and passed it through the url or cookies.

Really it all depends what data you need to pass and how it needs to be handled.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum