...

View Full Version : Parse error: syntax error, unexpected ']'



Mihai
03-09-2008, 08:19 PM
echo '
if($row[public] == "yes") {
$public = "public post";
} else {
$public = "private post";
}
$text = "$blog_content";
$message = stripslashes($text)';


anything wrong with this ?
i get this error
Parse error: syntax error, unexpected ']'

:confused:

Inigoesdr
03-09-2008, 08:27 PM
Put any string you are using to access an array variable in quotes: $row['public']. Normally PHP will allow you to not use the quotes(which is poor coding practice), but in this case the "public" reserved word is causing the error.

p4plus2
03-09-2008, 08:27 PM
try changing

[public]
to this

['public']


Inigoesdr beat me by like 2 seconds....lol

Inigoesdr
03-09-2008, 08:28 PM
Why did you add the echo, Mihai?

Mihai
03-09-2008, 08:31 PM
no reason at all ;-)

p4plus2
03-09-2008, 08:34 PM
reguardlesss of the reason why the final code should look like this:



if($row['public'] == "yes") {
$public = "public post";
}
else {
$public = "private post";
}
$text = "$blog_content";
$message = stripslashes($text)';

(sorry I'm picky on how I indent my code so I can read it and edit it easier)

Mihai
03-09-2008, 09:19 PM
<php>
if($row[$public] == "yes")]

$public = "public post";

} else {

$public = "private post";

}

$text = "$blog_content";

$message = stripslashes($text);
</php>

same error message :Parse error: syntax error, unexpected T_PUBLIC, expecting ']'

p4plus2
03-09-2008, 10:48 PM
if($row[$public] == "yes")]

$public = "public post";

} else {

$public = "private post";

}

$text = "$blog_content";

$message = stripslashes($text);

should be


if($row['public'] == "yes") {
$public = "public post";
}
else {
$public = "private post";
}
$text = "$blog_content";
$message = stripslashes($text);


COPY THAT EXACTLY AS I HAVE IT.

you keep adding a ] instead of {



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum