Results 1 to 5 of 5

Thread: echo javascript

  1. #1

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    echo javascript

    I am trying to put a value into this pieice of code, buti cant get it work.

    PHP Code:
    echo "<script type='text/javascript'>
    window.location = '
    $row['redirect_url']'
    </script>"


  2. #2

    Thread Starter
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Re: echo javascript

    PHP Code:
    echo "<script type='text/javascript'>
    window.location = 'WANTA TO PUT Database value here 
    $something'
    </script>"


  3. #3
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: echo javascript

    PHP Code:
    ?>
    <script type="text/javascript"> 
    window.location = '<?php echo $row['redirect_url']; ?>';
    </script>
    <?php
    Or completely from PHP
    PHP Code:
    echo "<script type='text/javascript'> 
    window.location = '
    {$row['redirect_url']}'
    </script>"

    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: echo javascript

    It is reccommended that you DO NOT put javascript or a great amount of HTML within the PHP tags and echoing it.

    I would use RV's first example
    My usual boring signature: Something

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: echo javascript

    I recommend you don't use Javascript to redirect. Use the header function:
    PHP Code:
    header('Location: ' $row['redirect_url']); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

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