Jump to content

PHP/MySQL Database Connections


Recommended Posts

I am trying to write a MySQL database on a laptop, using web forms to populate the database via PHP scripts for my cycling club, where we record race times and names etc.

I have set up a IIS server on the laptop, installed PHP and MySQL, I have connected it all and it works, ie I can enter data into my web form, submit it, the PHP will then insert the data into the MySQL database, I can subsequently query it with no problem at all!!!

The next bit I want to be able to do is actually query my localhost database on the laptop and then connect to my Website database and update the information held there, with the data from the laptop.

My first connect string looks like:

<?

$conn1 = mysql_connect("localhost", "MYUSERNAME", "MYLOCALPASSWORD");

mysql_select_db("testdb");

.... the rest of the script querying the local database ....

then I want to run this in the same script so it connects to my website database:

$conn2 = mysql_connect("WWW.MYWEBSITES.COM:DATABASE", "MYWEBUSERNAME", "MYWEBPASSWORD");

mysql_select_db("myweb_testdb");

Now the problem is I don't know what to put into the WWW.MYWEBSITES.COM:DATABASE part of the string, I thought it would have been my URL:3306, but that just gives me this error:

"Access denied for user: MYWEBUSERNAME@hostMYWESBITES.COM (using password:YES)"

I do have a support call out with the hosting company, as I am at a complete loss on this one!! but they can take upto 72 hours to respond! :wacko:

Can anyone guide me on this one?? All replies appreciated.

Link to comment
Share on other sites


did you try just leaving it "localhost". If your mysql and web server are on same machine it will work. My hosting (globedomain, apache shared server) is like this.

EDIT: sorry, that no good. I see what you are doing now. You want to connect direct to the remote db from your desktop app, not php on your server, right?

Edited by dman
Link to comment
Share on other sites

so when you connect to the database on your website are you still connected to the database on your laptop?

Yes, but it does not have too as long as I have loaded the contents of the local database to variables in my PHP script, I can then "insert" these into the Web based database. So I don't mind if the script disconnects from the local database.

did you try just leaving it "localhost". If your mysql and web server are on same machine it will work. My hosting (globedomain, apache shared server) is like this.

EDIT: sorry, that no good.  I see what you are doing now. You want to connect direct to the remote db from your desktop app, not php on your server, right?

Locally there is no problem, just when trying to connect to the web database, so yes I want to connect directly to it from a PHP script on my laptop (which is setup up as a local webserver).

Link to comment
Share on other sites

I tried this with my host and could not connect either. I am thinking that the MySQL DB at host is set up to only accept local connections. I sent email to my host co to ask.

Link to comment
Share on other sites

I tried this with my host and could not connect either. I am thinking that the MySQL DB at host is set up to only accept local connections. I sent email to my host co to ask.

I have asked my hosting company the question...... :thumbup Will report back.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...