PHP - How To Exportt Encoded Utf-8 Csv?
Hello,
I am trying to export data from database. the exported data is creted with wrong encoding. I am using this code: header("Pragma: public"); header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/force-download;charset=utf-8; encoding=UTF-8"); header('Content-Disposition: attachment; filename="'.$newFile.'"'); header("Content-Transfer-Encoding: binary"); header('Content-Length: '.@filesize($path)); Please help with the encoding. Thanks. Similar Tutorialsso I've been putting all of my php scripts to exe to protect some of the code I have written, say I write a simple loop script like below <?php $REPEAT = 1000; $ECHO = "CLUEL3SS"; for($cwb=1; $cwb!=$REPEAT; $cwb++) { echo "#$cwb: $ECHO\n"; } sleep(99999999); ?> Now how can I set the variable $REPEAT when the script is in .exe form and I cannot edit the code I have tried $REPEAT = fgets(STDIN); That doesnt seem to work though when I have 5+ variables to assign and I have an array set like like $Variable[] = 12345799; $Variable[] = 34324555; $Variable[] = 34289789; $Variable[] = 32899090; How can I use a text file to set these options? maybe have the variables assigned in a text file like Code: [Select] ; this is a comment, this will be ignored REPEAT : 1000 ; this is another comment, ignored also... ECHO : CLUEL3SS ; comment Variable : 3423423 Variable : 2903890 Variable : 3948903 Variable : 9823900 How would I have the php script read the text file in that format to set the variables? Hello all, I have a script I have been working on that retrieves my email from my mail server using some of the imap_functions. Everything works fine except for the emails that were sent from my blackberry. I have done some research and it seem to be something to do with the encoding that the blackberry uses. I have found a little bit of code that I was hoping would solve the issue. My goal is to get the body content from email that was produced with my blackberry and put bits of this body into a database. Then I want to do a report from that database once a week. I have developed a script that will retrieve all other message except from my blackberry. Does anyone know how blackberry encodes their body content? jmr3460 Hey guys, I have a script that attempts to call the database of my forums to find the last games played on each of their xbox live profiles. However when it attempts to call the image, it encodes the url - so http://tiles.xbox.com/tiles/tT/MX/0mdsb2JgbA9ECgQJGgYfVlpWL2ljb24vMC84MDAwIAABAAAAAP04M6o=.jpg turns into http%3A%2F%2Ftiles.xbox.com%2Ftiles%2FtT%2FMX%2F0mdsb2JgbA9ECgQJGgYfVlpWL2ljb24vMC84MDAwIAABAAAAAP04M6o%3D.jpg which makes the URL not work anymore so the script gives an error. I've tried urldecode() on numerous variables and it won't work. If I call the variable for the image on the page that submits the form it returns a normal address. Anyone have any ideas? Thanks! How can i check if a string is URL encoded or not using PHP Hi guys, I'm parsing a bunch of html sources, some of them (a minority) contain base64 encoded URLs. At least 20-30 URLs per page. Some of the information I need is taken from the URLs. I'm looking for a way to parse these URLs without losing too much time (20-30 URLs per page and I need to parse about 10k pages daily). Should I regex each source individually for base64 encoded URLs and then decode them each time and isn't that going to take a lot of time/resources (especially considering it's only a minority that have the base64 URLs in them)? Or is there a better way to do it? Code snippets are absolutely welcome! Thank you in advance <?php // rss page - $feed_url = "http://blog.kyleramirez.com/feed/"; // Load XML. $xml = simplexml_load_file($feed_url); // How many items to display from the RSS Feed ... $count = 3; // Grabbing the NameSpace URI for "itms" and "content" ... foreach ($xml->channel->item as $item) { $ns_content = $item->children('http://purl.org/rss/1.0/modules/content/'); if($count > 0){ echo " <ul class=\"pageitem\"> <li class=\"textbox\"><span class=\"header\">{$item->title}</span> {$ns_content->encoded} </li> <li class=\"menu\"> <span class=\"name\"><a href='{$item->link}'>View</a></span></li></ul> "; }else{ Return; } $count--; } ?> Above is a snippet of code used to extract the content:encoded and title from my RSS feed. I am looking for a way to strip the content part of a few tags, namely style and size and width tags so that I can fit it into the mobile section of my website. The mobile site is m.kyleramirez.com. You will be able to see how the rss feed is implemented there. This shouldn't be that complicated. I was trying to the str_replace to do it but I'm not sure how to put it in there. Any ideas? {$ns_content->encoded} is where the entire post is showing up. How do I add a str_replace to that? Hey everyone... Been over a year or more since I have had seek help here but I have something that I just do not understand. I am submitting a from from one domain - www.mydomain.com - to a form handler on another domain - www.theirdomain.com all under https. The form data is getting to theridomain.com just fine, the other side is handling it properly and all is well there. The issue is they are taking the response they generate and shipping it out via cURL using the below (they were nice enough to share this with me). Code: [Select] $url = $_SESSION['request']['retUrl']; $fields = array( 'hash'=>rawurlencode($hash), 'responseText'=>rawurlencode($_SESSION['response']['responseText']), 'cid'=>rawurlencode($_SESSION['request']['cid']), 'name'=>rawurlencode($_SESSION['request']['name']), 'actCode'=>rawurlencode($_SESSION['response']['actCode']), 'apprCode'=>rawurlencode($_SESSION['response']['applCode']), 'Token'=>rawurlencode($_SESSION['response']['token']), 'req_number'=>rawurlencode($_SESSION['request']['req_number']), ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); if (isset($_SESSION['request']['Address1'])) { $Address = array( 'Address1'=>rawurlencode($_SESSION['request']['Address1']), 'Address2'=>rawurlencode($_SESSION['request']['Address2']), 'City'=>rawurlencode($_SESSION['request'][City']), 'State'=>rawurlencode($_SESSION['request'][State']), 'Zip'=>rawurlencode($_SESSION['request']['Zip']), 'Country'=>rawurlencode($_SESSION['request']['Country']), ); foreach($Address as $key=>$value) { $Address_string .= $key.'='.$value.'&'; } rtrim($Address_string,'&'); } $end = array( 'END'=>"END" ); foreach($end as $key=>$value) { $end_string .=$key.'='.$value; } rtrim($end_string,'&'); I have worked for almost a week and I CANNOT snag the incoming data! All I am trying to do is collect this and convert it into $_SESSION data for use on a success page. If any one has any thoughts or in site, please.... Friends, I developed a script in php & i tested the script before encoding & its working fine. After i encoded the script through ionCube PHP Encoder & uploaded in my server but the file shows only blank page. Its not executing after encoding. What is the problem ?? How to fix it ? I have searched for the solution for so long and I still could not solve my problem. I have a localhost server where it stored some pdf files for download.
I implemented the following function to force the download:
if(isset($_POST['dlPDF'])) { $file = $_SERVER['DOCUMENT_ROOT'] .'/Upload/'.$pdfName; header("Content-Type: application/pdf"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$pdfName"); header("Content-Transfer-Encoding: binary"); // read the file from disk readfile($file); }However I could not open the pdf file properly since it says "the pdf file is not correctly encoded". FYI, the downloaded pdf file is always a few Kb larger than the original file. Please kindly let me know if there is anything I can do to make the pdf readable and I appreciate your help. |