By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

Connecting to local database from Internet

P: n/a
I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web site http://www.internet.com to run
the app. The app requires an internet connection and is outside of
the user's network. The app would have the option to either store
data locally or on the Internet. I would like to give users the
option to store data locally because some may have privacy/security
concerns if the data is stored on the Internet or kept/maintained by
another company.

Would the connection string below work from the Internet to connect to
the user's local database? I don't have my web hosting service up yet
so I can't test. Thanks...

<?php
$server='localhost' //or whatever the client db server name is
$c=new mysqli($server,'user','passwd','db');
?>

May 17 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
mo*****@yahoo.com wrote:
I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web site http://www.internet.com to run
the app. The app requires an internet connection and is outside of
the user's network. The app would have the option to either store
data locally or on the Internet. I would like to give users the
option to store data locally because some may have privacy/security
concerns if the data is stored on the Internet or kept/maintained by
another company.

Would the connection string below work from the Internet to connect to
the user's local database? I don't have my web hosting service up yet
so I can't test. Thanks...

<?php
$server='localhost' //or whatever the client db server name is
$c=new mysqli($server,'user','passwd','db');
?>
PHP runs on the server, not the client. So if your webserver with PHP is
on the same machine (or LAN) as your database server, there should be no
problem at all.

Storing data locally through a web browser is a bit more tricky though.
If you use certificates the client trusts, it should work. Otherwise,
the website might be considered a security problem (like the ones that
stoer trojans on your PC)...
--
Sabine Dinis Blochberger

Op3racional
www.op3racional.eu
May 17 '07 #2

P: n/a
mo*****@yahoo.com wrote:
I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web site http://www.internet.com to run
the app. The app requires an internet connection and is outside of
the user's network. The app would have the option to either store
data locally or on the Internet. I would like to give users the
option to store data locally because some may have privacy/security
concerns if the data is stored on the Internet or kept/maintained by
another company.

Would the connection string below work from the Internet to connect to
the user's local database? I don't have my web hosting service up yet
so I can't test. Thanks...

<?php
$server='localhost' //or whatever the client db server name is
$c=new mysqli($server,'user','passwd','db');
?>
As Sabine indicated, php runs on the server, so 'localhost' will always
be the server's database.

In addition, you shouldn't plan to store data in the client's database.
Most people don't have MySQL installed. Most of those who do have it
installed on their local machine either have network connections
disabled or have a firewall which prevents external access. And those
who do allow external access are not likely to give out a
userid/password to another website - at least not if they have any sense
at all. And even if they give you their userid and password, you don't
know if they have the appropriate database and tables - or maybe have
that database and table name for an entirely different use.

I don't know what kind of data you're storing, but I don't think this is
a good way to go.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 17 '07 #3

P: n/a
You would need to have a static IP first of all. Then you might need
to set up port forwarding if you have any sort of firewall. But then
you would just connect to that IP/Port just like you would if you were
on the same server

May 17 '07 #4

P: n/a
On May 17, 5:53 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
moua...@yahoo.com wrote:
I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web sitehttp://www.internet.comto run
the app. The app requires an internet connection and is outside of
the user's network. The app would have the option to either store
data locally or on the Internet. I would like to give users the
option to store data locally because some may have privacy/security
concerns if the data is stored on the Internet or kept/maintained by
another company.
Would the connection string below work from the Internet to connect to
the user's local database? I don't have my web hosting service up yet
so I can't test. Thanks...
<?php
$server='localhost' //or whatever the client db server name is
$c=new mysqli($server,'user','passwd','db');
?>

As Sabine indicated, php runs on the server, so 'localhost' will always
be the server's database.

In addition, you shouldn't plan to store data in the client's database.
Most people don't have MySQL installed. Most of those who do have it
installed on their local machine either have network connections
disabled or have a firewall which prevents external access. And those
who do allow external access are not likely to give out a
userid/password to another website - at least not if they have any sense
at all. And even if they give you their userid and password, you don't
know if they have the appropriate database and tables - or maybe have
that database and table name for an entirely different use.

I don't know what kind of data you're storing, but I don't think this is
a good way to go.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
I was expecting there would be firewall and security issues. It just
looks so simple thought I'd just give it a shot.
I would let the users know that if they want to store the data locally
they would have to have MySQL installed with a specified database
name, user, and password. Then provide a script to create the table
structure.
I was hoping this would be possible so the user wouldn't need to have
PHP and a web server installed. All they would need is just the
database. Now it looks like the user will need PHP, web server, and
MySQL. The user will download a PHP file and run it on their web
server. The PHP page will have links to include files from my web
site. I think it should work this way, right? No security or
firewall issues? Only issue here with me is that I run the risk of
users modifying my PHP and javascript codes. I want to control the
app from my web site so that if I make changes everyone will get the
update, even the ones who run the app locally.

BTW, I'm developing a financial app so the database will have
financial information about the user. Most people including myself
are protective of financial information.

May 17 '07 #5

P: n/a
mo*****@yahoo.com wrote:
I would let the users know that if they want to store the data locally
they would have to have MySQL installed with a specified database
name, user, and password. Then provide a script to create the table
structure.
PHP on your server is not way to do this. At all. Use downloadable
java application instead.
May be this is will be possible when IPv6 will be common.
May 17 '07 #6

P: n/a
>Now it looks like the user will need PHP, web server, and
>MySQL. The user will download a PHP file and run it on their web
server. The PHP page will have links to include files from my web
site.
If you expect users to run PHP on their system with off-site include
files, either you're nuts, or your users are nuts. Especially when the
application deals with financial data.
>I think it should work this way, right? No security or
firewall issues?
Including a PHP file from a site you (the guy running the site, in this
case, your customer) don't own is really, REALLY asking for trouble.
>Only issue here with me is that I run the risk of
users modifying my PHP and javascript codes. I want to control the
app from my web site so that if I make changes everyone will get the
update, even the ones who run the app locally.
So if your site gets infected, so do all your customers. Or if
your DNS gets spoofed somehow so the customer sites go elsewhere
for the include files.
>BTW, I'm developing a financial app so the database will have
financial information about the user. Most people including myself
are protective of financial information.
People who are protective of financial information should have run away
screaming halfway through this article.

May 18 '07 #7

P: n/a
mo*****@yahoo.com wrote:
On May 17, 5:53 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>moua...@yahoo.com wrote:
>>I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web sitehttp://www.internet.comto run
the app. The app requires an internet connection and is outside of
the user's network. The app would have the option to either store
data locally or on the Internet. I would like to give users the
option to store data locally because some may have privacy/security
concerns if the data is stored on the Internet or kept/maintained by
another company.
Would the connection string below work from the Internet to connect to
the user's local database? I don't have my web hosting service up yet
so I can't test. Thanks...
<?php
$server='localhost' //or whatever the client db server name is
$c=new mysqli($server,'user','passwd','db');
?>
As Sabine indicated, php runs on the server, so 'localhost' will always
be the server's database.

In addition, you shouldn't plan to store data in the client's database.
Most people don't have MySQL installed. Most of those who do have it
installed on their local machine either have network connections
disabled or have a firewall which prevents external access. And those
who do allow external access are not likely to give out a
userid/password to another website - at least not if they have any sense
at all. And even if they give you their userid and password, you don't
know if they have the appropriate database and tables - or maybe have
that database and table name for an entirely different use.

I don't know what kind of data you're storing, but I don't think this is
a good way to go.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

I was expecting there would be firewall and security issues. It just
looks so simple thought I'd just give it a shot.
I would let the users know that if they want to store the data locally
they would have to have MySQL installed with a specified database
name, user, and password. Then provide a script to create the table
structure.
I was hoping this would be possible so the user wouldn't need to have
PHP and a web server installed. All they would need is just the
database. Now it looks like the user will need PHP, web server, and
MySQL. The user will download a PHP file and run it on their web
server. The PHP page will have links to include files from my web
site. I think it should work this way, right? No security or
firewall issues? Only issue here with me is that I run the risk of
users modifying my PHP and javascript codes. I want to control the
app from my web site so that if I make changes everyone will get the
update, even the ones who run the app locally.

BTW, I'm developing a financial app so the database will have
financial information about the user. Most people including myself
are protective of financial information.
I agree with Gordon's comments. If you want them to store the data on
their local system, give them an encrypted file to store it in. Next
time they access your system, they can upload the encrypted file, which
you can then parse.

But your idea is a recipe for failure.

And no, you do not want or need a java application. In fact, java won't
help you a bit here. Java, due to security restrictions, can't store on
the client machine, either. It can only store back to the server.

And as for downloading java applications - the same caveats Gordon
mentioned for PHP apply to Java.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 18 '07 #8

P: n/a
mouac01 wrote:
I was hoping this would be possible so the user wouldn't need to have
PHP and a web server installed. All they would need is just the
database.
Yes, that is certainly possible.

It would be a triumph of ingenuity over sanity.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 18 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.