Displaying data from another host on web server
Moderator: General Moderators
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Displaying data from another host on web server
Hi everybody,
I do not know what do people call this...
A website namely http://www.abc.com but the database is located in http://www.alldata.com. Any actions that interacts with the data such as: Add, Edit, or Delete will only be do able in http://www.alldata.com, but not in http://www.abc.com. http://www.abc.com acts only as a website that displays contents added from http://www.alldata.com...
In short, the database is in http://www.alldata.com, and http://www.abc.com only displays data which were inserted into the database located in http://www.alldata.com
I am trying to google this, but I think I have not found the right keyword for this case, so the results returned were improper.
What do you call this (brown colored) ?
Is it possible to do it in PHP ?
Have any good resources about it ? (very appreciated !!)...
Thanks a lot,
Chris
NOTE:
Both domain are owned by the company where I work, so I am not trying to ask you how to hack any websites here.
I do not know what do people call this...
A website namely http://www.abc.com but the database is located in http://www.alldata.com. Any actions that interacts with the data such as: Add, Edit, or Delete will only be do able in http://www.alldata.com, but not in http://www.abc.com. http://www.abc.com acts only as a website that displays contents added from http://www.alldata.com...
In short, the database is in http://www.alldata.com, and http://www.abc.com only displays data which were inserted into the database located in http://www.alldata.com
I am trying to google this, but I think I have not found the right keyword for this case, so the results returned were improper.
What do you call this (brown colored) ?
Is it possible to do it in PHP ?
Have any good resources about it ? (very appreciated !!)...
Thanks a lot,
Chris
NOTE:
Both domain are owned by the company where I work, so I am not trying to ask you how to hack any websites here.
Last edited by christian_phpbeginner on Wed Apr 11, 2007 6:50 am, edited 1 time in total.
Using PHP you can connect to remote or local databases. You can specify database located on local or remote server when connecting to it using mysql_connect().
Are you looking for this?
Are you looking for this?
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Hi, well, actually I am not sure ... what do I have to pass in the parameter ?mentor wrote:Using PHP you can connect to remote or local databases. You can specify database located on local or remote server when connecting to it using mysql_connect().
Are you looking for this?
Code: Select all
mysql_connect('http://www.alldata.com/localhost', 'username', 'password');Thanks,
Chris
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
The mysql server is not connected to the internet I guessed....I just tried what mentor was suggested...and the mysql_error said "LOST CONNECTION......". So is this mean that I can't get the data out of the database ? Is there any other way ?aaronhall wrote:If the mysql server is connected to the internets, the host can give you the server's address. If it's not hooked into the internets, you're out of luck. If you get that all working, it's matter of setting the user permissions in mysql to allow the remote client to only read data.
that would be 'www.alldata.com'christian_phpbeginner wrote:'http://www.alldata.com/localhost'
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Hi Volka, I have tried to change the host name into http://www.alldata.com, but still it says: "LOST CONNECTION....". Is this means that I can not connect to the database ? I am sure that the database username and password is correct.volka wrote:that would be 'www.alldata.com'christian_phpbeginner wrote:'http://www.alldata.com/localhost'
Thanks,
Chris
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Danke
The MySQLConnection.phpvolka wrote:Please show more of your code - esp. the code block responsible forchristian_phpbeginner wrote:it says: "LOST CONNECTION...."
Code: Select all
<?php
function connectToMySQL() {
static $conn;
if (isset($conn)) {
return $conn;
}
$conn = mysql_connect('www.alldata.com', 'myusername', 'mypassword');
if (!$conn) {
die ("Connection error. Either host, username, password, or database name is invalid, or left blank.");
}
getDatabaseName();
return $conn;
}
function getDatabaseName() {
$dbName = "somedatabasename";
if (!mysql_select_db($dbName))
{
return "Database with the name you specified does not exist.";
} else {
return mysql_select_db($dbName, connectToMySQL());
}
}
?>Code: Select all
<?php
require_once('MySQLConnection.php');
$query = "SELECT addressID FROM tbladdress";
$result = mysql_query($query, connectToMySQL());
if (!$result) {
die (mysql_error(connectToMySQL()));
}
if (mysql_num_rows($result) > 0) {
echo 'Connection Established';
}
?>http://www.tokoapple.com/myos/test.php
You can see the error there...
I appreciated this...
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Post the fill error, and the error code - then it's a manual click away as to what it means.
Chances are it's unable to access the database across the internet. If that's the case you'll need to either find an alternative means of securely pushing the data to your current server, or something else. Are the server physically separated? No networking at all between them?
Chances are it's unable to access the database across the internet. If that's the case you'll need to either find an alternative means of securely pushing the data to your current server, or something else. Are the server physically separated? No networking at all between them?
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
And what alternatives do you suggest ?Maugrim_The_Reaper wrote:Post the fill error, and the error code - then it's a manual click away as to what it means.
Chances are it's unable to access the database across the internet. If that's the case you'll need to either find an alternative means of securely pushing the data to your current server, or something else. Are the server physically separated? No networking at all between them?
The server is physically separated. And no networking between them...
Oh by the way, I have called the web hosting provider. And they said that in the mean while they will only support 'localhost' as the host name...this means, I need alternatives...
The error:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /home2/apple/public_html/myos/MySQLConnection.php on line 8
Can XML solve this problem ?? What alternatives do I have in this case ?
Thanks,
Chris
Last edited by christian_phpbeginner on Wed Apr 11, 2007 9:03 am, edited 1 time in total.
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java