/    Sign up×
Community /Pin to ProfileBookmark

Cross-server script execution and delivery of results

I have a script that runs on a server (call it Server A) and it does essentially 3 things:
(1) it connects to a MySQL db & selects a row from a table,
(2) sets a session variable with certain data from the selected row, and
(3) writes dynamic html and content that includes the value in the session variable.

To minimize replicating the script on another server (call it Server ? and keep both sets of script in sync with each other, I want to access the source script on Server A from unrelated Server B and have the script run as defined above and deliver the same dynamic output to Server B.

I know the include() function doesn’t do this for me. Is there a way to make this happen without having to replicate the PHP script and the MySQL tables & rows on both servers?

Thanks for your help.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ryanlundMay 14.2009 — Possibly try using curl?? Too tired to go into details but im sure google would fill you in on how to use the curl function. Not 100% sure if it would work though. As far as using the same mysql tables you can connect to the same database from a different server (when you call your mysql_connect function). You will need to speak to your webhost to see if they allow this and get the information to connect to the database. Hope this has helped slightly.

Ryan
Copy linkTweet thisAlerts:
@devel95authorMay 14.2009 — Ok, thanks.

Let me ask this:

can I connect to the MySQL database on Server B from Server A by using the proper hostname on my mysql_connect() statement?

If so, how do I find out what the hostname is for the MySQL db on the server?
Copy linkTweet thisAlerts:
@ryanlundMay 14.2009 — Yeah thats right, like i said you need to ask your web host if they allow you to connect to the database from a different server and the details for doing this (obviously using localhost wont work). Give them a call and have a chat with them, they will let you know how to go about it from there if they are any good.
×

Success!

Help @devel95 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...