You are here: Re: Allow friend to access MySQL db from my host « PHP SQL « IT news, forums, messages
Re: Allow friend to access MySQL db from my host

Posted by NC on 06/01/06 23:06

©® wrote:
>
> I have a few MySQL databases that came with my hosting package.
> My friend has very simple webhosting and did not get any databases.

Then he probably doesn't have a MySQL client, either...

> How do I allow him access to one of my databases? (I will create one
> for his specific use).

Generally speaking, you should ask you hosting provider. It's entirely
possible that you cannot access your databases from anywhere other than
your hosting server. So you will not be able to let him use your
databases directly. This said, there are indirect ways (see below).

> E.g. My site would have settings something like this:
> My URL: www.mysite.com
> Absolute path: "/home/mysite/public_html"
> Database Name: mydbname
> MySQL Hostname: localhost
> MySQL Username: myusrname
> Password: test
>
> My friend's site would be:
> www.myfriendssite.com
>
> Is it actually possible to have the database on my hosting space
> and allow him to access it?

Yes, but you will have to write a middleware script, plus the
performance may be far from inspiring... Say, your friend wants to
retrieve some data, so he puts together a script like this:

$query = 'SELECT field1, field2 FROM the_table WHERE id=123';
$url = 'http://www.mysite.com/data.php?q=' . urlencode($query);
$data = file_get_contents($url);

Your data.php then could include this:

header('Content-Type: text/plain');
$query = $_GET['q'];
$result = mysql_query($query);
while ($record = mysql_fetch_row($result)) {
echo implode("\t", $record), "\r\n";
}

This will output the desired data in tab-delimited text format, which
your friend will then be able to use on his site. You could also
output CSV or XML if you want...

Note that the setup described above has no security features of any
kind. You will have to think of some...

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация