Jump to content

extracting information from server database


moleEE132

Recommended Posts

Our own database don't have the full information that the user needed/wanted after doing a search but it will only show the basic information. Hence we want to know how do we get the rest of the information from a different website so that when user view the searched details, they are able to see the full information needed.

Hi actually i do have the permission to access the database, but its too big therefore i am thinking of just "linking" my site to it. So that i am still able to get the information from it after doing a search.

There are people who suggests about HTTP commands to me like GET and POST but i'm not sure how to really do it.

 

thanks alot for your reply and advices. :)

 

@OP whatever website hosts the remote database, get them to write a small simple PHP script that acts like a private API.  That way you can use CURL to get data from the remote database.

 

Where $nvp below is a URL variable thing. like &db=customers&customer_id=1&fname=frank

 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.website.com/page.php" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);

// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp);

// Get response from the server.
echo curl_exec($ch);

 

then BOOM using a URL to get data from a remote database.

then BOOM using a URL to get data from a remote database.

 

That's all well and good, but if the OP has permission he may as well make a proper connection to the database and just use.

 

Unfortunately however, the OP isn't being very helpful with his questions / responses to other questions.

That's all well and good, but if the OP has permission he may as well make a proper connection to the database and just use.

 

Unfortunately however, the OP isn't being very helpful with his questions / responses to other questions.

 

From what i can gather OP has access but most likely not directly to the database.  Because it seems OP knows how to straight connect to a DB but for some reason this other DB isn't directly connectable.  Therefore it's probably on a remote system, and hes trying to connect and use it via a URL and that most closely resembles a remote HTTP request such as CURL.

 

I guess. lol.

 

$ID = @$_GET['id'] ;
$db_host = 'Host';
$db_user = 'username';
$db_pwd = 'password';

$database = 'database';
$table = 'table';

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

$result = mysql_query("SELECT id,post_content FROM $table WHERE id = '$ID'");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysql_fetch_row($result);

echo $row[1];

 

Something like that?

 

id and post_content are columns in the database just enter your own.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.