Mysterious php errors occuring in pure javascript line!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Mysterious php errors occuring in pure javascript line!

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

show us
view_each_new.php on line 204
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post more code.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

found problem, solution?

Post 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.
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Re: found problem, solution?

Post 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 :!:
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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?
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Post 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:
Last edited by harsha on Tue Oct 19, 2004 3:54 am, edited 3 times in total.
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post 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
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post 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!
Post Reply