Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Include
MrDziobak
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 28.08.2012

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


Chodzi o to że mam taki o kod:<?php
  1. session_start();
  2. include 'db.php'; // połączenie się z bazą danych
  3. if (isset($_SESSION['login'])) { // dostęp dla zalogowanego użytkownika?>
  4. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  5. <link rel=stylesheet href="style.css" TYPE="text/css" media="screen"/>
  6. <style type="text/css">
  7. body {
  8. background:url('images/') right;
  9. color: #000000;
  10. font-family: 'verdana';
  11. }
  12. </style>
  13. <div style='font-size: 80%;' align='left'>Witaj <b><?echo "$login";?></b>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Twoje punkty: <?include 'stan.php?user=$login';?></div>
  14. <hr color='purple'/>
  15. <center>
  16. <p>Jesteś na ukrytej części strony<br>
  17. <a href='wyloguj.php'>Wyloguj się</a></p>
  18. <?php } else {
  19. header('Location: index.php '); // niezalogowany użytkownik zostaje przekierowany na stronę główną
  20. }
  21. ?>

Lecz przy napisie twoje punty wywala mi błędy

Warning: include($url) [function.include]: failed to open stream: No such file or directory in C:\Program Files (x86)\WebServ\httpd\demo\page\indeks.php on line 15
Warning: include() [function.include]: Failed opening '$url' for inclusion (include_path='.;C:\php5\pear') in C:\Program Files (x86)\WebServ\httpd\demo\page\indeks.php on line 15

I za Chiny nie wiem co jest nie tak, bardzo proszę o pomoc (IMG:style_emoticons/default/nerdsmiley.png)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
b4rt3kk
post
Post #2





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Przecież wyraźnie jest napisane, że taki plik nie istnieje.
Go to the top of the page
+Quote Post
MrDziobak
post
Post #3





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 28.08.2012

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


Lecz gdy wpisze w url tą ścieżkę wszystko dobrze pokazuje.
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #4





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Spróbuj tak:

  1. <?include $_SERVER['DOCUMENT_ROOT'].'/stan.php?user=$login';?>
Go to the top of the page
+Quote Post
MrDziobak
post
Post #5





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 28.08.2012

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


Wpisałem tak
  1. <?include $_SERVER['DOCUMENT_ROOT'].'demo/page/stan.php?user=$login';?>

Bo skrypt mam w katalogu demo/page, winnik jest taki
Warning: include(C:/Program Files (x86)/WebServ/httpd/demo/page/stan.php?user=$login) [function.include]: failed to open stream: No error in C:\Program Files (x86)\WebServ\httpd\demo\page\indeks.php on line 14

Warning: include() [function.include]: Failed opening 'C:/Program Files (x86)/WebServ/httpd/demo/page/stan.php?user=$login' for inclusion (include_path='.;C:\php5\pear') in C:\Program Files (x86)\WebServ\httpd\demo\page\indeks.php on line 14
Go to the top of the page
+Quote Post
redeemer
post
Post #6





Grupa: Zarejestrowani
Postów: 915
Pomógł: 210
Dołączył: 8.09.2009
Skąd: Tomaszów Lubelski/Wrocław

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


Jaki wy plik chcecie inkludować? "stan.php?user=jakislogin"? Przecież takiego pliku nie ma, ale jest za to stan.php.
Go to the top of the page
+Quote Post
MrDziobak
post
Post #7





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 28.08.2012

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


Chciałbym aby include zwracał wartość stan.php?user=jakislogin
Go to the top of the page
+Quote Post
redeemer
post
Post #8





Grupa: Zarejestrowani
Postów: 915
Pomógł: 210
Dołączył: 8.09.2009
Skąd: Tomaszów Lubelski/Wrocław

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


Masz źle zaprojektowaną aplikację. Co robi stan.php? Zrób funkcje zwracającą status czy co tam zwracasz użytkownika (login jako argument funkcji) i wykonuj ją w odpowiednich miejscach (m.in. w stan.php i tam gdzie chcesz go zainkludować).
Go to the top of the page
+Quote Post
MrDziobak
post
Post #9





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 28.08.2012

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


Dzięki za pomoc problem rozwiązałem sam, niepotrzebnie zrobiłem następny plik, zrobiłem wszystko w jednym.
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: 29.09.2025 - 13:37