It was really a challenging task to upload any data (fixed pattern) from a file into Mysql table in Php. So I tried many queries and also search on forums as well, finally I got this:
$query=“LOAD DATA INFILE ‘”.$_SERVER[‘DOCUMENT_ROOT’].“/my_formatted_data_file.txt’ INTO TABLE my_db_table FIELDS TERMINATED BY ‘|’ IGNORE 1 LINES;”;
And it really works.
Recently I was working on one of project. There I need to post some data to HTTPs server. I though for using CURL in php. But it was very tough to submit the XML in form of post. I had tried a lots of code from net, but none were success full. so I tried the below:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/xml’));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
It was really very helpful and got the desired result.