Jump to content

extracting information from server database


moleEE132

Recommended Posts

You generally do not connect to database servers via urls. You need to provide allot more information though I suspect your not sure what your asking exactly.

 

Try not to tell us what you think you need to do, just describe your actual need.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :)

 

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

$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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.