hi
I know nothing about php. i just need to insert a javascript code in a php page but it gives me

Parse error: parse error, unexpected '<' in ....blah,blah

the code i want to insert is from alexa, and it looks like:

<SCRIPT type='text/javascript' language='JavaScript' src='http://xsltcache.alexa.com/traffic_graph/js/g/a/3m?&u=ebay.com'></SCRIPT>

do i need to edit the JS in some way before pasting, or add a ; at the end

thanks in adv

    PHP can be mixed with HTML. The PHP stuff has to be inside the "<? ?>" tags. The HTML is OUTSIDE these tags.

    For example:

    <?
    // PHP...
    echo "Generated: ".date('m/d/Y', mktime())";
    ?>
    <!-- HTML NOW -->
    <h3> Priority Report </h3>
    <!-- BEGIN JSCRIPT
    blah blah blah
    END JSCRIPT -->

    <?
    // now we're back in PHP
    echo "Done. ";
    ?>

    For larger projects, mixing HTML and PHP like this gets very painful. Consider using something like PHPLib templates to separate the HTML and the PHP code so that you can separate the logic of PHP from the presentation. (HTML)

      Thanks, it works.

      Now, Is there any way to use a php variable within javascript
      .i.e. I have

      <SCRIPT type='text/javascript' language='JavaScript' src='http://xsltcache.alexa.com/traffic_graph/js/g/a/3m?&u=$website'></SCRIPT>

      where $website is a php variable containing a url address.
      i want the javascript to show the alexa graphic based in this variable.

      or may be a php code to completely replace the javascript with a php code instead for the example above.

      any help?

        Write a Reply...