Thread: E_PARSE error ?

E_PARSE error ?

From
PJ
Date:
I'm using php5, postgresql 8.3, apache2.2.8, FreeBSD 7.0
I don't understand the message:

*Parse error*: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING

the guilty line is:

list($page_id)=sqlget("
        select page_id from pages where name='$_SERVER['SCRIPT_NAME']'");

the variable value is "/index.php"

however, at the time of execution this has been cleared

So, the question is - What is the unexpected T_ENCAPSED_AND_WHITESPACE?
and What is actually expected? Are we talking about the content of
$_SERVER['SCRIPT_NAME'] or what is the syntax error? This is within php
code; could it be that the parser is reading this as something else,
like HTML?
I'm lost :((

Re: E_PARSE error ?

From
Ludwig Kniprath
Date:
Hi,
I think, this is the wrong list, it appears to be a PHP error.

Anyway, try to put the global $_SERVER['SCRIPT_NAME'] into {}brackets:

list($page_id)=sqlget("select page_id from pages where
name='{$_SERVER['SCRIPT_NAME']}'");

Hope, You're not lost anymore ...
Ludwig

PJ schrieb:
> I'm using php5, postgresql 8.3, apache2.2.8, FreeBSD 7.0
> I don't understand the message:
>
> *Parse error*: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING
>
> the guilty line is:
>
> list($page_id)=sqlget("
>        select page_id from pages where name='$_SERVER['SCRIPT_NAME']'");
>
> the variable value is "/index.php"
>
> however, at the time of execution this has been cleared
>
> So, the question is - What is the unexpected T_ENCAPSED_AND_WHITESPACE?
> and What is actually expected? Are we talking about the content of
> $_SERVER['SCRIPT_NAME'] or what is the syntax error? This is within
> php code; could it be that the parser is reading this as something
> else, like HTML?
> I'm lost :((
>


Re: E_PARSE error ?

From
"Scott Marlowe"
Date:
On Tue, Jun 3, 2008 at 10:14 AM, PJ <af.gourmet@videotron.ca> wrote:
> I'm using php5, postgresql 8.3, apache2.2.8, FreeBSD 7.0
> I don't understand the message:
>
> *Parse error*: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
> T_STRING or T_VARIABLE or T_NUM_STRING
>
> the guilty line is:
>
> list($page_id)=sqlget("
>       select page_id from pages where name='$_SERVER['SCRIPT_NAME']'");

Inside quotes, you need to remove the single quotes around your array
index.  Seems wrong, I know, but that's what php says to do.  I prefer
to concatenate.  so either:

list($page_id)=sqlget("select page_id from pages where
name='$_SERVER[SCRIPT_NAME]'");


list($page_id)=sqlget("select page_id from pages where
name=".$_SERVER['SCRIPT_NAME'].");

are legal.