0

I cannot for the life of me realise what is wrong with this code.

 <? if (empty($nick)): ?>
 $('#nickTextbox').val(chatmoreDefaults.nick);
 <? else: ?>
 $('#nickTextbox').val(null);
 <? endif; ?>
 <? if (empty($realname)): ?>

And the first line gives me the error Uncaught SyntaxError: Unexpected token <

Any ideas of how I can remove that error?

asked May 3, 2015 at 2:27
2
  • Read carefully what @Tracker1 says. Commented May 3, 2015 at 4:31
  • Not sure why you're getting downvoted: I think (as others said below) the error is coming from not having proper <?php ... ?> tags. Commented May 3, 2015 at 5:00

2 Answers 2

2

You need to use <?php or <?= if short tags are enabled.

answered May 3, 2015 at 2:31
Sign up to request clarification or add additional context in comments.

Comments

2
  1. The logic is useless... there's no difference between setting a textbox to an empty string or null. It will be an empty string.

  2. Mixing content like this is a bad idea. I would suggest passing any server values that the JS needs, and setting them as a JSON/JObject variable for javascript. Then doing your checks in JS.

  3. There's not enough context as to how you are sending any of this information or where it fits.

  4. As another answer mentions... <?php

answered May 3, 2015 at 2:41

4 Comments

Not my script, trying to "fix" a broken script.
I would try cleaning it up first... again, without more context of what it is supposed to be doing, or where these variables are coming in, or how they are transmitting, who knows... is the error from php, or in the javascript console?
it is if you are interested, Chatmore. Web-based IRC. Couldn't find a better one but it has a lot of work a head.
I would look at shout-irc.com - github.com/erming/shout - which seems to be very active... it's node based, but you can reverse proxy it behind nginx or apache pretty easily. Will probably work better than a PHP solution.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.