Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][HTML]jak połączyc dwie funkcje ?, - na przykładzie
Luki2604
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

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


hej, uzywam dwóch funkcji w różnych skryptach:

$html .= "$val - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";

oraz

$html .= $val .' Odnotowano: '. date('H:i:s. d-F-Y.', filemtime($aDir."/".$val))."</a><hr><br>";

jak połączyc te dwie funkcje, aby były w jednym wierszu? ... próbowałem tak:

$html .= $val .' Odnotowano: '. date('H:i:s. d-F-Y.', filemtime($aDir."/".$val))." - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";

wtedy link USUN działa i usuwa plik, ale zarazem wywala błąd:

Warning: filemtime(): Stat failed for ./myfiles/CKK- 12597 (errno=2 - No such file or directory) in c:\usr\krasnal\www\tele\filestv.php on line 66
Usunieto ./myfiles/CKK- 12597
CKK- 12597 Odnotowano: 01:00:00. 01-January-1970. - Usun

Proszę o pomoc, bo już nie wiem, w czym błąd :/

Dzięki i pozdrawiam !
Go to the top of the page
+Quote Post
hedrazer
post
Post #2





Grupa: Zarejestrowani
Postów: 15
Pomógł: 1
Dołączył: 27.03.2009
Skąd: Pułtusk

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


Cytat(Luki2604 @ 29.07.2009, 10:38:58 ) *
Warning: filemtime(): Stat failed for ./myfiles/CKK- 12597 (errno=2 - No such file or directory) in c:\usr\krasnal\www\tele\filestv.php on line 66


Treść tego błędu jasno mówi iż plik do ktorego odwołujesz się, NIE ISTNIEJ...
sprawdz czy zmienna $val posiada prawidłową wartość...

ps. to o co pytasz na początku postu to jest zwykłe składania stringów, a nie funkcji. Ale to tak na marginesie (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post
Luki2604
post
Post #3





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

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


ale plik istnieje, bo go usuwa przecież (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Podejrzewam, ze zapytanie o datę pojawia się PO wykonaniu polecenia USUN i stad ten błąd... niestety nie wiem, jak się go pozbyć :/
Go to the top of the page
+Quote Post
hedrazer
post
Post #4





Grupa: Zarejestrowani
Postów: 15
Pomógł: 1
Dołączył: 27.03.2009
Skąd: Pułtusk

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


oczywiście ze to jest powodem bledu.

  1. <?php
  2. $file = $aDir."/".$val;
  3. $mTime = filemtime($file);
  4. if (unlink($file))
  5.    echo "ok. usunieto plik ({$file}); data ostatniej modyfikacji tego pliku: {$mTime}";
  6. else
  7.    echo "blad";
  8. ?>


Ten post edytował hedrazer 29.07.2009, 14:57:33
Go to the top of the page
+Quote Post
Luki2604
post
Post #5





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

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


u mnie to tak wygląda:

  1. <?php
  2. function dirList ($directory)
  3. {
  4.    $results = array();
  5.    $handler = opendir($directory);
  6.    while ($file = readdir($handler)) {
  7.  
  8.        if ($file != '.' && $file != '..' && is_file($directory."/".$file) == TRUE)
  9.            $results[] = $file;
  10.    }
  11.  
  12.    closedir($handler);
  13.    return $results;
  14. }
  15.  
  16. header('Content-type: text/html; charset=utf-8');
  17.  
  18. //<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  19. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
  20. $html .= '<html>';
  21. $html .= '<head>';
  22. $html .= '<meta http-equiv="refresh" content="4;url=http://crm2.orcansi.com/luki/files.php" />';
  23. $html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
  24. $html .= '<title>';
  25. $html .= "Pliki";
  26. $html .= '</title>';
  27. $html .= '</head>';
  28. $html .= '<body>';
  29. $html .= "<div>";
  30.  
  31. $aDir = "./myfiles";
  32.  
  33. $files = dirList($aDir);
  34.  
  35. if (TRUE == array_key_exists("deleteFile", $_GET))
  36.  {
  37.  $file = $aDir."/".$_GET["deleteFile"];
  38.  if ($file == $_SERVER["SCRIPT_NAME"])
  39.    {
  40.    $html .= "Nie mozna usunac <br>";
  41.    }
  42.    else if (file_exists($file) && unlink($file))
  43.    {
  44.    $html .= "Usunieto $file<hr><br>";
  45.    }
  46.  else
  47.    {
  48.    $html .= "Blad podczas usuwania $file<br>";
  49.    }
  50.  }
  51. foreach ($files as $val)
  52.  {
  53.  $html .= "$val - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";
  54.  }
  55.  
  56. $html .= "</div>";
  57. $html .= '</body>';
  58. $html .= '</html>';
  59.  
  60. echo $html;
  61. ?>


ok, już znalazlem błąd (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
trzeba wiersz
  1. <?php
  2. $files = dirList($aDir);
  3. ?>
przenisc nizej przed
  1. <?php
  2. foreach ($files as $val)
  3. ?>
i jest ok.

A wiecie może jak zrobić, aby wyświetlało posortowane np wg daty ? Teraz wyświetla wg nazwy

Ten post edytował Luki2604 29.07.2009, 15:40:48
Go to the top of the page
+Quote Post
Wicepsik
post
Post #6





Grupa: Zarejestrowani
Postów: 1 575
Pomógł: 299
Dołączył: 26.03.2009

Ostrzeżenie: (20%)
X----


Poczytaj o filemtime" title="Zobacz w manualu PHP" target="_manual
Go to the top of the page
+Quote Post
Luki2604
post
Post #7





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

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


filemname - pobiera i wyswietla, ale nie sortuje przeciez ?
Teraz tak mi wyswietla:

33333.ckk Odnotowano: 09:26:40. 30-July-2009.
44444.ckk Odnotowano: 09:26:42. 30-July-2009.
55553.ckk Odnotowano: 09:28:47. 30-July-2009.
77777.ckk Odnotowano: 09:28:54. 30-July-2009.
78945.ckk Odnotowano: 11:31:44. 30-July-2009.
88888.ckk Odnotowano: 09:28:56. 30-July-2009.
96563.ckk Odnotowano: 13:28:37. 29-July-2009.
99663.ckk Odnotowano: 11:32:45. 30-July-2009.
Go to the top of the page
+Quote Post
Fifi209
post
Post #8





Grupa: Zarejestrowani
Postów: 4 655
Pomógł: 556
Dołączył: 17.03.2009
Skąd: Katowice

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


Cytat(Luki2604 @ 30.07.2009, 12:42:57 ) *
filemname - pobiera i wyswietla, ale nie sortuje przeciez ?
Teraz tak mi wyswietla:

33333.ckk Odnotowano: 09:26:40. 30-July-2009.
44444.ckk Odnotowano: 09:26:42. 30-July-2009.
55553.ckk Odnotowano: 09:28:47. 30-July-2009.
77777.ckk Odnotowano: 09:28:54. 30-July-2009.
78945.ckk Odnotowano: 11:31:44. 30-July-2009.
88888.ckk Odnotowano: 09:28:56. 30-July-2009.
96563.ckk Odnotowano: 13:28:37. 29-July-2009.
99663.ckk Odnotowano: 11:32:45. 30-July-2009.


No nie, do sortowania znajdziesz odpowiednie funkcje w manualu.
Wicepsik podał Ci tylko jak odczytać datę.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.12.2025 - 11:44