Page 1 of 1

unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE

Posted: Mon Oct 31, 2005 8:47 am
by Curtis782
Newbie question:

When I use this code (line 494):

Code: Select all

echo "<option selected value='$myrow[\"partNo1\"]' class='style10'>&nbsp;</option>";
I get the following error:

Parse error: parse error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /path-to/modify.php on line 494

How can I appropriately mark up the $myrow["partNo1"] ?

Re: unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE

Posted: Mon Oct 31, 2005 8:57 am
by feyd

Code: Select all

echo "<option selected value='{$myrow["partNo1"]}' class='style10'>&nbsp;</option>";

Posted: Mon Oct 31, 2005 9:11 am
by Moocat
What about:

Code: Select all

echo "<option selected value=",$myrow['partNo1']," class='style10'>&nbsp;</option>";
?

Posted: Mon Oct 31, 2005 9:41 am
by Chris Corbyn
Moocat wrote:What about:

Code: Select all

echo "<option selected value=",$myrow['partNo1']," class='style10'>&nbsp;</option>";
?
That will give a parse error. You use dots "." to concatenate, not commas.

It may not be any faster than just using the variable inside the double quotes however since the interpreter will still scan the double quoted string for variables to parse. Doing that, along with the use of single quotes has indeed been found to be faster however :D

Posted: Mon Oct 31, 2005 9:51 am
by foobar
d11wtq wrote:
Moocat wrote:What about:

Code: Select all

echo "<option selected value=",$myrow['partNo1']," class='style10'>&nbsp;</option>";
?
That will give a parse error. You use dots "." to concatenate, not commas.

It may not be any faster than just using the variable inside the double quotes however since the interpreter will still scan the double quoted string for variables to parse. Doing that, along with the use of single quotes has indeed been found to be faster however :D
Liar, liar, pants on fire.

Code: Select all

echo 'a', 'b', 'c';
^This works fine, since you can pass multiple parameters to echo. It's actually faster than concatenation, I've heard.

Posted: Mon Oct 31, 2005 9:55 am
by Chris Corbyn
*gulps* :oops:

It's OK every knows I'm still a n00b anyway :P

Posted: Mon Oct 31, 2005 10:15 am
by foobar
d11wtq wrote:*gulps* :oops:

It's OK every knows I'm still a n00b anyway :P
|'|`´| jU57 700 |`´|U(|-| 0|= 4 1337 |-|4><><0|2

*pant* *pant* 8O