Results 1 to 4 of 4

Thread: PHP/Javascript Bridge?

  1. #1

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Arrow PHP/Javascript Bridge?

    Okay I have this:
    PHP Code:
    <script type="text/javascript">
        <!--
            function log(text)
            {
                <?php
                $con 
    mysql_connect("localhost","user","pass");
                
    $now date("d/m/y");
                
    $text ?> text <? ; // Line 12
                $ip = $_SERVER['REMOTE_ADDR'];
                mysql_select_db("db", $con);
                mysql_query("INSERT INTO `translog` ( `ip` , `date` , `transfrom` )
    VALUES (
    '$ip', '$now', '$text'
    );");
                ?>
            }
        -->
    </script>
    The error:
    Parse error: parse error, unexpected ';' in /home/mage/public_html/rvcom/trans.php on line 12

    Tried removing the ; at the end of the line and get the same error.

    Do you think that there could be a possible bridge in Javascript using this method??

    I'm guessing no, but I can't make the user have to click a link to pass variables to PHP



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: PHP/Javascript Bridge?

    PHP is a server side language which gets process before it gets sent to the client, Javascript is a client side language and has no knowledge of what happens on the server. If you wish to communicate between client and server using javascript, look into AJAX, there's loads of articles about and visualAd wrote a good one a while ago.

  3. #3

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: PHP/Javascript Bridge?

    Thankie



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: PHP/Javascript Bridge?

    Can you mark your thread resolved please, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width