Page 1 of 1

Mysterious php errors occuring in pure javascript line!

Posted: Fri Oct 15, 2004 5:40 pm
by dimitris
I tried to use this part of phpbb code (javascript) in a php script (this line 205):

Code: Select all

bbtags = new Array('їb]','ї/b]','їi]','ї/i]','їu]','ї/u]','їquote]','ї/quote]','їcode]','
','
  • ','
','
  • ','
','[img]','[/img]','','','

Code: Select all

<?php\n','\n?>
', '[php_man]', '[/php_man]', '[mysql_man]', '[/mysql_man]', '[pg_man]', '[/pg_man]', '[google]', '[/google]', '[mail_search]', '[/mail_search]', '[big_search]', '[/big_search]');

and i get the following error:

Code: Select all

Warning: Unexpected character in input: ''' (ASCII=92) state=1 in /u1/public_html/view_each_new.php on line 204

Parse error: parse error, unexpected T_STRING in /u1/public_html/view_each_new.php on line 204
Note:The javascript is not echoed or printed by php. It is normally included in the html code

Note: When i remove this part of code no errors are shown

Thanks in advance

Posted: Fri Oct 15, 2004 5:55 pm
by John Cartwright
show us
view_each_new.php on line 204

Posted: Fri Oct 15, 2004 6:03 pm
by dimitris
Phenom wrote:show us
view_each_new.php on line 204
it is this javascript code:

Code: Select all

bbtags = new Array('&#1111;b]','&#1111;/b]','&#1111;i]','&#1111;/i]','&#1111;u]','&#1111;/u]','&#1111;quote]','&#1111;/quote]','&#1111;code]','
','
  • ','
','
  • ','
','[img]','[/img]','','','

Code: Select all

<?php\n','\n?>
', '[php_man]', '[/php_man]', '[mysql_man]', '[/mysql_man]', '[pg_man]', '[/pg_man]', '[google]', '[/google]', '[mail_search]', '[/mail_search]', '[big_search]', '[/big_search]');


i tried it alone:

Code: Select all

&lt;script language="JavaScript" type="text/javascript"&gt;
bbtags = new Array('&#1111;b]','&#1111;/b]','&#1111;i]','&#1111;/i]','&#1111;u]','&#1111;/u]','&#1111;quote]','&#1111;/quote]','&#1111;code]','
','
  • ','
','
  • ','
','[img]','[/img]','','','

Code: Select all

<?php\n','\n?>
', '[php_man]', '[/php_man]', '[mysql_man]', '[/mysql_man]', '[pg_man]', '[/pg_man]', '[google]', '[/google]', '[mail_search]', '[/mail_search]', '[big_search]', '[/big_search]');
</script>

and i get the same error!

I tried it now echoed by echo "..."; and it returns no error

Posted: Sun Oct 17, 2004 8:06 pm
by feyd
post more code.

found problem, solution?

Posted: Mon Oct 18, 2004 2:59 am
by phpScott
I don't know how to fix it but in the second line of your posted code where the elements in the array are stored you have

Code: Select all

&lt;?php\n','\n?&gt;

which is what will be causing the error as the interpreter is doing wow <?php must be some php code in here.


I sure one of the other geniuses around here will know the solution.

Re: found problem, solution?

Posted: Tue Oct 19, 2004 3:20 am
by dimitris
phpScott wrote:I don't know how to fix it but in the second line of your posted code where the elements in the array are stored you have

Code: Select all

&lt;?php\n','\n?&gt;

which is what will be causing the error as the interpreter is doing wow <?php must be some php code in here.


I sure one of the other geniuses around here will know the solution.
What do you mean? There is no <?php tag before the javascript code :!:

Posted: Tue Oct 19, 2004 3:48 am
by phpScott
sorry let me try this agian.

in your array declaration on the second line elements 19/20, scrolled off to the left, you have the tags '

Code: Select all

<?php', ' ?>
' even thought it is in a quoted string in javascript the php intepretor will thing that these are opening and closing php tags and that there should be something to prosess in there and ',' is not a valid php string.

I know this has been talked about before on this site if you do a search for displaying php code I'm sure the answer is in there.

Does that clear it up what I'm refering too?

Posted: Tue Oct 19, 2004 3:51 am
by harsha
Use external javascript file to load the bbcode handling javascript

something like this in

view_each_new.php

Code: Select all

<?
echo "<script language="javascript" src="bbcodeparser.js"> ";
?>
so that php doen;t get a chance to parse the javascript that you are doing it presently in your script

it aviods confusion to PHP. :wink: :) :wink: :idea:

Posted: Tue Oct 19, 2004 3:52 am
by dimitris
phpScott wrote:sorry let me try this agian.

in your array declaration on the second line elements 19/20, scrolled off to the left, you have the tags '

Code: Select all

<?php', ' ?>
' even thought it is in a quoted string in javascript the php intepretor will thing that these are opening and closing php tags and that there should be something to prosess in there and ',' is not a valid php string.

I know this has been talked about before on this site if you do a search for displaying php code I'm sure the answer is in there.

Does that clear it up what I'm refering too?
I am trying to understand you... I look in my code for such line and fix it.
Thanks a lot

Posted: Tue Oct 19, 2004 3:54 am
by dimitris
harsha wrote:Use external javascript file to load the bbcode handling javascript

something like this in

view_each_new.php

Code: Select all

<?
echo "<script language="javascript" src="bbcodeparser.js"> ";
?>
so that php doen;t get a chance to parse the javascript that you are doing it presently in your script

it aviods confusion to PHP.
Ok harsha! I'll try this option too!