moleEE132 Posted July 14, 2010 Share Posted July 14, 2010 I am trying to extract information from a server database to put it into my database. how do i do so by using a URL? thanks Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/ Share on other sites More sharing options...
kenrbnsn Posted July 14, 2010 Share Posted July 14, 2010 More information is needed to effectively answer your question. Ken Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1085852 Share on other sites More sharing options...
moleEE132 Posted July 14, 2010 Author Share Posted July 14, 2010 The database that i have with me do not have much info. In order to have the rest of the info ( by not editing my database) i will need to get from the server. Hence will need a url to link there. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1085856 Share on other sites More sharing options...
trq Posted July 14, 2010 Share Posted July 14, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1085859 Share on other sites More sharing options...
moleEE132 Posted July 14, 2010 Author Share Posted July 14, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1085871 Share on other sites More sharing options...
trq Posted July 14, 2010 Share Posted July 14, 2010 So you want to steal content from another website? This has nothing to do with connecting databases (unless of course you can get permission to do that). You need to Google 'screen scraping'. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086108 Share on other sites More sharing options...
moleEE132 Posted July 15, 2010 Author Share Posted July 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086231 Share on other sites More sharing options...
dezkit Posted July 15, 2010 Share Posted July 15, 2010 What are you trying to say? You want to get all the data from another sql database to your own? You may want to export the sql in the export tab in the other database. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086234 Share on other sites More sharing options...
Pikachu2000 Posted July 15, 2010 Share Posted July 15, 2010 What do you mean the database is "too big"? Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086235 Share on other sites More sharing options...
optikalefx Posted July 15, 2010 Share Posted July 15, 2010 @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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086240 Share on other sites More sharing options...
trq Posted July 15, 2010 Share Posted July 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086242 Share on other sites More sharing options...
optikalefx Posted July 15, 2010 Share Posted July 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086258 Share on other sites More sharing options...
ajicles Posted July 15, 2010 Share Posted July 15, 2010 $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. Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086263 Share on other sites More sharing options...
moleEE132 Posted July 15, 2010 Author Share Posted July 15, 2010 thank you optikalefx. Ya that's exactly what i am trying to say, its only that i'm not sure how to put them in words properly. Will try out your codes and update on the outcomes soon thanks again Quote Link to comment https://forums.phpfreaks.com/topic/207714-extracting-information-from-server-database/#findComment-1086267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.