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

  • Home
  • SEARCH
  • 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 9230369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:48:31+00:00 2026-06-18T05:48:31+00:00

I am developing a PHP application that needs to access MySQL (EC2 Instance) remotely

  • 0

I am developing a PHP application that needs to access MySQL (EC2 Instance) remotely from my machine (or any IP for that matter). The application needs to be a stand alone, meaning if tunnel is necessary then the application needs to be able to do that. Currently I am using the below code for connecting to MySQL:

$conn = mysql_connect( $serverName, $uid, $pwd) or die(print_r(mysql_error(), true));

// select database
$dbname='xxxxx';
mysql_select_db($dbname);

I have tried opening the port for MySQL in security groups in AWS console, and have played around with giving access to IPs. I know that EC2 requires keys to access, so I was wondering if any functions allow me to use the key to connect and query data, as well as get that data back into my application for use.

Here is the error message I am currently recieving:

XMLHttpRequest cannot load /myapp.php? Origin null is not allowed by Access-Control-Allow-Origin.

It doesn’t seem to be able to load the data back, and it is strange that I do get some of the information from the database in the file. Somehow it is not able to come back and process the information the way I want. When the same application is on localhost it works fine

Any help would be greatly appreciated!

  • 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-06-18T05:48:32+00:00Added an answer on June 18, 2026 at 5:48 am
    1. You wont need to use the keys to connect to mysql. There is nothing special about an ec2 setup for mysql as you would in a traditional environment. To be secure, its probably best to use an ssl connection (or SSH tunnel) to mysql if its going to be remote, over the internet.

    2. The other error message has nothing to do with mysql. You are making a cross domain ajax request. By default browsers will block this. Recent browsers allow you to set a Access-Control-Allow-Origin header to allow cross domain requests.

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

Sidebar

Related Questions

I am developing a PHP application that is provided with timestamps from a Dynamics
I'm currently developing a PHP application that's using an Access database as a backend.
I am developing a PHP application that will be run only on the local
I a web application that I am developing (being developed in PHP) when a
We've been developing a web application (PHP, using the Yii PHP framework) that is
i was developing my php application and using mysql to store session data and
I am developing an PHP/Mysql application whereby if the user enter a certain value,
I'm developing a web application/game using PHP and mySQL. I need to give the
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I
I am developing a web application that uses JQuery AJAX and PHP to upload

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.