Re: [PHP-DB] session_registered variable problem

2002-01-29 Thread Markus Lervik

On Monday 28 January 2002 18:42, Jason Wong wrote:

  $page behaves just fine :

  page: 2 - yup, it's incrementing, all right...
  nr_pages: 230

  Whack! Doesn't work any more...  It's starting to drive me mad.

 Me too. Post the full code so we can all revel in this madness!

All rightey. Here it goes in it's (almost) full glory!

// The nav-function that's responsible for updateing the query

if($nav) {

if($go==next) {
if($page  $nr_pages  $page = 0) {
 $page++;
 $milla= (($page) * 20).,;// replace with
 echo millä:  . $milla;   // echo out debug info
 $mita = (($page-1) * 20).,;  // replace what
 echo mitä:  .$mita;  // echo out more debug info
 $query=ereg_replace($mita,$milla,$query); 
}
}
if($go==prev) {
if($page=1  $page = $nr_pages) {
$page--;
$milla = (($page) * 20).,;
echo millä:  . $milla;
$mita  = (($page+1) * 20).,;
echo mitä:  . $mita;
$query=ereg_replace($mita,$milla,$query);
}
}

echo query from nav():  .$query;
$result=mysql_query($query,$database)
or die(BEATCH,WHINE AND MOAN!);  // hehe. just a debug output.
print_taulukko();

}


function print_taulukko() {

?
FORM ACTION=page.php METHOD=POST
?  
//debug
echo query:  . $query;
echo BRBR;
echo page:  . $page;
echo BR;
echo nr_pages:  .$nr_pages;
//endof debug

while($row=mysql_fetch_row($result)) {
[snip away stuff that doesn't really matter]
}
?
TR
TD COLSPAN=5 WIDTH=50% ALIGN=CENTERINPUT ?php if($page == 0) {echo 
DISABLED;} ? TYPE=button 
VALUE=Edellinen sivu 
onclick=parent.location='page.php?nav=truego=prev';/TD

TD COLSPAN=4 WIDTH=50% ALIGN=CENTERINPUT ?php if($page = 
($nr_pages-1)) { echo DISABLED; }? TYPE=button 
VALUE=Seuraava sivu 
onclick=parent.location='page.php?nav=truego=next';/TD
/TR
?
}


And that's basically it. There's a function responsible for
reading user input and constructing the sql-query, and it
places the sql in $query, stuffs it down MySQL and throws
it over to print_taulukko(), and it seems to be working right,
since the first result always is the correct one. It also session_registers
$query. (yes, I use session_register(query), not session_register($query).)

I checked the sess_whatever file step by step when testing again just to see
exactly what is put in it, but it seems to be a well-behaved little textfile.

Make any sense out of the code?

Cheers mate, 
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-29 Thread Markus Lervik

On Monday 28 January 2002 18:42, Jason Wong wrote:


  $page behaves just fine :
 [snip]
  page: 2 - yup, it's incrementing, all right...
  nr_pages: 230

  Whack! Doesn't work any more...  It's starting to drive me mad.

 Me too. Post the full code so we can all revel in this madness!

Well, problem solved, sort of. It suddenly started working. 

Wicked.


Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-29 Thread Jason Wong

On Tuesday 29 January 2002 21:15, Markus Lervik wrote:
 On Monday 28 January 2002 18:42, Jason Wong wrote:
   $page behaves just fine :
 
  [snip]
 
   page: 2 - yup, it's incrementing, all right...
   nr_pages: 230
  
   Whack! Doesn't work any more...  It's starting to drive me mad.
 
  Me too. Post the full code so we can all revel in this madness!

 Well, problem solved, sort of. It suddenly started working.

Our collective karma did the trick then?

 Wicked.

Hehe


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
The heart is wiser than the intellect.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] session_registered variable problem

2002-01-28 Thread Markus Lervik


Hello!

I have a problem with session_registered variables. 
It seems that my sessions behave quite erratic. Well, 
actually just one variable, $query.

