FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Undefined variable: Origin
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Undefined variable: Origin [message #174241 is a reply to message #174238] Sat, 28 May 2011 12:03 Go to previous messageGo to previous message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma:
Member
On 28 mei, 11:57, Luuk <L...@invalid.lan> wrote:
> On 28-05-2011 11:41, Co wrote:
>
>
>
>
>
>
>
>
>
>> On 28 mei, 11:34, Luuk <L...@invalid.lan> wrote:
>>> On 28-05-2011 11:30, Co wrote:
>
>>>> On 28 mei, 11:17, Luuk <L...@invalid.lan> wrote:
>>>> > On 28-05-2011 08:51, Co wrote:
>
>>>> >> Hi All,
>
>>>> >> I give two values from one php page to the next.
>>>> >> <a href="MembersFrom.php?myCountry=Netherlands&myFlag=nl.gif">
>
>>>> >> On the second page I first define them:
>>>> >> if (isset($_GET['myCountry'])) {
>>>> >>    $Origin = $_GET['myCountry'];
>>>> >>    $Flag = $_GET['myFlag'];
>>>> >> }
>
>>>> >> $queryString = "WHERE email_activated='1' AND country='$Origin' AND
>>>> >> active='1' ORDER BY id ASC";
>>>> >> $sql2 = mysql_query("SELECT * FROM myMembers $queryString $limit") ;
>
>>>> >> I limit the data to one record per page.
>>>> >> However when I want to go to the next record on a new page he doesn't
>>>> >> recognize the variable Origin anymore in here:
>>>> >> $queryString = "WHERE email_activated='1' AND country='$Origin' AND
>>>> >> active='1' ORDER BY id ASC";
>
>>>> >> How should I save the value in Origin so it can be used everytime
>>>> >> again?
>
>>>> >> Marco
>
>>>> > You will need a session
>
>>>> >http://nl2.php.net/manual/en/function.session-start.php
>
>>>> > --
>>>> > Luuk
>
>>>> Can you have more than one sessions?
>>>> Could you give me some example of start and end of this session?
>
>>>> Marco
>
>>> What is wrong with the examples at the given page?
>
>>> --
>>> Luuk
>> I put in this code:
>
>> session_start();
>> $_SESSION['Origin'] = $_GET['myCountry'];
>> $_SESSION['Flag']   = $_GET['myFlag'];
>
>> //if (isset($_GET['myCountry'])) {
>> // $Origin = $_GET['myCountry'];
>> // $Flag = $_GET['myFlag'];
>> //}
>> $queryString = "WHERE email_activated='1' AND country='$Origin' AND
>> active='1' ORDER BY id ASC";
>
>> How can I give the $_SESSION['Origin'] to the query?
>> Marco
>
> try this:
>         session_start();
>         print "Session Origin: ".$_SESSION['Origin']."<br>";
>         $_SESSION['Origin'] = $_GET['myCountry'];
>         print "Session Origin replaced with value from _GET:
> ".$_SESSION['Origin']."<br>";
>         $_SESSION['Flag']   = $_GET['myFlag'];
>
> The first time you start this page $_SESSION['Origin'] will be empty
>
> The second time it will hold the value of the previous $_GET['myCountry']
>
> In other words,
>
> If $_GET['myCountry'] is empty, you should not do:
> $_SESSION['Origin'] = $_GET['myCountry'];
>
> --
> Luuk


When I try your code and go to the second page I get three
notifications:

Notice: A session had already been started - ignoring session_start()
Notice: Undefined index: myCountry
Notice: Undefined index: myFlag

on these lines:
$_SESSION['Origin'] = $_GET['myCountry'];
$_SESSION['Flag'] = $_GET['myFlag'];
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Persistence engine for GWT
Next Topic: input country name and query database to output google map
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 02:00:05 GMT 2024

Total time taken to generate the page: 0.05408 seconds