Re: [PHP] eating mySQL result rows 1 by 1.. a better way?

2002-03-21 Thread Joffrey van Wageningen

- Original Message -
From: Steve Clay [EMAIL PROTECTED]
To: PHP-GENERAL [EMAIL PROTECTED]
Sent: Thursday, March 21, 2002 4:54 PM
Subject: [PHP] eating mySQL result rows 1 by 1.. a better way?


 On my site I paginate query results by limiting rows output to a
 value, say LIMIT, and then the 2nd, 3rd pages run the same query with
 $skip=LIMIT, $skip=(LIMIT*2) value posted back.  I use the following
 code to skip these result rows, which is just fetching the next row
 to an unused array.

 //if there are rows to skip
 if ($result_rows  $rows_to_skip) {
while ( $rows_to_skip ) {
   // eat a row
   mysql_fetch_array($result);
   $rows_to_skip--;
   $total_results_shown++;
}
 }

 Can I make this more efficient?  Is there a way to eliminate this data
 before it leaves the mySQL server (and would it be faster)?

try 'LIMIT' :)

http://www.mysql.com/doc/S/E/SELECT.html

The LIMIT clause can be used to constrain the number of rows returned by the
SELECT statement. LIMIT takes one or two numeric arguments. If two arguments
are given, the first specifies the offset of the first row to return, the
second specifies the maximum number of rows to return. The offset of the
initial row is 0 (not 1):
mysql select * from table LIMIT 5,10;  # Retrieve rows 6-15
if one argument is given, it indicates the maximum number of rows to return:
mysql select * from table LIMIT 5; # Retrieve first 5 rows
In other words, LIMIT n is equivalent to LIMIT 0,n.

Rod Kreisler wrote a nice article on Building Next/Prev Buttons for Query
Results:
http://www.phpbuilder.com/columns/rod20001214.php3

hope it helps :)

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Compiled php again but running still old php version

2002-02-26 Thread Joffrey van Wageningen

  I did build  php4.1.1 on RH7.2 with a different configuration command.
 
  After restarting the server, the phpinfo shows still the same version
and
  the old configure command.
 
  Do I have to point to the new installation? This suprises me, because
  everything went ok during compile.

 locate mod_php
 or, if updatedb hasn't been runned yet
 find /usr -name mod_php* -print

please note: if you run php compiled into apache you should recompile apache
after a make install in the php dir... run a make and a make install in your
apache sourcetree and restart apache using apachectl

with kind regards,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] storing arrays

2002-02-17 Thread Joffrey van Wageningen

- Original Message - 
From: Clark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, February 17, 2002 3:15 AM
Subject: [PHP] storing arrays


 Two questions:
 
 1) Is it possible to write an array to a file?

not direct, use:

$fp = fopen(/my/file, w);
foreach($filearray as $row)
  fputs($fp, $row.\n);
fclose($fp);

 2) Is it possible to specify the name of the key to each item of an
 array when you get the array using file().

not direct, use:

$keys = array(first, second, third, fourht);
$filearray = file(/my/file);

for($x = 0; $x  count($filearray); $x++)
  $newfilearray[$keys[$x]] = $filearray[$x];

$filearray = $newfilearray;

i think only a write version of file could be a useful function for php...

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Looking for optimal coding

2002-02-15 Thread Joffrey van Wageningen


 This is not a big thing.
 But I am looking at this thinking there is a way to make the code take up
 even less lines.

 for($i=01;$i=50;$i++)  {
  if (!empty($content))   {
  if ($row[$content]==$states[$i])
  echo option value=\$states[$i]\
 selected$nstates[$i]\n;
  else
  echo option
value=\$states[$i]\$nstates[$i]\n;
  }
  else{
  if ($dstate == $states[$i])
  echo option value=\$states[$i]\
 selected$nstates[$i]\n;
  else
  echo option
value=\$states[$i]\$nstates[$i]\n;
  }
 }

i would try:

for($i=01;$i=50;$i++) {
if(!empty($content)  $row[$content] == $states[$i])
$selected =  selected;
elseif($dstate == $states[$i])
$selected =  selected;
else
$selected = ;
echo option
value=\.$states[$i].\.$selected..$nstates[$i]./option;
}

trading four echo's for a one echo and a extra var and nest the ifs

 Basically I want to check for two possible conditions to make an item
selected.
 If the first one is valid then do not check for the other.

 Get what I mean?
 Any expert programmers out there with the way to chop this even further?

test it :)

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Decode Encoded text in phpMyAdmin

2002-02-14 Thread Joffrey van Wageningen

 Hello,
  How can I decode encoded text/numbers in my phpMyAdmin? I looked
at
 BASE64, but thats not it. Any help is great. Thanks

 Example: 8e73b27568cb3be29e2da74d42eab6dd

i dont wanna spoil your day, but your looking at a md5 hash... md5 is a one
way encoding scheme, no way back... md5 is used to make a sum of a load of
data and compared by a second sum to see if the data matches (like passwords
or file integrety)

if you want 7bit encoding try base64_encoding and _decoding

hope you can have a good night sleep :)

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] how to specify custom http header in fopen(http://...,...)

2002-01-29 Thread Joffrey van Wageningen

 I've a bunch of PHP program that heavily depends 
 on remote services via fopen(http://...;,...) costruct.
 
 Now I've installed mod_gzip on the remote server 
 and so if I can specify Accept-Encoding: gzip,deflate in 
 my http header request, I can have a (much) smaller network traffic.
 
 My question: how can I specify a custom HTTP header
 in the fopen(http://...;,...) function ???

i think the best way is to use
http://www.php.net/manual/en/function.fsockopen.php
and send your your own headers...

mvgr,
Joffrey van Wageningen

ps/1: hows the smog in milano? :P

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams


-- 
PHP General 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] PHP Chat REALTIME

2002-01-22 Thread Joffrey van Wageningen

 I dont think its possible without Java programing.

its posible to keep a http connection open and trust on flush() to send some
data to the client, if this data contains javascript you could update a
window or something... if you want to make this safe: make sure you use a
combination of a open http connection with flush() and reload the frame your
flush()'ing time to time (in case of a proxy server)

shoplist for a chat:
* 3 frames: 1 to display incomming data, 1 to have a input field and post to
the server and 1 to receive data from your http stream (could be hidden)

* some javascript to move the data from the http stream window to the
display window

* a db backend and maybe a check (with the post, or the refresh) which lines
have been received by the client

* a cute design :)

with kind regards,
Joffrey van Wageningen
ne2000.nl





Re: [PHP] PHP Chat REALTIME

2002-01-22 Thread Joffrey van Wageningen

   I dont think its possible without Java programing.

  its posible to keep a http connection open and trust on flush() to send
some
  data to the client, if this data contains javascript you could update a
  window or something... if you want to make this safe: make sure you use
a
  combination of a open http connection with flush() and reload the frame
your
  flush()'ing time to time (in case of a proxy server)

 I've been kidding around with a chat experiment of my own a few weeks ago
and
 stumbled in the same problem with refresh, so I'm quite interested in this
 discussion. So, ok, I didn't know about flush() at all, but how do you
keep the
 http connection open in the first place? Just keep looping in the PHP or
is
 there a smarter way?

the 'smarter' way would be having a client side programming language open a
socket to the server (read: the php script running). the only realy useful
language is javascript becouse flash and java are not portable on some
platforms. the next problem is javascript isnt able (for security reasons)
to open a socket to the outside.

the only way to do (simplex) communication is to leave the http connection
open... by default, the connection is kept open until the php scripts
finishes (or die()'s). by looping php for a sertain amout of time we create
a 'stable' connection to the client.

an example (dont mind my crappy code format/indenting):

html
body
?
// put a new row in /tmp/myfile?
if($new)
  {
  // yup, let us open a file (append modes) and write one line...
  $fp = fopen(/tmp/myfile, a);
  fputs($fp, $new.\n);
  fclose($fp);
  // done, no code left for us, lets die
  }
else
  {
  // no new line, we are in viewing mode
  while(1 == 1)
{
// i feel looped :) open a file, again and again and again :)
$file = file(/tmp/myfile);

// if the file has more lines than the last time we opened it, we should
display some
for($x=$filemax; $x  count($file); $x++)
  echo $file[$x].br;
// here we flush our send queue... the client is getting some data now
flush();

// count the number of lines we have displayed
$filemax = count($file);
// sleep! strange things are appenin' if we dont give a file time to
close when we are appending
sleep(1);
}
  }
?
/body
/html

this example does _not_ handle any file locking and is _verry_ cpu/io
intensive. alot of other solutions could be uses including database query's
or shared memory

the next step is to build a nice interface for this, and maybe send some
'script/script' info instead of plain text

please mind, default php sets a timeout of 30 seconds for completing a php
script. ofcourse we can overrule that:

ini_set(max_execution_time, 3600);

another problem is proxy's and to slow connections, they will reset and your
client wont noice the page is not recieving data anymore... one of my
solutions is to just take resets for granted and build in a reload every 10
seconds with a html meta directive. if we use this we have a problem with
the sequenceing of the data: 'is our last row received'... a javascript
thingy could send a notice to the webserver the client recieved the line...

but thats a choice by the designer of a specific system, every chat has his
own needs of connection integrety.

hope my 5 euro cents help... :)

Joffrey van Wageningen
ne2000.nl


-- 
PHP General 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] PHP Chat REALTIME

2002-01-22 Thread Joffrey van Wageningen

i forgot to mention in my last code sniplet:

just run the script (maybe touch a new file in /tmp and give it readwrite
rights)... you will have a run for 30 seconds (the php timeout)

if you want to add a line edit the file manualy or use the sniplet:

sniplet.php?new=mynewline

:)


-- 
PHP General 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] RE: Printing structure and data of array

2002-01-22 Thread Joffrey van Wageningen

how about:

?
$a = array(dit = array(zus, zo, bla), nog = array(wat, van,
dit = array(is, dat)), bla);

function displayarr($arr)
  {
  $c = ;
  echo array(;
  foreach($arr as $key = $val)
{
if($c)
  echo , ;

if(is_array($key))
  displayarr($key);
else
  echo \.$key.\ = ;

if(is_array($val))
  displayarr($val);
else
  echo \.$val.\;

$c++;
}
  echo );
  }

displayarr($a);

?

it prints the output just like you would enter it in your code...

with kind regards,
Joffrey van Wageningen
ne2000.nl

- Original Message -
From: Sandeep Murphy [EMAIL PROTECTED]
To: 'Tim Ward' [EMAIL PROTECTED]; PHP List
[EMAIL PROTECTED]
Sent: Tuesday, January 22, 2002 3:41 PM
Subject: RE: [PHP] RE: Printing structure and data of array



 nope...

 It continues to print in a single column indexed from 0 to  It does
not
 print the sub elements as sub elements.

 any more ideas???

 regards,
 sands
 -Original Message-
 From: Tim Ward [mailto:[EMAIL PROTECTED]]
 Sent: terça-feira, 22 de Janeiro de 2002 12:56
 To: Sandeep Murphy; PHP List
 Subject: RE: [PHP] RE: Printing structure and data of array


 how about ...

 function ShowArray($array)
 { echo(ul);
 foreach ($array as $key=$value)
 { echo(li$key)
 if (is_array($value))
 { ShowArray($value);
 } else
 { echo(=$value);
 }
 echo(/li)
 }
 echo(/ul);
 } // end of fn ShowArray


 Tim
 www.chessish.com

  -Original Message-
  From: Sandeep Murphy [SMTP:[EMAIL PROTECTED]]
  Sent: 22 January 2002 12:01
  To: 'Tim Ward'; PHP List
  Subject: RE: [PHP] RE: Printing structure and data of array
 
  hi,
 
  how can I display the array exactly as it is the format specified???
like
  if
  their exists sub elements of elements, how could I represent them in a
  multidimensional format??
 
  I went thru most of the array functions but unable to adapt any of
them..
 
  pl help..
 
  TIA,
  sands
 
  -Original Message-
  From: Tim Ward [mailto:[EMAIL PROTECTED]]
  Sent: segunda-feira, 21 de Janeiro de 2002 10:24
  To: PHP List; Daniel Alsén
  Subject: [PHP] RE: Printing structure and data of array
 
 
  Foreach($array as $key=$value) ech0($key=$valuebr);
 
  Tim
  www.chessish.com http://www.chessish.com
 
  --
  From:  Daniel Alsén [SMTP:[EMAIL PROTECTED]]
  Sent:  20 January 2002 19:33
  To:  PHP List
  Subject:  Printing structure and data of array
 
  Hi,
 
  i know i have this answered before. But i can´t find that mail in
  the
  archive.
 
  How do i print an array to see both the structure and the data
  within?
  (test = value, test2 = value2)...
 
  # Daniel Alsén| www.mindbash.com #
  # [EMAIL PROTECTED]  | +46 704 86 14 92 #
  # ICQ: 63006462   | +46 8 694 82 22  #
  # PGP: http://www.mindbash.com/pgp/  #
 
 
  --
  PHP General 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 General 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 General 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] PHP Chat REALTIME

2002-01-22 Thread Joffrey van Wageningen

 i haven't been following this, but have you guys thought of ircg?
 http://php.net/ircg

ircg is a lot of fun and could be used as the server system for message
management, the real problem is how to get the data  to the client without
use of a socket

ircg also needs an ircd which is a little to bloated[1] for a simple
solution for a realtime chat :)

/me is taking a extra jolt on ircg :)

Joffrey van Wageningen
ne2000.nl
--
[1]
bloat·ed (bltd)
adj.
  1.. Much bigger than desired: a bloated bureaucracy; a bloated budget.
  2.. Medicine. Swollen or distended beyond normal size by fluid or gaseous
material.




Re: [PHP] Prev Next Buttons

2002-01-22 Thread Joffrey van Wageningen

phpbuilder has a good article on prevnext buttons, the code is based on
mysql but take a look at the mysql  odbc functions... view, compare and
adjust to your needs:

http://www.phpbuilder.com/columns/rod20001214.php3

with kind regards,
Joffrey van Wageningen
ne2000.nl

- Original Message -
From: Alawi [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 22, 2002 4:06 PM
Subject: [PHP] Prev Next Buttons



How cam I make Prev Next Buttons with

ODBC+ACCESS XP by PHP :(




-- 
PHP General 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] Redeclare a Function

2001-11-14 Thread Joffrey van Wageningen


i recon this is a way too, the website does not support to much
information about how to use a tool like APD.

create_function is a php native function so support, stability and
usability is much greater than a 3rd party Zend Extention in early beta :)

with kind regards,

Joffrey van Wageningen

On Thu, 15 Nov 2001, Yasuo Ohgaki wrote:

 Joffrey Van Wageningen wrote:

  its possible to create lambda-style functions with create_function() and
  redeclare the variable functions
 
  ---
  $funct = create_function('$x', 'return ++$x;');
  echo $funct(10);
 
  $funct = create_function('$x', 'return --$x;');
  echo $funct(10);
  ---
 
  its fun to create array's of functions :) try it :P
 
  with kind regards,
  Joffrey van Wageningen


 APD can rename/redeclare functions also.

 http://apd.communityconnect.com/

 --
 Yasuo Ohgaki





-- 
PHP General 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] Redeclare a Function

2001-11-13 Thread Joffrey van Wageningen


its possible to create lambda-style functions with create_function() and
redeclare the variable functions

---
$funct = create_function('$x', 'return ++$x;');
echo $funct(10);

$funct = create_function('$x', 'return --$x;');
echo $funct(10);
---

its fun to create array's of functions :) try it :P

with kind regards,
Joffrey van Wageningen

On Tue, 13 Nov 2001, Andrey Hristov wrote:

 I think it's not possible.

 Andrey Hristov
 IcyGEN Corporation
 http://www.icygen.com
 BALANCED SOLUTIONS


 - Original Message -
 From: Michael Cronström [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, November 13, 2001 3:13 PM
 Subject: [PHP] Redeclare a Function


 Hi everybody,

 I would like to declare/redeclare a function twice in the same doc. Is it
 possible to unset/undeclare the function and include it again a second
 time? I have searched the manual but can´t find anything useful, any ideas?

 TIA
 Michael


 --
 PHP General 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 General 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]