Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6220667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:59:47+00:00 2026-05-24T07:59:47+00:00

I’m trying to connect to a mysql db, but from another server and process

  • 0

I’m trying to connect to a mysql db, but from another server and process all queries on that server and then send all the data off to the original server, using CURL.

I’ve been researching for hours and cant seem to find the right way to go about it.

so this is what I’m trying to do overall:

  1. When somebody visits a page from server A, a request will then be sent out from server A to server B which will then connect to a db.

  2. Once server B has connected to the db, it will take information from certain rows and fields and then send it back to server a.

  3. Once server A has received the info, it will then echo out and etc etc…

Firstly, is this safe to do? It wont like open a door on both or even one server will it?

Secondly, I have no idea how to go about it.

An example code would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:59:48+00:00Added an answer on May 24, 2026 at 7:59 am

    On server A

    $post_fields = array(
        'variable_name' => 'variable_value',
        'variable' => $variable,
    );
    $ch = curl_init('http://www.serverB.com/example.php');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,  $post_fields);
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    

    $result now contains the HTML of the page you have requested from server B.

    On server B

    // pseudocode
    $variable = $_POST['variable'];
    $variable_name = $_POST['variable_name'];
    $db_results = $db->getQuery('SELECT * FROM table WHERE `variable` = ?', array($variable))->toString();
    echo $db_results;
    

    Is it safe?

    This depends. Does the information coming from the DB need to be protected from public view? Obviously with the setup above the information is just echod out to a page on server B. Was someone to find that page then they would be able to see the information.

    If that does not matter then its perfectly save and does not open any doors (you own both sites right?) particularly.

    If you need to protect against that then I suggest sending a token from server A to server B to authenticate that the correct script is attempting to access the information. Something like an API key, which you could pass as a header in your curl request and then get out and verify from $_SERVER on server B.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.