3

I'm trying to implement TinyMCE, which is working fine on my test rig, but on the production server, PHP is trying to execute some '<?' tags which are in the tiny_mce.js file.

I have a file called html_editor.php, which is brought into each form which requires it using include_once. Inside html_editor, i have the following:

<script type="text/javascript" src="/Public/TinyMCE/tiny_mce.js"></script>

followed by the Tiny MCE initialization, but it's failing on that line with unexpected T_CONSTANT_ENCAPSED_STRING. I replaced the script file with tiny_mce_src.js to find the exact code which is causing the problem, and it's:

html.push('<?', name, ' ', text, '?>');

I've swapped the single quotes with doubles in tiny_mce_src.js, which does resolve the problem, but in the minified code, they're already double.

It's obviously a configuration difference with PHP between my test and production servers, but I can't track down what. I am testing with PHP 5.3, and the server is running 5.2.

4
  • Is there a reason that you're letting your PHP server process your .js files? That's not a super-great idea, as it'll mean they may not be cached by the clients, which really can slow pages down. Commented May 30, 2011 at 3:15
  • @Pointy, thats why you set the Cache using the Header function. Granted, not that writing js should be done this way, but yea. Commented May 30, 2011 at 3:24
  • Well, if you can force the files to be cached, why would you need to process them through PHP in the first place? If they're really dynamic, then you can't let them be cached. If they're not dynamic, why load your server down with pointless work? Commented May 30, 2011 at 3:31
  • Thats a good point. About all I can say is that if you want customizations to be made through an Admin Panel, IE just enter in hex code for color changing or other items like that, it would be good to set it up that way and have a re-cache of the file. Granted, that should be done in CSS, but still can hold true. Commented May 30, 2011 at 3:43

2 Answers 2

6

Why are JavaScript files going through the PHP interpreter?!

Fix your server configuration to only treat *.php as PHP. How to do this depends on the web server you use and how you're running PHP; can you paste your test and production configurations?

Sign up to request clarification or add additional context in comments.

1 Comment

It's running on Apache. I don't have access to the main .htaccess file, so I'll set one up in the /Scripts folder until I can get the admin to fix it.
0

you need to edit php.ini and set

short_open_tag=0

this will stop

being processed, its a good idea regardless, then make suer all your php scripts use

1 Comment

While it's true that this will make his problem go away, the real issue is that .js files are being parsed as php. See @Eevee's answer. If the TinyMCE had a line like html.push('<?php', name, ' ', text, '?>'); then turning off short tags wouldn't help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.