Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Stworzenie pliku w notatniku przejscie do nowej lini.
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Hej,
mam skrypt ktory otwiera plik w nottatniku tylko string niechce mi sie zawijac. Nie wiem dlaczego sad.gif

  1. <?php
  2. global $title;
  3. global $wpdb;
  4.  
  5. $date_start = $_GET['date_start'];
  6.  
  7. $date_end = $_GET['date_end'];
  8.  
  9. //End 1
  10. include "WP-ROOT-PATH/wp-config.php";
  11. $db = new mysqli('localhost', 'xxx', 'xxxx', 'xxx');
  12. // Test the connection:
  13. if (mysqli_connect_errno()){
  14. // Connection Error
  15. exit("Couldn't connect to the database: ".mysqli_connect_error());
  16. }
  17. $result = mysqli_query($db,"SELECT * FROM wp_ogloszenia_kupione WHERE add_date BETWEEN '$date_start' AND '$date_end'");
  18.  
  19. $gcid = "/<$>gc";
  20.  
  21. //zawartość pliku
  22.  
  23. $file = 'myText.txt';
  24.  
  25. $id = '1'.$file;
  26. //explode($delimiter, $id);
  27.  
  28. $content = "<PMTags1.0 win>". PHP_EOL;
  29. $content .= . PHP_EOL;
  30.  
  31. while($row = mysqli_fetch_array($result))
  32. {
  33. $content .= "<@win:><\<>win>". $row['kategoria'] . PHP_EOL;
  34. $content .= "<@tekst:><\<>tekst><$>";
  35. $content .= $row['text'];
  36. $content .= $gcid.$row['id'].'/'. PHP_EOL;
  37. }
  38.  
  39. utf8_encode($content);
  40. echo $content;
  41. //Stworzenie pliku
  42. $fp = fopen(trim(trim($id)),"wb");
  43.  
  44. fwrite($fp,$content);
  45. fwrite($fp, pack("CCC",0xef,0xbb,0xbf));
  46. fopen(trim(trim($id)),"r");
  47. fclose($fp);
  48. //End 4
  49. //5 - Otwarcie pliku
  50.  
  51.  
  52.  
  53. if (file_exists(trim($id))) {
  54. header('Content-Description: File Transfer');
  55. header('Content-Type: application/octet-stream');
  56. header('Content-Disposition: attachment; filename='.basename(trim($id)));
  57. header('Content-Transfer-Encoding: binary');
  58. header('Expires: 0');
  59. header('Cache-Control: must-revalidate');
  60. header('Pragma: public');
  61. header('Content-Length: ' . filesize(trim($id)));
  62. flush();
  63. readfile(trim($id));
  64. }


Ten post edytował cykcykacz 30.07.2013, 08:51:09
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 05:25