Philipp Hasenfratz: fehler bei variable

Beitrag lesen

Halihallo johann

$jahr = "$row['YEAR(datum)']";
echo " <br><br> $jahr";

diese variable erzeugt eine fehlermeldung!! nämlich diese:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /pfad/newv.php3 on line 49

http://www.google.ch/search?q=unexpected+T_ENCAPSED_AND_WHITESPACE%2C+expecting+T_STRING+or+T_VARIABLE+or+T_NUM_STRING+&ie=UTF-8&oe=UTF-8&hl=de&meta=
=> http://p2p.wrox.com/archive/beginning_php/2002-09/85.asp

<quote>
http://www.php.net/types.string#language.types.string.parsing
  you'll see that for simple array cases, you do NOT need to enclose a string
index within quotes.  What's happening in your example is that you're
attempting to find the index "'userid'" in the post array, where the single
quotes are part of the string index.  PHP wasn't expecting the ' character when
parsing tokens, since it knew it was parsing an array index.  Valid array
indexes are strings, variables, or numbers, which is why the parse error you
see says "expected T_STRING, ...".
</quote>

zu einfachem Deutsch: Einfach die Quotingzeichen weg und schon sollte es funktionieren.

Google weiss _alles_! ;)

Viele Grüsse

Philipp