Professional Web Applications Themes

explicitly assigning a variable - PHP Development

$databname =$seriesname; The above code assignes a value from a previous page to seriesname, and then ultimately to databname, which I pass on to mysql_connect, instead of having to make separate mysql_connects. Basically, I have a welcome/choose your database page (all 3 databases use the same structure), and from that page the $seriesname value is passed on. All well and good so far, but... When the page loads for the first time, everything is fine, but when I use a sort (<a href the same page, but in a different order) on the page (so basically re-loading the page), $seriesname ...

  1. #1

    Default explicitly assigning a variable

    $databname =$seriesname;


    The above code assignes a value from a previous page to seriesname, and then
    ultimately to databname, which I pass on to mysql_connect, instead of having
    to make separate mysql_connects. Basically, I have a welcome/choose your
    database page (all 3 databases use the
    same structure), and from that page the $seriesname value is passed on.
    All well and good so far, but...
    When the page loads for the first time, everything is fine, but when I use
    a sort (<a href the same page, but in a different order) on the page (so
    basically re-loading the page), $seriesname has no value, and therefore it
    won't
    connect. If I expressly assign $database to a value, all works perfectly,
    but I don't want that.
    I've tried various ways, the most obvious being

    if ($seriesname) {
    $databname =$seriesname;
    }

    meaning, if $seriesname has a value, (which it does the first time because
    it gets it from a previous page but not the second time), then change
    $databname. This doesn't work, though, so can anyone help? I'm sure it's a
    simple answer!



    Please help! The answer must be so simple!


    Colin Harris Guest

  2. #2

    Default Re: explicitly assigning a variable

    how are u passing it from page to page?

    --
    Mike Bradley
    [url]http://www.gzentools.com[/url] -- free online php tools
    "Colin Harris" <c_harris01getridofthisbit.blueyonder.co.uk> wrote in
    message news:rRWUb.9075$u47.3040news-binary.blueyonder.co.uk...
    > $databname =$seriesname;
    >
    >
    > The above code assignes a value from a previous page to seriesname, and
    then
    > ultimately to databname, which I pass on to mysql_connect, instead of
    having
    > to make separate mysql_connects. Basically, I have a welcome/choose your
    > database page (all 3 databases use the
    > same structure), and from that page the $seriesname value is passed on.
    > All well and good so far, but...
    > When the page loads for the first time, everything is fine, but when I use
    > a sort (<a href the same page, but in a different order) on the page (so
    > basically re-loading the page), $seriesname has no value, and therefore it
    > won't
    > connect. If I expressly assign $database to a value, all works perfectly,
    > but I don't want that.
    > I've tried various ways, the most obvious being
    >
    > if ($seriesname) {
    > $databname =$seriesname;
    > }
    >
    > meaning, if $seriesname has a value, (which it does the first time because
    > it gets it from a previous page but not the second time), then change
    > $databname. This doesn't work, though, so can anyone help? I'm sure it's a
    > simple answer!
    >
    >
    >
    > Please help! The answer must be so simple!
    >
    >

    CountScubula Guest

  3. #3

    Default Re: explicitly assigning a variable


    "CountScubula" <mescantek.hotmail.com> wrote in message
    news:TeXUb.22218$NO.2963newssvr25.news.prodigy.co m...
    > how are u passing it from page to page?
    >
    method= post....


    Colin Harris Guest

  4. #4

    Default Re: explicitly assigning a variable

    On Sat, 7 Feb 2004 01:05:27 -0000, "Colin Harris"
    <c_harris01getridofthisbit.blueyonder.co.uk> wrote:

    >it gets it from a previous page but not the second time), then change
    >$databname. This doesn't work, though, so can anyone help? I'm sure it's a
    >simple answer!
    >
    Either...
    1)Store it in a session variable
    or
    2)Store it in a cookie variable
    or
    3)Add it to the url you use...
    <a href="mypage.php?databname=<?php echo $databname; ?>">thelink</a>
    When processing the page, get $databname from $_GET['databname'] if
    it's not in $_POST['databname'].

    Leveller

    Leveller Guest

  5. #5

    Default Re: explicitly assigning a variable


    "Leveller" <Leveller127.0.0.1> wrote in message
    news:p44a20png6qft50j3er4rp0ksuge1mesjt4ax.com...
    > On Sat, 7 Feb 2004 01:05:27 -0000, "Colin Harris"
    > <c_harris01getridofthisbit.blueyonder.co.uk> wrote:
    >
    >
    > >it gets it from a previous page but not the second time), then change
    > >$databname. This doesn't work, though, so can anyone help? I'm sure it's
    a
    > >simple answer!
    > >
    > Either...
    > 1)Store it in a session variable
    > or
    > 2)Store it in a cookie variable
    > or
    > 3)Add it to the url you use...
    > <a href="mypage.php?databname=<?php echo $databname; ?>">thelink</a>
    > When processing the page, get $databname from $_GET['databname'] if
    > it's not in $_POST['databname'].
    >
    > Leveller
    >
    Thank you - I've no idea how to do this first one, but I've seen how to do
    the second. I'm not totally sure how to do the third, but that might be the
    best option, so I'll give it a try :)


    Colin Harris Guest

Similar Threads

  1. Assigning a AS variable to the return value of a webservice
    By GotJosh? in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: June 17th, 03:23 AM
  2. Assigning a table value from a dataset to a variable
    By blitzed2010 in forum Dreamweaver AppDev
    Replies: 1
    Last Post: April 29th, 07:37 PM
  3. assigning variable values in tk
    By Tammer in forum PERL Modules
    Replies: 2
    Last Post: April 23rd, 07:52 PM
  4. Assigning instance name to variable
    By bhenry17 webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 3
    Last Post: January 20th, 04:37 PM
  5. Assigning huge chunk of text to variable
    By Sandman in forum PHP Development
    Replies: 5
    Last Post: October 22nd, 12:31 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