LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2005, 04:11 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
merge ASP code with PHP code.. possible ??


The company I work in has a directory of all the websites of a certain business category.. it is written in php and connected to a mysql database that contains the data that is frequently updated....while another company's website has wide exposure..so the deal was to include our directory in their website....
They gave me a skeleton of their asp site with a note somewhere "your code goes here"...
I had already tailored a php page that would be included in their site....
Questions:
1- Can I include a php code within asp..."Note however,that the include file should call a php file on our server that will be executed on our server and the results will be displayed in the visitor's browser.

Example "abstract":

ASP CODE
<--#ASP include "http://www.php-page.com/directory.php" -->
ASP CODE

I know it sound weird...but I have to make it work someway....
 
Old 12-29-2005, 08:47 AM   #2
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
Arrow

Quote:
Originally Posted by ALInux
Questions:
1- Can I include a php code within asp...

I know it sound weird...but I have to make it work someway....
To include an ASP program in a PHP page:
PHP Code:
<? include "http://localhost/aspcode/example.asp"?>
*Note: The included page must be a url, even if it's on the same server, in order to force it to execute the code on the page prior to including it.


To include a PHP program in an ASP page:
Code:
<%
Set GetConnection = CreateObject("Microsoft.XMLHTTP") 
GetConnection.Open "get", "http://localhost/phpcode/example.php", False
GetConnection.Send  

MyString = GetConnection.responseText
%>
I don't know for sure whether the filename here has to be a url like the PHP example... try it and see.


Hope that helps.

Last edited by Spudley; 12-29-2005 at 08:51 AM.
 
Old 12-29-2005, 08:59 AM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Thanks for your reply...Iam a step nearer to my solve my problem ..now ...

Ive used this code:
<%
Set GetConnection = CreateObject("Microsoft.XMLHTTP")
GetConnection.Open "get", "http://www.thedaleel.com/index_test.php", False
GetConnection.Send

MyString = GetConnection.responseText
%>


Ive pasted this code into the asp page...and it showed in the status bar that www.thedaleel.com is loading...so that should have worked..but the problem is that the ouput was not displayed on the asp page..i.e. the images and text of the requested php page did not show up in the asp page...

Any more comments please.....
 
Old 12-29-2005, 10:51 AM   #4
LegendBreath
Member
 
Registered: Apr 2005
Location: New Brunswick, Canada
Distribution: Fedora Core 3
Posts: 39

Rep: Reputation: 15
Errmmm... I'm not an expert but, try ending your ASP (I don't know any ASP so... What I mean is like ?> thats for ending PHP but do that but for ASP) and then <?php include("yourphpfile"); ?> And then after start back your ASP. I was doing that for HTML I don't know if it's the same thing for ASP. As I say, I'm not an expert.
 
Old 12-29-2005, 12:54 PM   #5
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
Quote:
Originally Posted by ALInux
Ive pasted this code into the asp page.....but the problem is that the ouput was not displayed on the asp page
....well, he ASP code is just creating a string variable, so you would need to output the string in order to see it. (hehe... I didn't say the example code was perfect! ... adapt it as per requirements )

Something like: document.write(MyString) should do the trick.
 
Old 12-29-2005, 02:22 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
ASP, PHP, JSP, ASPX, CFM, and so forth are all examples of "server side scripting".

When your web client requests a ".php" page from an Apache server, for example, the server must have been configured to:

a) recognize the .php file suffix the web client requested of it, and
b) Pass the page (your "source code") to the appropriate interpreter program (either a standalone php program or an Apache PHP plug-in).

The interpreter parses (executes) the page, and the results are passed back to the client.

So far, so good.

But how can the SAME interpreter handle DIFFERENT languages?

Believe it or not, the answer is "sometimes: it can!".

But in your case, I suspect you'll quickly reach a point where you need EITHER .asp OR .php code, where you will NOT be able to co-mingle the two languages on the same page.

Hopefully I'm being overly pessimistic, and you won't reach this juncture. But have you considered using frames?
 
Old 12-29-2005, 02:58 PM   #7
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
Quote:
Originally Posted by paulsm4
....Hopefully I'm being overly pessimistic, and you won't reach this juncture. But have you considered using frames?
The idea here is to ensure the two pages run separately, but that the one includes the output of the other. The two languages don't have to intermix at all.

I've done it myself (when I was required to use an existing perl program inside a PHP system), so it can be done without doing anything special: Just make a http request, even to localhost, and the server will parse and execute the page before giving you the processed output. So it doesn't matter what language it was written in; all your calling program ever sees is the finished html, which can then be included in your page's final output however you see fit.

The only downside is that making all those http requests can be a bit heavy on server resources, but if you really do need to mix your languages, it is a good solution.
 
Old 12-30-2005, 08:40 AM   #8
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
sorry for being so late ...in my reply...actually it is working quite well right now ....I used frames...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
is there any tool avilable to convert java/sql code into asp.net/sql2000 rddreamz Programming 1 11-08-2004 02:16 PM
Editing buttons (quote, code etc.) add the code to the end vharishankar LQ Suggestions & Feedback 2 09-13-2004 09:32 AM
What is correct code for "Include File Function" on .asp pages gregoryfrancis Linux - General 1 02-11-2003 10:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration