View Full Version : Converting Page string into variables so can update MySQL

02-15-2010, 06:35 PM

I have a mysql db on 1 server and a script to update the mysql db on another server (unfortunately), my server will not let me connect so i have gone down the page scraping route to add to the mysql.

I have a simple page with infomation (after scraping) within it that i would like to send to mySQL db, but i'm not sure how to tell mysql which bits of data should go where, if i could make them variables i could add them accordingly.

After page scrape data examples looks like this in the view source file, all fields are seperated with < >

How can i take each <FIELD> and make it a variable in order so i can update mysql, there are 8 fields of data i wish to extract from each block from within the < >

View Source Info looks like this





HERE IS MY PHP PAGE SCRAPER CODE, not sure if this needS to be changed.

//$ch = curl_init();
//curl_setopt($ch, CURLOPT_URL, $url);
//curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
//$data = curl_exec ($ch);
//curl_close ($ch);
// you can do something with $data like explode(); or a preg match regex to get the exact information you need
//echo $data;

Thanks In-adavance

02-15-2010, 07:14 PM
I don't understand why you need to do this. Do you have access to both servers (and cpanel or any other control panel access to the server with the database)?

02-15-2010, 07:44 PM

Yes i do have access to both servers and use cpanel, but everywhere i look informs me i cant update my database from a different server.

If you could advise me how i would be grateful


02-15-2010, 08:06 PM
If you look for the Remote MySQL in cpanel on the server with the database, and add
%.%.%.% to the Access Hosts list then you connect to your database putting the credentials in the connection info of your script, and specifying the IP/domain name of the server instead of localhost for the host name
So instead of

mysql_connect('localhost', 'username', 'password');
it would be

mysql_connect('domain.com', 'username', 'password');

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum