#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0

    What is the error <<<END_OF_TEXT..END_OF_TEXT;


    Why can't i get text to display in the select tag?


    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/shawnhbk/public_html/az/notes/addcode.php on line 22

    PHP Code:
    if ($_POST['title'] == "")
        {
    //haven't seen the form, so show it
        
    $display_block = <<<END_OF_TEXT
        <form method="post" action="$_SERVER[PHP_SELF]">
        
        

      

     <p>
     <select name="language">
     
    $query="SELECT DISTINCT language FROM codes";
    if (
    $result = $mysqli->query($query)) {
    /* fetch object array */
    while (
    $row = $result->fetch_assoc()) {
    $language=$row['language'];

    echo("<option value="
    $language">$language</option>");

    }  
    $result->close();
    </select>

       <p><label for="title">title</label><br/>
        <input type="text" name="title">

       <p><textarea class="ckeditor" rows="4" cols="50"  name="code" ></textarea>

        <button type="submit" name="submit" value="send">Add Entry</button>
        </form>
     END_OF_TEXT;

  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,915
    Rep Power
    1045
    Hi,

    this code makes no sense whatsoever. The heredoc covers almost your whole code, while you have PHP and HTML randomly mixed. What is this supposed to do??
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0
    Originally Posted by Jacques1
    Hi,

    this code makes no sense whatsoever. The heredoc covers almost your whole code, while you have PHP and HTML randomly mixed. What is this supposed to do??
    I thought you can use php inside heredoc that was the whole purpose of it wasnt it?
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,915
    Rep Power
    1045
    Um, no? Where did you read that? And how would that even work?

    A heredoc works exactly like a double quoted string -- the only difference is that you don't have to escape double quotes. So you can insert variables and escape sequences (newlines etc.), but that's it. Anything else is interpreted as literal characters.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0
    Originally Posted by Jacques1
    Um, no? Where did you read that? And how would that even work?

    A heredoc works exactly like a double quoted string -- the only difference is that you don't have to escape double quotes. So you can insert variables and escape sequences (newlines etc.), but that's it. Anything else is interpreted as literal characters.
    got it thanks
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    322
    Rep Power
    0
    so how would i put all this php code inside a variable can you point me in the right direction?
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,915
    Rep Power
    1045
    I don't even understand what you're trying to do. What do you mean by "putting PHP code into a variable"?

    Isn't this simply about outputting HTML strings?
    PHP Code:
    if ($_POST['title'] == ""
    {    
    //haven't seen the form, so show it
        
    echo "
            <form method='post' action='
    $_SERVER[PHP_SELF]'> 
                <p> 
                <select name='language'>
        "
    ;
        ...


IMN logo majestic logo threadwatch logo seochat tools logo