31 users online (1 members and 30 guests)  


  Results 1 to 15 of 15

Related

  1. inserting css into php pages?    Forum: CSS Forum
    Replies: 10
  2. Inserting system calculator    Forum: HTML Forum
    Replies: 0
  3. error in perl with javascript    Forum: CGI Perl Forum
    Replies: 1
  4. Replies: 4
  5. Inserting Html    Forum: HTML Forum
    Replies: 3
  1. #1
    fictionised
    fictionised's Avatar
    Guest

    Error inserting javascript into php

    Hey, I'm trying to insert this code into a php page, but it gives me a parse error- can anyone tell me why?:

    Code:
    <?php
    
    echo "<script language=\"Javascript1.2\">\n";
    echo "<!-- // load htmlarea_editor_url = "'http://www.fictionised.net/htmlarea/'";\n"; // URL to htmlarea files
    echo "var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);\n";
    echo "if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }\n";
    echo "if (win_ie_ver >= 5.5) {\n";
    echo " document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');\n";
    echo " document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');  \n";
    echo "} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); } // -->\n";
    echo "</script>";
    (plus more code, of course- but this is the bit i am having troubles with...).

    Cheers.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi, welcome to the forums.

    Code:
    echo "<!-- // load htmlarea_editor_url = "'http://www.fictionised.net/htmlarea/'";\n"; // URL to htmlarea files
    There a non-escaped " symbols in there.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    Lets see if I am learning

    Do you mean that the " does not have an \ in front?

    like the line
    Code:
    echo " document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');  \n

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Yes
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    fictionised
    fictionised's Avatar
    Guest
    Alright, I fixed that error up, but now I get this error:

    Code:
    Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home2/kendal/public_html/stories.php on line 5
    When using this code:

    Code:
    echo "<script language=\"Javascript1.2\">\n";
    echo "<!-- // load htmlarea_editor_url = \"http://www.fictionised.net/htmlarea/\";\n"; // URL to htmlarea files
    echo "var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);\n";
    echo "if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }\n";
    echo "if (win_ie_ver >= 5.5) {\n";
    echo " document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');\n";
    echo " document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');  \n";
    echo "} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); } // -->\n";
    echo "</script>";
    Any ideas, now? :P

  6. #6
    fictionised
    fictionised's Avatar
    Guest
    N.B. Thanks for the welcome I'll be sure to stick around and help out when I can (despite this minor set-back...lol)...

  7. #7
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Ill need to know which line is your actual line 5 in the above code. I dont want to assume its the fifth one there, have made that mistake before
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  8. #8
    fictionised
    fictionised's Avatar
    Guest
    Whoops! My bad.

    Err- this one;

    Code:
    echo "var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);\n";

  9. #9
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Again, " symbols without escaping.

    ("MSIE")

    should be

    (\"MSIE\")
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  10. #10
    fictionised
    fictionised's Avatar
    Guest
    Alright, well I fixed up that small problem, but now I am presented with:

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home2/kendal/public_html/stories.php:3) in /home2/kendal/public_html/header.php on line 3

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/kendal/public_html/stories.php:3) in /home2/kendal/public_html/header.php on line 3

    Warning: Cannot modify header information - headers already sent by (output started at /home2/kendal/public_html/stories.php:3) in /home2/kendal/public_html/header.php on line 4

    Warning: Cannot modify header information - headers already sent by (output started at /home2/kendal/public_html/stories.php:3) in /home2/kendal/public_html/header.php on line 5

    Warning: Cannot modify header information - headers already sent by (output started at /home2/kendal/public_html/stories.php:3) in /home2/kendal/public_html/header.php on line 6
    Here is the full inserted JS code now:

    Code:
    echo "<script language=\"Javascript1.2\">\n";
    echo "<!-- // load htmlarea_editor_url = \"http://www.fictionised.net/htmlarea/\";\n"; // URL to htmlarea files
    echo "var win_ie_ver = parseFloat(navigator.appVersion.split(\"MSIE\")[1]);\n";
    echo "if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }\n";
    echo "if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }\n";
    echo "if (win_ie_ver >= 5.5) {\n";
    echo " document.write('<scr' + 'ipt src=\"' +_editor_url+ 'editor.js\"');\n";
    echo " document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');  \n";
    echo "} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); } // -->\n";
    echo "</script>";
    I am not sure which part of it is calling up the session headers...?

  11. #11
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Its not, its later on.

    You cann amend headers once output has started to the browser. If you try, you get the errors above.

    Try moving everything you amended/added lower down the page. Move it to where the rest of the html is output.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  12. #12
    fictionised
    fictionised's Avatar
    Guest
    Cheers- that worked.

    Now to discover why the actual htmlarea 'gui' won't show up/be displayed in the actual 'Add Story' page.....

    Thanks for the quick replies!

  13. #13
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Are you using htmlArea? I have used that, its very good.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  14. #14
    fictionised
    fictionised's Avatar
    Guest
    Yeah, I am :P

    'Cept it doesn't show up in my stories.php page...the gui, that is- the htmlarea doesn't show up in place of my textarea, and I have no idea why- I have followed it exactly....???

    Any ideas? I asked on the htmlarea forums, but haven't received a response...

  15. #15
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Post a link and I will have a look.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread