Google Answers Logo
View Question
 
Q: Update a remote MYSQL database using PHP ( No Answer,   5 Comments )
Question  
Subject: Update a remote MYSQL database using PHP
Category: Computers > Programming
Asked by: mmatrix-ga
List Price: $35.00
Posted: 22 Jun 2004 12:58 PDT
Expires: 23 Jun 2004 11:59 PDT
Question ID: 364672
I have two servers, 'Foo' is a box that parses email orders using PHP
as a command line scripting server ( a filter kicks off the PHP script
that breaks up and email into parts), 'Bar' is a MySQL server with
Apache and PHP.

I need to be able to insert records on Bar using data from Foo (this
would be lightweight stuff like names and addresses.)

I have PHP on both sides, and a lot of familiarity with it.

I am looking for best practices, or just quick and dirty, but the
least complex solution is preferred. Some form of encryption for the
connection (SHH is available to both Foo and Bar) would be preferred.
Feel free to be verbose. =)

Clarification of Question by mmatrix-ga on 23 Jun 2004 06:14 PDT
Just to clarify, I can INSERT into the "Bar" server just fine _on that
box_, what I need to do is an INSERT from a remote server using PHP. I
need the easiest way possible, with the best security possible. I
understand that these are propably mutually exclusive, but I need to
consider security.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Update a remote MYSQL database using PHP
From: crythias-ga on 22 Jun 2004 21:35 PDT
 
You're so close!
You know how to query a MySQL database from PHP with SELECT, so the
connection to a database is the same. The query is simply "INSERT INTO
tblname (col1, col2) VALUES (foosresult1, foosresult2);"
from http://dev.mysql.com/doc/mysql/en/INSERT.html

Of course, if you want *security*, then gpg encrypt the raw data,
email it to BAR and let BAR gpg decrypt the raw data, run the PHP
parser, including the INSERT to the MySQL on BAR. Since the data runs
visible (hopefully only) on localhost of BAR, the exposure to the web
is minimal. There's probably a better way, but I don't think parsing
for clear text data and sending it is going to be secure. Do all of
your data manipulation on the MySQL box. Yes, keep email separate,
though. Maybe someone will have a different, perhaps better idea.
Subject: Re: Update a remote MYSQL database using PHP
From: crythias-ga on 23 Jun 2004 06:31 PDT
 
I don't understand. As long as MySQL is hosting on TCP/IP (not UNIX Sockets only), 
$link = mysql_connect('BAR', 'mysql_user', 'mysql_password'); should work from FOO.

For security, it appears you'll need openSSL and recompile MySQL with
specific options. http://dev.mysql.com/doc/mysql/en/Secure_requirements.html
Subject: Re: Update a remote MYSQL database using PHP
From: mmatrix-ga on 23 Jun 2004 06:56 PDT
 
Crythias, wouldn't the MySQL username and password be sent in
cleartext uising that method?
Subject: Re: Update a remote MYSQL database using PHP
From: crythias-ga on 23 Jun 2004 11:27 PDT
 
The short answer is "Yes" under PHP4
PHP5 gives mysqli including mysqli-ssl-set
http://us4.php.net/manual/en/function.mysqli-ssl-set.php

This for built-in PHP commands. HOWEVER, the
http://us4.php.net/manual/en/function.shell-exec.php command might be
useful to call the mysql CLI to connect under SSL and pass the query
that way. (drop your query into a temporary file.sql, call the mysql
-u and ssl connections, with reading in the inserts from file.sql.

OK, OK, it's a kludge, but I don't know why it won't work.
Subject: Re: Update a remote MYSQL database using PHP
From: mmatrix-ga on 23 Jun 2004 11:58 PDT
 
That is very interesting, if I can connect via SSl to "Bar" from "Foo"
then I can execute my INSERT query securely. Thanks!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy