I'm getting this error: Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/public_html/uploader.php on line 6 if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="1" />'; } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah('[var.base_url]/uploader.php?sub_cat='+ document.form_upload.channel.value, 'sub_change', '', 'GET', '', this);"> [var.fields_all;htmlconv=no]</select>'; } Code (markup): Can you help me find how/where to correct the error? Any help will be appreciated.
You're having trouble because of inline-javascript. Which you shouldn't use. But if you do, you will have to decide how you want to escape the single quotes. But the better solution is to just not use inline javascript.
Hope i solved this if(isset($_SESSION['channel_id'])) { echo '<input type="hidden" name="channel" value="1" />'; } else { echo '<select class="upload-video-form-input" name="channel" onchange="javascript:ahahscript.ahah(\'[var.base_url]/uploader.php?sub_cat=\'+ document.form_upload.channel.value, \'sub_change\', \'\', \'GET\', \'\', this);"> [var.fields_all;htmlconv=no]</select>'; } PHP:
@WebDeveloperOne showed you it right, escape your single quotes inside the strings with leading slashes -- little tip though, if you only have two results and no other code running, don't waste time with an if and two echo to do the job of one echo and a ternary operator. Also with onchange it's automatically javascript, so saying javascript: actually breaks it. That "javascript:" is only used in HREF, not in any of the onevent handlers. echo isset($_SESSION['channel_id']) ? '<input type="hidden" name="channel" value="1">' : '<select class="upload-video-form-input" name="channel" onchange="ahahscript.ahah(\'[var.base_url]/uploader.php?sub_cat=\'+ document.form_upload.channel.value, \'sub_change\', \'\', \'GET\', \'\', this);"> [var.fields_all;htmlconv=no] </select>'; Code (markup): That said... *DINGDINGDINGDINGDNIG* we have a winner. If you are using any of the onevent methods in the markup, or using href="javascript:" you have sloppy and possibly insecure scripting... which is why those are blocked from working whatsoever if you use the new "content security policy" from HTML 5. (one of the few things in HTML 5 I like) https://www.w3.org/TR/CSP/ No more onchange, onclick, etc, in the markup... no more <script> tag unless it's loading a script, sandboxing like a sandboxed iframe is to further reduce context bleed... People in the know have said for over a decade to stop using those things -- but of course like everything else we've been told not to do on websites since 4 Strict dropped in 1998, people just keep sleazing along doing it.