Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Funkcja echo nie działa
Forum PHP.pl > Forum > Przedszkole
Hajki
Witam mam problem w funkcją echo, która wyswietla tylko linki ze statusem ok.
Oto kod php:

  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7. $cookieFile = 'cookies/' . uniqid(true) . '.txt';
  8.  
  9. // Login
  10. $curl = curl_init();
  11. curl_setopt($curl, CURLOPT_URL, $link.'login.php');
  12. curl_setopt($curl, CURLOPT_COOKIEJAR, $cookieFile);
  13. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($curl, CURLOPT_HEADER, true);
  15. curl_setopt($curl, CURLOPT_POST, true);
  16. $postVars = array('username' => $login, 'password' => $pass, 'autologin' => 'on', 'login' => 'Zaloguj');
  17. curl_setopt($curl, CURLOPT_POSTFIELDS, $postVars);
  18. $resp = curl_exec($curl);
  19. curl_close($curl);
  20.  
  21. // Parse sid from cookie file
  22. $match = explode('sid', file_get_contents($cookieFile));
  23. $sId = trim($match[1]);
  24.  
  25. // Post
  26. $curl = curl_init();
  27. $temat1 = $link.'posting.php?mode=newtopic&f='.$temat;
  28. curl_setopt($curl, CURLOPT_URL, $temat1);
  29. curl_setopt($curl, CURLOPT_COOKIEFILE, $cookieFile);
  30. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  31. curl_setopt($curl, CURLOPT_HEADER, false);
  32. curl_setopt($curl, CURLOPT_POST, true);
  33. $postVars = array('subject' => $tytul,
  34. 'subject_e' => $message2,
  35.  
  36. 'message' => $message,
  37. 'sid' => $sId,
  38. 'f' => $temat,
  39. 'post' => 'Submit');
  40. curl_setopt($curl, CURLOPT_POSTFIELDS, $postVars);
  41. $result = curl_exec($curl);
  42. curl_close($curl);
  43.  
  44.  
  45.  
  46. $pattern = '#<a href="(.*?)">Tutaj</a>#';
  47. $ile = preg_match_all($pattern, $result, $matches, PREG_PATTERN_ORDER);
  48. $zwrot = $adres . '/' . $matches[1][0];
  49. $viewtopic = strpos($matches[1][0], 'viewtopic');
  50. $postlink = strpos($matches[1][0], 'postlink');
  51.  
  52. if($viewtopic !== false || $postlink !== false)
  53. {
  54. $status = "ok";
  55. echo "$i. <a href='$zwrot'>$zwrot </a><br>";
  56. }
  57. else
  58. $status = "bad";
  59. //print_r($matches);
  60. //echo $matches[1][0];
  61. //echo $resp;
  62. ?>



Kod odpowiedzialny za wyswietlanie:
  1. $zwrot = $adres . '/' . $matches[1][0];
  2. $viewtopic = strpos($matches[1][0], 'viewtopic');
  3. $postlink = strpos($matches[1][0], 'postlink');
  4.  
  5. if($viewtopic !== false || $postlink !== false)
  6. {
  7. $status = "ok";
  8. echo "$i. <a href='$zwrot'>$zwrot </a><br>";
  9. }
  10. else
  11. $status = "bad";


Otóż nic się nie dzieje, nie wyswietla ani błędnych ani dobrych ....
Proszę o pomoc!
chmiello
a może włącz raportowanie błędów i zobacz gdzie masz błąd ?

zamiast:
  1. error_reporting(~E_ALL);

daj:
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.