Professional Web Applications Themes

nOOb question... - PHP Development

Sorry, but i'm not all that good in this. I have this: <a href="#" onClick="frames['winkels'].location.href = 'storelocator2.php?postcode=3500'; return false">Test</a> Which works great, it transfers the variable into the iframe, which takes it and handles it into its own php. Now i need also to call this same thing from php (it transfers the variable from a GET method): <?php if (isset($_GET['postcode'])) { $invoer = $_GET['postcode']; frames["winkels"].location.href = "storelocator2.php?postcode="+$invoer; <------!!! } ?> The line with the <----!!!!! is (offcourse) not working. Where am i going wrong? No problem with calling me a noob ;)...

  1. #1

    Default nOOb question...

    Sorry, but i'm not all that good in this.

    I have this:
    <a href="#" onClick="frames['winkels'].location.href =
    'storelocator2.php?postcode=3500'; return false">Test</a>

    Which works great, it transfers the variable into the iframe, which takes it
    and handles it into its own php.


    Now i need also to call this same thing from php (it transfers the variable
    from a GET method):

    <?php
    if (isset($_GET['postcode']))
    {
    $invoer = $_GET['postcode'];
    frames["winkels"].location.href =
    "storelocator2.php?postcode="+$invoer; <------!!!
    }
    ?>

    The line with the <----!!!!! is (offcourse) not working. Where am i going
    wrong?
    No problem with calling me a noob ;)



    Mich Guest

  2. #2

    Default Re: nOOb question...

    What exactly is the error you're getting?

    My guess is that you're getting something about a p error --
    because you're trying to mix JavaScript with PHP.

    Remeber that that JavaScript runs client side -- which means the code
    needs to be output to the browser along with the HTML. I think what
    you really want is something like this:

    <?php
    if(isset($_GET['postcode'])) {
    $invoer = $_GET['postcode'];
    ?>
    frames["winkels"].location.href = "storelocator2.php?postcode=" +
    <?
    php echo $invoer; ?>;
    <?php } ?>

    The idea is that you can escape between HTML and PHP code and it will
    usually behave as expected. Anything between the <?php and ?> will be
    pd as PHP; the rest will be sent straight to the browser.

    ZeldorBlat Guest

  3. #3

    Default Re: nOOb question...

    ZeldorBlat wrote:
     

    Does this "+" mean string concatination?
    Kleist Guest

  4. #4

    Default Re: nOOb question...

    "Kleist" <pl> wrote in message
    news:df3qf1$19e5$uar.net... 
    >
    > Does this "+" mean string concatination?[/ref]

    It does, in javaScript.

    --
    Welcome to Usenet! Please leave tolerance, understanding
    and intelligence at the door. They aren't welcome here.
    eternal piste erection miuku gmail piste com


    Kimmo Guest

  5. #5

    Default Re: nOOb question...

    ----- Original Message -----
    From: "ZeldorBlat" <com>
    Newsgroups: alt.comp.lang.php
    Sent: 31 August, 2005 03:02
    Subject: Re: nOOb question...

     

    Thankx Zeldor,

    Had to adjust a little, but got it working in the end.

    <?php
    if (isset($_GET['postcode']))
    {
    $invoer = $_GET['postcode'];
    ?>
    <script type="text/javascript">
    var whatever = "<?= $invoer ?>";
    frames['winkels'].location.href = 'storelocator2.php?postcode=' +
    whatever
    </script>
    <?php
    }
    ?>

    For some reason this: frames["winkels"].location.href =
    "storelocator2.php?postcode=" +<?php echo $invoer; ?>;
    didn't get any characters through, though it did numbers.

    Also:
    frames['winkels'].location.href = 'storelocator2.php?postcode=' + "<?=
    $invoer ?>"
    Works well.

    Thankx for the help, very much appreciated.



    Mich Guest

  6. #6

    Default Re: nOOb question...

    "Mich" <nl> wrote in message
    news:43159479$0$11061$xs4all.nl... 
    >
    > Thankx Zeldor,
    >
    > Had to adjust a little, but got it working in the end.
    >
    > <?php
    > if (isset($_GET['postcode']))
    > {
    > $invoer = $_GET['postcode'];
    > ?>
    > <script type="text/javascript">
    > var whatever = "<?= $invoer ?>";
    > frames['winkels'].location.href = 'storelocator2.php?postcode=' +
    > whatever
    > </script>
    > <?php
    > }
    > ?>[/ref]


    This should also work:
    <?php if (isset($_GET['postcode'])){ ?>
    <script type="text/javascript">
    frames['winkels'].location.href = 'storelocator2.php?postcode=<?=
    $_GET['postcode'] ?>';
    </script>
    <?php } ?>

    --
    Welcome to Usenet! Please leave tolerance, understanding
    and intelligence at the door. They aren't welcome here.
    eternal piste erection miuku gmail piste com


    Kimmo Guest

  7. #7

    Default Re: nOOb question...

    Yeah, that's how I would normally write it...with the short tags. But
    I figure if you're just learning, you might as well get into the habbit
    of the full open tags since people these days seem to think that
    they're bad :)

    ZeldorBlat Guest

  8. #8

    Default The Dark Side of short tags (Was: nOOb question...)

    "ZeldorBlat" <com> kirjoitti
    viestissä:googlegroups.com... 

    They are bad, at least if you're writing (or trying to write) xhtml
    compatible code. There you need the xml declaration row <?xml version="1.0"
    encoding="UTF-8"?>. If short tags are on, and the xml declaration is in a
    php file, it's concidered as php. And since 'xml version="1.0"
    encoding="UTF-8"' makes no sense in php, it raises an error. I've done a few
    times so that I echo the xml tag , ie <?= '<?xml version="1.0"
    encoding="UTF-8"?>' ?>, but that again is bad practise. It would be better
    to leave short tags out and write proper code.

    --
    SETI Home - Donate your cpu's idle time to science.
    Further reading at <http://setiweb.ssl.berkeley.edu/>
    Kimmo Laine <com>


    Kimmo Guest

  9. #9

    Default Re: The Dark Side of short tags (Was: nOOb question...)

    Kimmo Laine wrote: 
    >
    >
    > They are bad, at least if you're writing (or trying to write) xhtml
    > compatible code. There you need the xml declaration row <?xml version="1.0"
    > encoding="UTF-8"?>. If short tags are on, and the xml declaration is in a
    > php file, it's concidered as php. And since 'xml version="1.0"
    > encoding="UTF-8"' makes no sense in php, it raises an error. I've done a few
    > times so that I echo the xml tag , ie <?= '<?xml version="1.0"
    > encoding="UTF-8"?>' ?>, but that again is bad practise. It would be better
    > to leave short tags out and write proper code.
    >[/ref]

    Well maybe xhtml standards should be more considerate of php short tag
    users! ;)

    --
    Dustin Davis
    Freelance Portal: http://www.nerdlance.com
    Dustin Guest

  10. #10

    Default Re: The Dark Side of short tags (Was: nOOb question...)

    Seriously, like it's so difficult to write:

    echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";

    In a single place. I keep mine in an include file so it's really one
    line of code. It would be hard to argue that the convenience that the
    short open tag provides is out-weighed by the fact that you have to do
    a little more work in a single file.

    ZeldorBlat Guest

Similar Threads

  1. Noob question
    By Hill in forum Ubuntu
    Replies: 4
    Last Post: November 3rd, 07:26 PM
  2. sorry noob question
    By the rebel in forum Macromedia Director 3D
    Replies: 3
    Last Post: September 26th, 12:17 PM
  3. Noob question
    By drew146 webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 1
    Last Post: October 5th, 11:24 PM
  4. question from perl noob
    By boblehue in forum PERL Miscellaneous
    Replies: 9
    Last Post: August 1st, 09:59 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139