Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] tabela zależna od istnienia pliku pomocy gdzi
Forum PHP.pl > Forum > Przedszkole
Piotrwusek
chcę żeby tabela była zależna od pliku i nie zrobiłem skrypt ale nie działa nie wiem co zrobić

proszę o pomoc i o odpowiedż


  1. <?php
  2. /*
  3.  
  4. Copyright Š 2007 Piotrwusek
  5.  
  6. Released under the GNU General Public License
  7. */
  8.  
  9.  
  10. function url_exists($url) {
  11. $x = fopen($url, "r");
  12. if($x == False) {
  13. return False;
  14. } else {
  15. return True;
  16. }
  17. }
  18.  
  19.  
  20.  
  21.  
  22. include("includes/language/polish.php");
  23. ?>
  24. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  25. <html>
  26. <head>
  27. <meta name="verify-v1" content="<?php echo GOOGLE; ?>" />
  28. <link rel="SHORTCUT ICON" href="<?php echo IKONA; ?>">
  29. <meta http-equiv="content-type" content="<?php echo KODOWANIE; ?>" />
  30. <meta name="author" content="<?php echo AUTOR; ?>" />
  31. <meta name="description" content="Strona klasy 3a gimnazjum" />
  32. <meta name="keywords" content="<?php echo KEYWORDS; ?>" />
  33. <meta name="copyright" content="<?php echo PRAWA; ?>" />
  34. <meta http-equiv="content-language" content="pl" />
  35. <meta name="distribution" content="GLOBAL" />
  36. <link rel="stylesheet" href="stylesheet.css" type="text/css" />
  37. <title><?php echo TITLE; ?></title>
  38. </head>
  39. <body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" background="images/strona/tlo.bmp">
  40. <table border="0" width="908" height="" align="CENTER" valign="TOP" cellspacing="0" cellpadding="0" bgcolor="white">
  41. <tr>
  42. <td background="images/strona/tabela-prawo.bmp" width="11"></td>
  43. <td><?php require("includes/header.php"); ?>
  44. <table border="0" align="CENTER" valign="TOP" cellspacing="0" cellpadding="0" leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0">
  45. <tr>
  46. <?
  47. $a = url_exists("http://www.zsp3a.za.pl/includes/kolumna-lewa.php");
  48.  
  49. if($a == False) {
  50. echo("<td width="3"></td>
  51. <td width="201"><?php require("includes/kolumna-lewa.php"); ?></td>
  52. <td width="700"></td>
  53. <td width="3"></td>");
  54. } else {
  55. echo("<td width="3"></td>
  56. <td width="201"><?php require("includes/kolumna-lewa.php"); ?></td>
  57. <td width="500"></td>
  58. <td width="201"></td>
  59. <td width="3"></td>");
  60. }
  61. ?>
  62. </tr>
  63. </table>
  64.  
  65. <?php require("includes/stopka.php"); ?></td>
  66.  
  67. <td background="images/strona/tabela-lewo.bmp" width="11"></td>
  68. </tr>
  69. <tr background="images/strona/tabela-dol_1.bmp" height="10" widht="201"></tr>
  70. <td ></td>
  71. <td></td>
  72. </table>
  73. <br />
  74. </body>
  75. </html>
JaRoPHP
Cytat
chcę żeby tabela była zależna od pliku i nie zrobiłem skrypt ale nie działa nie wiem co zrobić

Zrobiłeś skrypt, czy nie? smile.gif
Czym objawia się nie działanie?
Piotrwusek
zrobiłem skrypt

strona jest czysta nic na niej nie ma

pierwsza cześć skryptu
  1. <?php
  2. function url_exists($url) {
  3. $x = fopen($url, "r");
  4. if($x == False) {
  5. return False;
  6. } else {
  7. return True;
  8. }
  9. }
  10. ?>


druga
  1. <?
  2. $a = url_exists("http://www.zsp3a.za.pl/includes/kolumna-lewa.php");
  3.  
  4. if($a == False) {
  5. echo("<td width="3"></td>
  6. <td width="201"><?php require("includes/kolumna-lewa.php"); ?></td>
  7. <td width="700"></td>
  8. <td width="3"></td>");
  9. } else {
  10. echo("<td width="3"></td>
  11. <td width="201"><?php require("includes/kolumna-lewa.php"); ?></td>
  12. <td width="500"></td>
  13. <td width="201"></td>
  14. <td width="3"></td>");
  15. }
  16. ?>

a 1 post wyżej cała strona

można efekty skryptu również zobaczyć na zsp3a.za.pl
JaRoPHP
na sam początek daj:
  1. <?php
  2. ini_set('error_reporting', E_ALL | E_STRICT);
  3. ini_set('display_errors', 'On');
  4. ?>

I powiedz, jaki jest rezultat.
fiszol
Raczej nic nie wyświetli bo nadpisze error_reporting tym co ma w 3 linii aktualnie
Piotrwusek
Cytat(JaRoPHP @ 16.06.2007, 20:48:56 ) *
na sam początek daj:
  1. <?php
  2. ini_set('error_reporting', E_ALL | E_STRICT);
  3. ini_set('display_errors', 'On');
  4. ?>

I powiedz, jaki jest rezultat.


nic sie nie stało jest cały czas czysta strona może to coś miec związek z inclde (wstawianiem zawartości pliku są w tym pliku definicje stałych pożna zobaczyć na zsp3a.za.pl)
fiszol
wywal ze swojego kodu error_reporting(false); i dodaj to na samym początku:

  1. <?php
  2. if(!ini_set('error_reporting', E_ALL | E_STRICT))
  3. {
  4. echo 'błąd, zmiana ustawień dla error_reporting nie powiodła się';
  5. }
  6. if(!ini_set('display_errors', 'On'))
  7. {
  8. echo 'błąd, zmiana ustawień dla display_errors nie powiodła się';
  9. }
  10. ?>

teraz musi coś wyświetlić
Piotrwusek
tak samo ni sie nie dzieje
Ziels
Cytat(fiszol @ 16.06.2007, 21:00:43 ) *
wywal ze swojego kodu error_reporting(false); i dodaj to na samym początku:

  1. <?php
  2. if(!ini_set('error_reporting', E_ALL | E_STRICT))
  3. {
  4. echo 'błąd, zmiana ustawień dla error_reporting nie powiodła się';
  5. }
  6. if(!ini_set('display_errors', 'On'))
  7. {
  8. echo 'błąd, zmiana ustawień dla display_errors nie powiodła się';
  9. }
  10. ?>

teraz musi coś wyświetlić



Nie musi, musiało by gdybyś die() dał miast echo
Darti
tą część z warunkiem zastąp tym, może już zadziała (a przynajmniej coś się wyświetli) :
  1. <?php
  2. $a = url_exists("http://www.zsp3a.za.pl/includes/kolumna-lewa.php");
  3.  
  4. if($a == False) {
  5. echo('<td width="3"></td><td width="201">');
  6. require("includes/kolumna-lewa.php");
  7. echo('</td><td width="700"></td><td width="3"></td>');
  8. } else {
  9. echo('<td width="3"></td><td width="201">');
  10. require("includes/kolumna-lewa.php");
  11. echo ('</td><td width="500"></td><td width="201"></td><td width="3"></td>');
  12. }
  13. ?>
Piotrwusek
dzięki działa ale jeszcze trochę kuleje
powstał taki skrypt

  1. <?php
  2. /*
  3.  
  4. Copyright (c) 2007 Piotrwusek
  5.  
  6. Released under the GNU General Public License
  7. */
  8. if(!ini_set('error_reporting', E_ALL | E_STRICT))
  9. {
  10. echo 'błąd, zmiana ustawień dla error_reporting nie powiodła się ';
  11. }
  12. if(!ini_set('display_errors', 'On'))
  13. {
  14. echo '< błąd, zmiana ustawień dla display_errors nie powiodła się ';
  15. }
  16.  
  17.  
  18.  
  19.  function url_exists($url) {
  20. $x = fopen($url, "r");
  21. if($x == False) {
  22. return False;
  23. } else {
  24. return True;
  25. }
  26. }
  27.  
  28.  
  29.  
  30. include("includes/language/polish.php");
  31. ?>
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  33. <html>
  34. <head>
  35. <meta name="verify-v1" content="<?php echo GOOGLE; ?>" />
  36. <link rel="SHORTCUT ICON" href="<?php echo IKONA; ?>">
  37. <meta http-equiv="content-type" content="<?php echo KODOWANIE; ?>" />
  38. <meta name="author" content="<?php echo AUTOR; ?>" />
  39. <meta name="description" content="Strona klasy 3a gimnazjum" />
  40. <meta name="keywords" content="<?php echo KEYWORDS; ?>" />
  41. <meta name="copyright" content="<?php echo PRAWA; ?>" />
  42. <meta http-equiv="content-language" content="pl" />
  43. <meta name="distribution" content="GLOBAL" />
  44. <link rel="stylesheet" href="stylesheet.css" type="text/css" />
  45. <title><?php echo TITLE; ?></title>
  46. </head>
  47. <body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" background="images/strona/tlo.bmp">
  48. <table border="0" width="908" height="" align="CENTER" valign="TOP" cellspacing="0" cellpadding="0" bgcolor="white">
  49. <tr>
  50. <td background="images/strona/tabela-prawo.bmp" width="11"></td>
  51. <td><?php require("includes/header.php"); ?>
  52. <table border="1" align="CENTER" valign="TOP" cellspacing="0" cellpadding="0" leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0">
  53. <tr>
  54.  
  55. <?php
  56. $a = url_exists("http://www.zsp3a.za.pl/includes/kolumna-lewa.php");
  57.  
  58. if($a == True) {
  59. echo('<td width="3"></td><td width="201">');
  60. require("includes/kolumna-lewa.php");
  61. echo('</td><td width="700"><table border="0" width="700" align="JUSTIFY" valign="TOP" cellspacing="0" cellpadding="0">
  62. <tr>
  63. <td><php require("includes/zawartosc.php"); ?></td>
  64. </tr>
  65. </table></td><td width="3"></td>');
  66. } else {
  67. echo('<td width="3"></td><td width="201">');
  68. require("includes/kolumna-lewa.php");
  69. echo ('</td><td width="500"><table border="0" width="500" align="JUSTIFY" valign="TOP" cellspacing="0" cellpadding="0">
  70. <tr>
  71. <td><?php require("inludes/zawartosc.php"); ?></td>
  72. </tr>
  73. </table></td><td width="201"><?php require("includes/kolumna-lewa.php"); ?></td><td width="3"></td>');
  74. }
  75. ?>
  76. </tr>
  77. </table>
  78.  
  79. <?php require("includes/stopka.php"); ?></td>
  80.  
  81. <td background="images/strona/tabela-lewo.bmp" width="11"></td>
  82. </tr>
  83. <tr background="images/strona/tabela-dol_1.bmp" height="10" widht="201"></tr>
  84. <td ></td>
  85. <td></td>
  86. </table>
  87. <br />
  88. </body>
  89. </html>


a na stronie wyświetla sie

błąd, zmiana ustawień dla display_errors nie powiodła się błąd, zmiana ustawień dla error_reporting nie powiodła się



co robić
Darti
Bo prawidłowo powinno być raczej tak:
  1. <?php
  2. ini_set('display_errors', 'On');
  3. ini_set('error_reporting', E_ALL | E_STRICT);
  4.  
  5. if (ini_get('error_reporting') != 4095))
  6. {
  7. echo 'błąd, zmiana ustawień dla error_reporting nie powiodła się ';
  8. }
  9. if(ini_get('display_errors') != 'On'))
  10. {
  11. echo '< błąd, zmiana ustawień dla display_errors nie powiodła się ';
  12. }
  13. ?>


Jeżeli w dalszym ciągu będzie wyskakiwało że "nie powiodło się" to znaczy że nie masz praw do stosowania funkcji ini_set i albo będziesz działał inaczej albo zrezygnujesz z raportowania błędów.
Piotrwusek
Cytat(Darti @ 17.06.2007, 12:30:18 ) *
Bo prawidłowo powinno być raczej tak:
  1. <?php
  2. ini_set('display_errors', 'On');
  3. ini_set('error_reporting', E_ALL | E_STRICT);
  4.  
  5. if (ini_get('error_reporting') != 4095))
  6. {
  7. echo 'błąd, zmiana ustawień dla error_reporting nie powiodła się ';
  8. }
  9. if(ini_get('display_errors') != 'On'))
  10. {
  11. echo '< błąd, zmiana ustawień dla display_errors nie powiodła się ';
  12. }
  13. ?>


Jeżeli w dalszym ciągu będzie wyskakiwało że "nie powiodło się" to znaczy że nie masz praw do stosowania funkcji ini_set i albo będziesz działał inaczej albo zrezygnujesz z raportowania błędów.



z tym kodem to wogóle nie działa
Darti
Cytat(Piotrwusek @ 17.06.2007, 10:53:10 ) *
z tym kodem to wogóle nie działa


To coś źle wkleiłeś ...
Piotrwusek
a może ktoś zrobi mi takie coś questionmark.gif
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.