Can't get PHP to execute inside a – t.niese Apr 23 '18 at 05:19

  • 1
    You should probably be using a `div` not a `textarea`. Contents of a `textarea` are treated as text not html – Nick Apr 23 '18 at 05:24
  • @Nick A bib file contains _text_ and not html so to me a `textarea` looks like a valid container for that or a `pre` element. – t.niese Apr 23 '18 at 05:26
  • Jaromanda's comment was on point when he told me to look at the developer console. The issue is now fixed, please see the solution I posted. – learnerX Apr 23 '18 at 05:27
  • 1
    Your console error message is your answer. Your javascript code is failing due to an obsolete function [`.size()` - https://api.jquery.com/size/](https://api.jquery.com/size/). It was removed in 3.0, and you are using 3.3.1. Need to update to `.length()` – Sean Apr 23 '18 at 05:27
  • see `JS script, jquery and stylesheet mentioned on the page above is included in the header.` suggests the right version too :p – Jaromanda X Apr 23 '18 at 06:21
  • 3 Answers3

    1

    After help from the community here and after some experimentation according to comments made, I was able to look at the developer console in browser and see that the jquery was giving errors. In short, I was using the latest version of jquery (3.x) and the tool (that I took from the website linked in my question) was using a function that is deprecated. I went on the page, looked at their source, and used their specific version of jquery. It works now.

    Alternatively, I also tested updating the deprecated size() function to .length and it now works with the latest jquery.

    For more info, see this: g.size() is not a function - Jquery Error

    learnerX
    • 1,022
    • 1
    • 18
    • 44
    -1

    Procedural PHP is as intelligent as an hammer so I'm pretty sure that if there's any content it is displayed despite of it's adherence with HTML. It not even bother about if there is any html within the page unless you don't tell it to.

    It could seem trivial but please check the page source generated with right click->View Page Source and check there and not with just the inspector.

    Textarea allows only plain text and I think that anything else (e.g. html strings) is just discarded by your browser.

    Enrico Deleo
    • 388
    • 2
    • 15
    -1

    Your code has the correct structure. There are closing tags that confused your textarea tags.

    <textarea ...>
    <?php echo htmlspecialchars(file_get_contents('...'));?>
    </textarea>
    
    Schien
    • 3,855
    • 1
    • 16
    • 29