I pull a data from o开发者_StackOverflow社区ther website by using curl but how to store in my local database.
$url = 'http://sample.com/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
I just want post some categories and sample of data.
right.
well, i asume you're using mysql as database. if you have allready set up your database including a table owning a blob or text formatted field you can easily store the data there by sending a query like:
"INSERT INTO mytable SET curlData='".$data."';"
with PHP you can connect to your DB via mysql_connect() after selecting the desired database with mysql_select_db() you can start sending queries to the db.
use the mysql_connect() php-native-call to do so.
I hope i was helpful now ;-)
by the way, check out the php-mysql manual for further information.
精彩评论