Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] GET & switch
krystian1991x
post
Post #1





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

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


Chciałbym ustawić domyślną wartość get gdy nie jest ona zainicjowana nawet aktualnie mam coś takiego
  1. $site = $_GET['id'];
  2. if($site != "") {
  3. switch($site) {
  4. case $site:
  5. require("$site.php");
  6. break;
  7. }
  8. }

ale za bardzo nie wiem jak to zrobić ;/ i mam jeszcze jeden problem czy da się przekazywać 2 wartości w jednej zmiennej get ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
krystian1991x
post
Post #2





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

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


zamiast strony domyślnej news.php pojawia się teraz taki błąd (IMG:style_emoticons/default/smile.gif) dopiero jak wprowadze wartość do zmiennej get np news to wtedy dopiero wczytuje news.php
Cytat
Fatal error: Uncaught exception 'Exception' with message 'Unable to load template file '.tpl'' in /home/edesing/public_html/libs/sysplugins/smarty_internal_template.php:167 Stack trace: #0 /home/edesing/public_html/libs/sysplugins/smarty_internal_template.php(538): Smarty_Internal_Template->isExisting(true) #1 /home/edesing/public_html/templates_c/c0360d049dff10f364dfc53ba2cc3958abf6ee6d.file.index.tpl.php(52): Smarty_Internal_Template->getRenderedTemplate() #2 /home/edesing/public_html/libs/sysplugins/smarty_internal_template.php(425): include('/home/edesing/p...') #3 /home/edesing/public_html/libs/sysplugins/smarty_internal_template.php(542): Smarty_Internal_Template->renderTemplate() #4 /home/edesing/public_html/libs/Smarty.class.php(339): Smarty_Internal_Template->getRenderedTemplate() #5 /home/edesing/public_html/libs/Smarty.class.php(383): Smarty->fetch('index.tpl', NULL, NULL, NULL, true) #6 /home/edesing/public_html/index.php(22): Smarty->display('index.tpl') #7 {main} thrown in /home/edesing/public_html/libs/sysplugins/smarty_internal_template.php on line 167


ha działa ostateczne rozwiązanie to
  1. if (!isset($_GET['id'])) { $_GET['id'] = 'news'; }
  2. $site = $_GET['id'];
  3.  
  4. if($site != "") {
  5. switch($site) {
  6. case $site:
  7. require("$site.php");
  8. break;
  9. }
  10. }
Go to the top of the page
+Quote Post

Posty w temacie


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: 13.10.2025 - 16:57