Somehow when I print the value of $query, it looks fine.
Then, when I change $query a bit and print it again, 
it looks fine.
Change it a third time, and it suddenly gets the value it
had in the beginning. 

Ideas as to how one would go about solving this little problem?

Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Jason Wong

On Monday 28 January 2002 20:45, Markus Lervik wrote:
 Hello!

 I have a problem with session_registered variables.
 It seems that my sessions behave quite erratic. Well,
 actually just one variable, $query.

 Somehow when I print the value of $query, it looks fine.
 Then, when I change $query a bit and print it again,
 it looks fine.
 Change it a third time, and it suddenly gets the value it
 had in the beginning.

 Ideas as to how one would go about solving this little problem?

Could you post some code please?


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
The heart has its reasons which reason knows nothing of.
-- Blaise Pascal
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Markus Lervik

On Monday 28 January 2002 14:57, Jason Wong wrote:

  Somehow when I print the value of $query, it looks fine.
  Then, when I change $query a bit and print it again,
  it looks fine.
  Change it a third time, and it suddenly gets the value it
  had in the beginning.

 Could you post some code please?

Well, for instance, this screws up the $query. It works if one clicks
once on the next-button, but clicking another time resets the query to

SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE (L.Nimi_id=N.id AND  N.Nimi LIKE asdf) 
LIMIT 0,20

if($go==next) {
if($page  $nr_pages  $page = 0) {
 $page++;
 $replace_with= (($page) * 20).,;
 echo replace_with:  . $replace_with;
 $replace = (($page-1) * 20).,;
 echo replace:  .$replace;
 $query=ereg_replace($replace,$replace_with,$query); 
}
}

It's the LIMIT 0,20 - LIMIT 20,20 - LIMIT 40,20 that doesn't work. Strange thing is, 
that
it worked about a week ago. : \ 
I can't really recall changing that part of the code at all at that point.

Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Jason Wong

On Monday 28 January 2002 21:05, Markus Lervik wrote:
 On Monday 28 January 2002 14:57, Jason Wong wrote:
   Somehow when I print the value of $query, it looks fine.
   Then, when I change $query a bit and print it again,
   it looks fine.
   Change it a third time, and it suddenly gets the value it
   had in the beginning.
 
  Could you post some code please?

 Well, for instance, this screws up the $query. It works if one clicks
 once on the next-button, but clicking another time resets the query to

 SELECT
   L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huom
autuksia FROM uusi_lehtitaulu L, nimet N
   WHERE (L.Nimi_id=N.id AND  N.Nimi LIKE asdf)
   LIMIT 0,20

 if($go==next) {
   if($page  $nr_pages  $page = 0) {
$page++;
$replace_with= (($page) * 20).,;
echo replace_with:  . $replace_with;
$replace = (($page-1) * 20).,;
echo replace:  .$replace;
$query=ereg_replace($replace,$replace_with,$query);
   }
 }

 It's the LIMIT 0,20 - LIMIT 20,20 - LIMIT 40,20 that doesn't work.
 Strange thing is, that it worked about a week ago. : \
 I can't really recall changing that part of the code at all at that point.

Crikey, it looks terribly complicated for what looks like something to page 
through a set of results.

Wouldn't it be easier to do away with the ereg_replace()?

 if($go==next) {
   if($page  $nr_pages  $page = 0) {
 $page++;
 $start = $page * 20;   
   }
 }

 $qry = SELECT
L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huom
autuksia FROM uusi_lehtitaulu L, nimet N
   WHERE (L.Nimi_id=N.id AND  N.Nimi LIKE asdf)
LIMIT $start,20


Even it this doesn't work, at least it's easier to understand :)

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
The way to love anything is to realize that it might be lost.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Markus Lervik

On Monday 28 January 2002 17:34, Jason Wong wrote:


 Crikey, it looks terribly complicated for what looks like something to page
 through a set of results.

 Wouldn't it be easier to do away with the ereg_replace()?

  if($go==next) {
if($page  $nr_pages  $page = 0) {
  $page++;
  $start = $page * 20;
}
  }

  $qry = SELECT

 L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huom
 autuksia FROM uusi_lehtitaulu L, nimet N
WHERE (L.Nimi_id=N.id AND  N.Nimi LIKE asdf)
   LIMIT $start,20


 Even it this doesn't work, at least it's easier to understand :)

Well, in this particular case it won't work at all, because the SQL-query is 
dynamically
created based on what the user wants to search for. It doesn't nessecary include all 
columns. The only static bit of the query is FROM uusi_lehtitaulu L, nimet N and 
WHERE (L.Nimi_id=N.id : ) It would be just as big a mess with a truckload of
concatenations, like 

$query = SELECT  . $tables .  FROM uusi_lehtitaulu L, nimet N WHERE
(L.nimi_id=N.id . $search . ) LIMIT $start,20;

Besides, I have a strange fetisch to do everything the hard way. : )


Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Jason Wong

On Monday 28 January 2002 23:45, Markus Lervik wrote:

 Well, in this particular case it won't work at all, because the SQL-query
 is dynamically created based on what the user wants to search for. It
 doesn't nessecary include all columns. The only static bit of the query is
 FROM uusi_lehtitaulu L, nimet N and WHERE (L.Nimi_id=N.id : ) It would
 be just as big a mess with a truckload of concatenations, like

 $query = SELECT  . $tables .  FROM uusi_lehtitaulu L, nimet N WHERE
 (L.nimi_id=N.id . $search . ) LIMIT $start,20;

I usually give the concatenations a miss if I can and just use:

  $query = SELECT $tables FROM ... ;

 Besides, I have a strange fetisch to do everything the hard way. : )

Masochist :)

Anyway, as per the subject, how are you getting $page? I assume it is stored 
in the session. Is $page behaving correctly when you go from one page to the 
next? Could you post the relevant code? 


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Distrust all those who love you extremely upon a very slight acquaintance
and without any visible reason.
-- Lord Chesterfield
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Markus Lervik

On Monday 28 January 2002 18:06, Jason Wong wrote:

  Besides, I have a strange fetisch to do everything the hard way. : )
 Masochist :)

:D

 Anyway, as per the subject, how are you getting $page? I assume it is
 stored in the session. Is $page behaving correctly when you go from one
 page to the next? Could you post the relevant code?

$page behaves just fine :

first time around (haven't got to the nav() -function yet..) :

query from nav(): 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 0,20

//this is from the print_table -function

query: 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 0,20

page: 0   - note! bells! whistles! 
nr_pages: 230


We hit the next-button, and we get...

replace_with: 20,
replace: 0,

query from nav(): 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 20,20

query: 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 20,20

page: 1 - bells 'n' whistles again!
nr_pages: 230


Looks quite good. We hit the next-button again :

with: 40,
what: 20,

query from nav(): 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 0,20

query: 
SELECT 

L.Tunnus,N.Nimi,L.ISSN,L.Vuosi,L.Lisätietoja,L.Vuosikerta,L.Numerot,L.Huomautuksia 
FROM uusi_lehtitaulu L, nimet N 
WHERE L.Nimi_id=N.id 
LIMIT 0,20

page: 2 - yup, it's incrementing, all right...
nr_pages: 230

Whack! Doesn't work any more...  It's starting to drive me mad. 


Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] session_registered variable problem

2002-01-28 Thread Jason Wong

On Tuesday 29 January 2002 00:24, Markus Lervik wrote:
 On Monday 28 January 2002 18:06, Jason Wong wrote:

 $page behaves just fine :

[snip]

 page: 2 - yup, it's incrementing, all right...
 nr_pages: 230

 Whack! Doesn't work any more...  It's starting to drive me mad.

Me too. Post the full code so we can all revel in this madness!


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Why must you tell me all your secrets when it's hard enough to love
you knowing nothing?
-- Lloyd Cole and the Commotions
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]