Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected ']'

    PHP Code:
    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 ']'

    Last edited by Mihai; 03-09-2008 at 07:25 PM.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Mar 2008
    Posts
    103
    Thanks
    1
    Thanked 8 Times in 8 Posts
    try changing
    PHP Code:
    [public] 
    to this
    PHP Code:
    ['public'

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

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Why did you add the echo, Mihai?

  • #5
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    no reason at all ;-)

  • #6
    Regular Coder
    Join Date
    Mar 2008
    Posts
    103
    Thanks
    1
    Thanked 8 Times in 8 Posts
    reguardlesss of the reason why the final code should look like this:

    PHP Code:
         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)

  • #7
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    <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 ']'
    Last edited by Mihai; 03-09-2008 at 08:22 PM.

  • #8
    Regular Coder
    Join Date
    Mar 2008
    Posts
    103
    Thanks
    1
    Thanked 8 Times in 8 Posts
    PHP Code:
    if($row[$public] == "yes")]

    $public "public post";

    } else {

    $public "private post";

    }

    $text "$blog_content";

    $message stripslashes($text); 
    should be
    PHP Code:
         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 {

  • Users who have thanked p4plus2 for this post:

    Mihai (03-10-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •