WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   PHP: Warum kommt da nix? (http://www.wcm.at/forum/showthread.php?t=41898)

pirate man 05.01.2002 21:29

PHP: Warum kommt da nix?
 
ich bastel grad an einem script und hab dabei eine unlogische "entdeckung" gemacht

eine schleife:
PHP-Code:

if($id == "1")
{
setlocale("LC_ALL","de_DE");
$date strftime("%A, %d. %m. %Y"$temp_time);
}
elseif(
$id == "2")
{
$date strftime("%A, %B %d %Y"$temp_time);
}
else {} 

wenn ich $date ausgebe, wird das datum richtig angezeigt

noch eine schleife:
PHP-Code:

if($id == "1")
{
$kommentar "<a href=\"main.php?page=comments&id=$id\">Kommentare</a> [$anzahl]";
}
elseif(
$id == "2")
{
$kommentar "<a href=\"main.php?page=comments&id=$id\">Comments</a> [$anzahl]";
}
else {} 

wenn ich $kommentar ausgebe, wird nichts angezeigt

ich hab keine ahnung warum und hoffe, dass ihr mir helfen könnt

mqs 06.01.2002 16:08

Für was ist :
[$anzahl]
hinten bei $kommentar?

_m3 06.01.2002 20:50

Probier mal [ und ] escapen, also "\[$anzahl\]", ev. versucht er das in einem Array-Context auzulösen.

Schon mal das Error-Log gecheckt bzw. error_reporting() verwendet? Hilft vielleicht.

RaistlinMajere 06.01.2002 21:10

kann es sein, daß die variable $kommentar keinen wert zugewiesen bekommt, weil weder in if noch in elseif eingegangen wird? prüf mal mittels php-generierten js-alerts, ob die abfragen wirklich auch eingegangen werden.

ansonsten würde ich auch raten, die eckigen klammern zu escapen.

eine andere möglichkeit wäre auch noch, die ausgabe in strings und variablen aufzuteilen, anstatt die variablen in den ausgabestring sofort aufzunehmen.

also nicht: $string = "dies ist ein string und jetzt kommt eine $variable";

sondern: $string = "dies ist ein string und jetzt kommt eine " . $variable;

probier das mal aus.


Alle Zeitangaben in WEZ +2. Es ist jetzt 21:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag