[PHP] generating .doc on the fly

2004-01-06 Thread Naveed Ahmad
I want to save a document in .doc format on the fly but my server is running
on a linux machine. Can I still make use of COM object? Or there is some
other module which I can easily load on the fly???
somebody told me the link below butI cannot find the module from
there... :S
http://www.45.free.net/~vitus/ice/catdoc/

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



Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread Mike Migurski
I am looking for a comparison of features supported by PHP vs those
supported by Perl.

My gut tells me PHP is more robust, but we are trying to implement something
in a company that has long had a standard allowing Perl as a sanctioned
language, but current management does not want to fight for PHP as a new
sanctioned language (most managers there have never heard of PHP and the
resident Java zealots have almost established a monopoly).

PHP is designed to live in a web environment, so you'll probably find that
almost any feature needed in the typical usage of a webserver will be at
your fingertips. Your session example is a good one. So is automatic
inclusion of GET and POST variables, or access to Apache headers, or
availablity of interfaces to most databases, or projects such as PEAR that
further ease the use of high level functionality like XML parsing.
Personally,

PHP's strongest advantage for me is its transparent integration with
Apache, and the flexibility of using it in conjunction with mod_rewrite
(for example). Preliminary experiments with Java servers such as Resin
have left me with a profound sense of confusion at the litter of Servlet
and WEB-INF directories, only marginally related to the URL needed to
request them.

Perl has a strong developer community, and tons of available modules and
extensions for most imaginable purposes, but it was developed for
efficient parsing of text files and it's not necessarily intended for use
as an Apache module. I know of some very large, very busy applications
that run on mod_perl, but then again I've seen the source and it's not
pretty.


What would I lose by implementing in Perl (other than my mind)?

Losing your mind is a pretty good argument against Perl - It's a great
laguage, but its main strength (TMTOWDTI, a.k.a. There's More Than One Way
To Do It) is also its biggest drawback. Some of the most collosal code
headaches I've ever endured were the direct result of attempting to
unravel the exertions of experienced Perl hackers, parsing through
unending stretches of punctuation, following the implied $_.

OTOH, PHP's syntax is somewhat rooted in Perl, and it suffers from many of
the same drawbacks, though it's vastly more approachable. The other
extreme is Java, where it seems that every simple thing that would be a
one-liner in Perl has to be contorted into a senseless OOP framework in
the interest of reusability and portability.

Anyway, if you're the only person pulling for PHP and there's a crew of
Java toughs breathing down your neck, you may find that this is a losing
battle for you.


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



RE: [PHP] Cannot send session cache limiter SOLVED

2004-01-06 Thread john
 from the code:

  ?php
  include 'navigationStart3.php4';

 Are these indents in the code (changeAlertDetails3.php4 I think)? You
 can't have anything before the ?php.

yup, that was it red face, sorted, thanks everyone

J

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



[PHP] Re: Comparison PHP to Perl

2004-01-06 Thread Al
Warren Vail [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am looking for a comparison of features supported by PHP vs those
 supported by Perl.

[snip]

Ah, this old chestnut.

As someone who wrote a major application in Perl, and now (mostly) uses PHP,
I can only reiterate what's been said a thousand times before: the language
you choose depends on what features you want and the type of script you'll
be writing.

You've only identified session support as a requirement, and although PHP
has native session support, Perl has similar functionality available via the
Apache::Session CPAN module. Actually, this is true for almost all extra
native functionality in PHP that Perl does not support -- it's there in
Perl, but you need to download a CPAN module for it. Another example of this
is PHP's native mail( ) support. (For the uninitiated, CPAN
[http://www.cpan.org] is a fantastic collection of standardised Perl
extensions with an easy install script that has evolved over many years).

Unfortunately the same does not apply for PHP: although it has an impressive
array of built-in functions (especially compared to Perl's paltry offering),
if a particular feature is not handled natively then you'll probably have to
write your own code to implement it. Although there *is* a CPAN equivalent
in PHP called PEAR [http://pear.php.net] that boasts a decent number of
modules (most of which are still in early development stages), PHP simply
hasn't been around long enough attract as much module development as Perl.

So in summary: list all the features you need and if PHP supports them all
(or if a few are missing and PHP's ease-of-use and other benefits outweigh
the cons) then go with PHP, otherwise take another look at Perl. For a list
of PHP's features, take a look at the documentation ... it's very
user-friendly. [http://www.php.net/manual/en/]

You'll also find a ridiculously large number of articles online comparing
PHP to Perl, just do a Google search such as:
[http://www.google.com/search?q=php+perl+comparison]

Hope it helps,

Al

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



[PHP] globals?

2004-01-06 Thread Bryan Koschmann - GKT
Hi,

I was just curious, how much longer are globals going to be supported? I
had heard awhile back that they wouldn't be around for too long.

Thanks,

Bryan

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



[PHP] Re: detaching and running php processes in the background

2004-01-06 Thread Gary C. New
In order to get this to work I had to do several things.

1.  I had initially compiled my php installation as a server-side 
module, but in order to execute and detach a background php process I 
had to recompile my php installation as a binary installation (hint: if 
you compile php as a binary and then as a server-side module you can 
take advantage of both installation types--that is what I ended up doing).

2.  Next you must reference the php binary with the '-f' option to 
execute the desired php script.  To pass variables, you must reference 
them in a single quoted string prefacing each with a '' symbol. 
Finally write all signals to '/dev/null' and release it into the 
background using an ending '' symbol.

Example:

shell_exec(/usr/local/bin/php -f ./user-create.php 'uid= . $uid . 
vdomain= . $vdomain . password= . $password . '  /dev/null );

3.  In the primary php script (./user-create.php) escape any shell 
command variables that have been supplied by human input (security).

$u = escapeshellcmd($uid);
$d = escapeshellcmd($vdomain);
$p = escapeshellcmd($password);
4.  You should put any child commands you want to spawn in the primary 
script (./user-create.php) as this will help with maintaining the number 
of rogue processes that you might need to deal with.

shell_exec(useradd -d /home/$d $u);
shell_exec(passwd $u  $p);
That's it!

I know it sounds a bit complicated, but after you have all the right 
components functional it is quite easy.

Hope this helps all those of you who have requested it.

Respectfully,

Gary

Gary C. New wrote:
What is the best way to detach and run a command line based php script 
in the background from a web-based php script, without the need for 
reporting?

I have a web-based php script that gathers information and then passes 
it off to several functions, which execute several other php scripts. 
The problem is that the main php script does not return until all the 
processes have signaled and is taking about 30 sec to complete.  There 
is no need for the child processes spawned by the main php script to 
signal.  I would like to spawn and detach them to finish in the 
background; thus, dramatically reducing the load time of the main php 
script.

It has been suggested to me to use the  with the shell_exec function, 
but this still requires the child processes to signal.

Another suggestion was to use the pcntl_fork function, but my reading 
suggest that this is not to be used with web-based applications and does 
not compile in with mod_php (only the binary version).  If I were to use 
the binary version would I even be able to detach the forked child 
processes?  Doesn't pcntl_fork still require the child processes to 
signal to the parent before exiting otherwise becoming zombie processes?

Any suggestions on the best way to handle this?

Respectfully,

Gary

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


[PHP] web-based and command line mcrypting and back again

2004-01-06 Thread Gary C. New
I am trying to figure out how to encrypt data using the web-based php 
mcrypt function and then decrypt it using the command line (cli) mcrypt 
binary, and vica-versa.

I cannot seem to get the same encrypted output for the same data, 
between the two methods.  I've tried to ensure I am using the same 
algorithms and modes for both methods by testing the mcrypt_enc_get_* 
functions.  I think the problem may lie in the way both methods are 
being seeded.

Web-Based PHP Example:

$key = 'test';
$data[] = 'abcdefghijklmnopqrstuvwxyz';
$m = 0;
foreach ($data as $dt)
{
   $td = mcrypt_module_open('tripledes', '', 'ecb', '');
   $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
   mcrypt_generic_init($td, $key, $iv);
   $CRYPT[$m] = mcrypt_generic($td, $dt);
/*
   echo mcrypt_enc_get_algorithms_name($td);
   echo mcrypt_enc_get_block_size($td);
   echo mcrypt_enc_get_iv_size($td);
   echo mcrypt_enc_get_key_size($td);
   echo mcrypt_enc_get_modes_name($td);
   echo mcrypt_enc_get_supported_key_sizes($td);
   echo mcrypt_enc_is_block_algorithm_mode($td);
   echo mcrypt_enc_is_block_algorithm($td);
   echo mcrypt_enc_is_block_mode($td);
   echo mcrypt_enc_self_test($td);
*/
   $DECRYPT[$m] = mdecrypt_generic($td, $dt);
   mcrypt_generic_deinit($td);
   mcrypt_module_close($td);
   echo crypt_ . base64_encode($CRYPT[$m]) . _br /\n;
   echo decrypt_ . base64_decode(rtrim($DECRYPT[$m])) . _br /\n;
   $m++;
}
Note:  I believe it is the line where the $iv variable is being set that 
is causing the issue and/or I cannot reproduce the same seeding using 
the command line options.

Command Line Example:

echo abcdefghijklmnopqrstuvwxyz | mcrypt -Fb -m ecb -a tripledes | 
encode-base64

echo  | decode-base64 | mcrypt -dFb -m ecb -a tripledes

I would appreciate any comments or suggestions.

Respectfully,

Gary

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


Re: [PHP] [Fwd: failure notice] Why??

2004-01-06 Thread David T-G
Rolf, et al --

...and then Rolf Brusletto said...
% 
% Whenever I submit a message to this list, I get a bounce back saying its 
% a dupe, anyone have any ideas?

I figured some pair subscriber has a loop in his .forward setup.


% 
% -- 
% Rolf Brusletto
% rolf[at]emailfeeds[dot]com
% http://www.emailfeeds.com


HTH  HAND  HNY

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] web-based and command line mcrypting and back again

2004-01-06 Thread Tom Rogers
Hi,

Tuesday, January 6, 2004, 8:48:17 PM, you wrote:
GCN I am trying to figure out how to encrypt data using the web-based php
GCN mcrypt function and then decrypt it using the command line (cli) mcrypt
GCN binary, and vica-versa.

GCN I cannot seem to get the same encrypted output for the same data,
GCN between the two methods.  I've tried to ensure I am using the same
GCN algorithms and modes for both methods by testing the mcrypt_enc_get_*
GCN functions.  I think the problem may lie in the way both methods are
GCN being seeded.

GCN Web-Based PHP Example:

GCN $key = 'test';
GCN $data[] = 'abcdefghijklmnopqrstuvwxyz';
GCN $m = 0;

GCN foreach ($data as $dt)
GCN {
GCN $td = mcrypt_module_open('tripledes', '', 'ecb', '');
GCN $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
GCN mcrypt_generic_init($td, $key, $iv);
GCN $CRYPT[$m] = mcrypt_generic($td, $dt);

GCN /*
GCN echo mcrypt_enc_get_algorithms_name($td);
GCN echo mcrypt_enc_get_block_size($td);
GCN echo mcrypt_enc_get_iv_size($td);
GCN echo mcrypt_enc_get_key_size($td);
GCN echo mcrypt_enc_get_modes_name($td);
GCN echo mcrypt_enc_get_supported_key_sizes($td);
GCN echo mcrypt_enc_is_block_algorithm_mode($td);
GCN echo mcrypt_enc_is_block_algorithm($td);
GCN echo mcrypt_enc_is_block_mode($td);
GCN echo mcrypt_enc_self_test($td);
GCN */

GCN $DECRYPT[$m] = mdecrypt_generic($td, $dt);
GCN mcrypt_generic_deinit($td);
GCN mcrypt_module_close($td);

GCN echo crypt_ . base64_encode($CRYPT[$m]) . _br /\n;
GCN echo decrypt_ . base64_decode(rtrim($DECRYPT[$m])) . _br /\n;

GCN $m++;
GCN }

GCN Note:  I believe it is the line where the $iv variable is being set that
GCN is causing the issue and/or I cannot reproduce the same seeding using
GCN the command line options.


GCN Command Line Example:

GCN echo abcdefghijklmnopqrstuvwxyz | mcrypt -Fb -m ecb -a tripledes |
GCN encode-base64

GCN echo  | decode-base64 | mcrypt -dFb -m ecb -a tripledes


GCN I would appreciate any comments or suggestions.

GCN Respectfully,


GCN Gary


try setting the iv to all 0's
$iv = 0;
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);

-- 
regards,
Tom

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



Re: [PHP] Readfile, DAP and 3 questions

2004-01-06 Thread Adam i Agnieszka Gasiorowski FNORD
Ryan A wrote:
 
 Opera version 6.5 and 7...
 I already had that set.

Try asking again on news:opera.general
 (if your server does not carry this newsgroup,
 try news.opera.com). There are more Opera
 - knowleable people there :8]. I recall that
 there is a solution, I just cannot find it
 right now.

-- 
Seks, seksi, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa)   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne ksztaty... http://www.opera.com 007

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



[PHP] Error/ Warning messages in log files (OS 121) and (OS 64)

2004-01-06 Thread Trevor Dowling
(Relisted as no response from over Xmas period)

Hi,

I am having a real problem with error messages posted in the error.log file

in the Apache directory. I have been doing lots of searches to find a

solution and it seems obvious that many people are see this issue but I can

find no resolution or explanation for the entries (see below).

PHP Bug #25570 seemed to be a solution but the version of php I am using is

4.3.2 which is claimed to not exhibit the bug described in 25570.

The system is running on a Win2K box, and we are using php, sql and Apache.


Anyone out there have an idea of how to fix this issue?

Thanks

Trevor





Some system info:

System Windows NT UKRBCSR01 5.0 build 2195

Build Date May 28 2003 15:06:05

Server API Apache 2.0 Handler

Apache/2.0.47 (Win32) PHP/4.3.2

This is the more worring of the issues:

21:18:49 2003 [notice] Parent: child process exited with status

4294967295 -- Restarting.



But I am assuming that some or all of these are related.

21:19:44 2003 [warn] (OS 121)The semaphore timeout period has expired. :

winnt_accept: Asynchronous AcceptEx failed.

00:50:58 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.



Error Log snipit


21:18:16 2003 [notice] Parent: Created child process 3180

21:18:16 2003 [notice] Child 3180: Child process is running

21:18:16 2003 [notice] Child 3180: Acquired the start mutex.

21:18:16 2003 [notice] Child 3180: Starting 250 worker threads.

21:18:49 2003 [notice] Parent: child process exited with status

4294967295 -- Restarting.

21:18:49 2003 [notice] Parent: Created child process 676

21:18:49 2003 [notice] Child 676: Child process is running

21:18:49 2003 [notice] Child 676: Acquired the start mutex.

21:18:49 2003 [notice] Child 676: Starting 250 worker threads.

21:19:44 2003 [warn] (OS 121)The semaphore timeout period has expired. :

winnt_accept: Asynchronous AcceptEx failed.

00:50:58 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

00:50:58 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

01:54:48 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

02:00:14 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

05:41:18 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

06:03:28 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

06:31:33 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

07:30:38 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

07:30:38 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

07:42:30 2003 [warn] (OS 64)The specified network name is no longer

available. : winnt_accept: Asynchronous AcceptEx failed.

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



Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread David T-G
Warren --

...and then Warren Vail said...
% 
% I am looking for a comparison of features supported by PHP vs those
% supported by Perl.

In general, I'd say that there's nothing that one can do that the other
can't, though I'd also say that for things not native to the language
(or even for things native that someone wanted to do differently :-)
perl will have a better library of modules available.


% 
% My gut tells me PHP is more robust, but we are trying to implement something

Interesting...  perl is a much more mature and seasoned language than
php; why do you figure the latter to be more robust, or perhaps how do
you define the term?  [Don't get me wrong; I think that php is growing
like a weed and will, within just a few years, show that same level of
maturity, depth of functionality (very much via contributed code), and
breadth of deployment.]


% in a company that has long had a standard allowing Perl as a sanctioned
% language, but current management does not want to fight for PHP as a new
% sanctioned language (most managers there have never heard of PHP and the
% resident Java zealots have almost established a monopoly).  The kind of

Bleah.  Anything but Java!


% thing I am looking for is SESSION support, I know it's supported by PHP, but
% not sure about Perl.  I don't want to have to grow my own session manager.

Recall that, for many years, nearly all dynamic web pages under Apache
were written in perl; after all, nobody wanted the overhread of a shell
process and nobody wanted the hassle of writing in C.  I will say with
confidence that perl can do anything that php can do, including sessions
(though I'm not an expert in either language; in fact, my perl is quite
rusty since I've been doing very primarily php for a while now).  There
is almost no piece in perl, such as the session manager you mention,
which you have to write; it's not uncommon to write a script which uses
a bunch of different modules and all you write is a bit of glue calling
one and handing to the other :-)

Does that make it right or wrong for you?  Nope; not by any means.  One
of the great shining points of php, IMHO, is how easy it is to write the
code and how you can turn it on and off for spitting out raw HTML (though
I must admit that I very, very rarely do so myself and even keep trying
to move to abstraction of data via templates, but that's neither here nor
there), and I agree with Mike that you can get punctuation soup pretty
quickly in perl -- though that's usually because of lazy programming, and
you can have lazy or bad programming in any language, including php.

You might talk to some of the more sane perl zealots there (yes, I'm sure
there are plenty and off the deep end, too :-) to learn a bit about perl
and cpan and more.  You might find it not so bad.  I definitely prefer it
for doing system scripts; I use the php CLI for one-lining test code, and
I have written php system scripts, but perl is [currently] better suited
to tasks where the web is nowhere in sight.


% One alternative is mainframe COBOL, which clearly will not support what we
% want to do.

As I said, anything but Java :-)


% 
% What would I lose by implementing in Perl (other than my mind)?

Probably nothing.  Meanwhile, by moving away from their standard language
for this one project, you'd be introducing a whole new ball of maintenance
that probably shouldn't be there.  If you want php for one project, don't.
If you want php as a new language, you might pick some of the uglier perl
scripts they have and rewrite them in php to show how straightforward and
pretty it is.


% 
% thanks in advance,

Good luck!


% 
% Warren Vail
% [EMAIL PROTECTED]


HTH  HAND  Happy New Year

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


RE: [PHP] Getting results from Select Multiple HTML tag

2004-01-06 Thread Ford, Mike [LSS]
On 06 January 2004 04:06, Tyler Longren wrote:

 Hi,
 
 http://www.php.net/manual/en/faq.html.php#faq.html.select-multiple
 
 I read that.  Doesn't work in php since the whole register_globals
 thing.  Now, when I get the results from a form, they're all in a
 $_POST[] array.  Example. 
 
 When I have a select name=test MULTIPLE
 I would have to access the values of the test field like this:
 count($_POST['test']); 
 
 But since I have to have the [] in the name=select name=test[]
 MULTIPLE ()part, I get parse errors when trying to read it:
 ex: count($_POST['test[]']);

The array you get is $_POST['test'] -- you can use that just like any other
array, so:

   $how_many = count($_POST['test']);

   $first = $_POST['test'][0];
   $second = $_POST['test'][1];

etc.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Strange IF(condition) behaviour

2004-01-06 Thread Ford, Mike [LSS]
On 06 January 2004 03:58, Tim L wrote:

 I'm not sure if this is intended behaviour or not, but I can
 see that is
 might be.  Just thought I would bounce this to see what
 people think about
 it:
 
 ?php
  if (false)
 ? Hello?php
  else
   echo Hi;
 
  echo  World\n;
 ? 
 
 This returns a parse error due to the fact there is no
 brackets around the
 first part of the if statement.

Yes, but that's only part of the story.  What you seem to be neglecting here
is that the closing ? tag also implies a semicolon, so the above is
equivalent to:

  ?php
   if (false) ;
  echo Hello
   else
  echo Hi;
 
   echo  World\n;
  ? 

and I'm sure you can see why that is both syntactically and semantically
invalid.

It's because of this implied semicolon that any conditional or loop in which
you break out of PHP must be enclosed in braces, or use the colon syntax.
The following are valid ways of doing what you want:

  ?php
   if (false) {
  ? Hello?php
   }
   else
  echo Hi;
 
   echo  World\n;
  ? 

   if (false):
  ? Hello ?php
   else:
  ? Hi ?php
   endif;
 
   echo  World\n;
  ?

  It seems that because the
 next line after
 the if is not php, then it terminates the if at the closing
 of the php tag.

As I'm sure you can see now, this is becaue of the implied semicolon.
Possibly the easiest way to work out what's going on when you break in and
out of PHP is just to remember that any time you have a fragment like:

   ? something ?php

This is treated like

  ; echo something

(Notice the semicolon at the beginning, and the lack of one at the end!)

 
 But if you do this:
 
 ?php
  if (false)
 ? Hello?php
 ? 
 
 or
 
 ?php
  if (true)
 ? Hello?php
 ? 

These are syntactically valid because the closing ? tags imply the
necessary semicolons, but semantically wrong because the first one
terminates the if statement -- so the Hello will be output unconditionally
(and a following else would be syntactically invalid again!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Newbie with sorting problem

2004-01-06 Thread Bart Koppe
Hi all,

I'm quite a newbie ot php/mysql, so my question might be oversimple 
(though i tried for hours to understand..)
I'm making an addressbook, as a try out, to see how it al works. All is 
great actually, but only the sorting of the addresses seems complicated 
for me..
I have a databse called 'addressen', and four fields of this db are 
called 'id', 'name', 'surname' and 'address'
To display the content i use this:

?
	include( file_that_connects_with_my_database.php);
	$result = mysql_query(
  SELECT id, name, surname, address FROM addresses);
  	if (!$result) {
  		echo( pError performing query:  .
  mysql_error() . /p);
   		exit();
  	}
   	while ( $row = mysql_fetch_array($result) ) {
 		$addressid = $row[id];
  		$nametext = $row[name];
   		$surnametext = $row[surname];
   		$addresstext = $row[address];
   		//the table
  		echo( table width='100%' border='0' cellspacing='0' 
cellpadding='0'trtd);
  		echo( $addressid. /tdtd);
  		echo( $nametext. /tdtd);
  		echo( $surnametext. /tdtd);
  		echo( $addresstext /tdtd);
	  	echo( /tr/table);
  	}
?
This scripts works, but.. my desire is now to be able to sort the 
output, wich is generated by the 'while' loop, for instance on 'name', 
or on 'surname' . sort(), ksort()? I couldn't understand the 
explanations i found (and so declared myself as newbie :)

Can anybody help me with this? I would be delighted...

Thanks in advange!

Bart Koppe

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


[PHP] Re: Newbie with sorting problem

2004-01-06 Thread pete M
Just add order by to the sql query instead eg

SELECT id, name, surname, address FROM addresses order by name asc;

or descending on surname
eg
SELECT id, name, surname, address FROM addresses order by surname desc;
hope this helps

Pete

Bart Koppe wrote:
Hi all,

I'm quite a newbie ot php/mysql, so my question might be oversimple 
(though i tried for hours to understand..)
I'm making an addressbook, as a try out, to see how it al works. All is 
great actually, but only the sorting of the addresses seems complicated 
for me..
I have a databse called 'addressen', and four fields of this db are 
called 'id', 'name', 'surname' and 'address'
To display the content i use this:

?
include( file_that_connects_with_my_database.php);
$result = mysql_query(
  SELECT id, name, surname, address FROM addresses);
  if (!$result) {
  echo( pError performing query:  .
  mysql_error() . /p);
   exit();
  }
   while ( $row = mysql_fetch_array($result) ) {
 $addressid = $row[id];
  $nametext = $row[name];
   $surnametext = $row[surname];
   $addresstext = $row[address];
   //the table
  echo( table width='100%' border='0' cellspacing='0' 
cellpadding='0'trtd);
  echo( $addressid. /tdtd);
  echo( $nametext. /tdtd);
  echo( $surnametext. /tdtd);
  echo( $addresstext /tdtd);
  echo( /tr/table);
  }
?
This scripts works, but.. my desire is now to be able to sort the 
output, wich is generated by the 'while' loop, for instance on 'name', 
or on 'surname' . sort(), ksort()? I couldn't understand the 
explanations i found (and so declared myself as newbie :)

Can anybody help me with this? I would be delighted...

Thanks in advange!

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


RE: [PHP] Newbie with sorting problem

2004-01-06 Thread Jay Blanchard
[snip]
$result = mysql_query(
SELECT id, name, surname, address FROM
addresses);
This scripts works, but.. my desire is now to be able to sort the 
output, wich is generated by the 'while' loop, for instance on 'name', 
or on 'surname' . 
[/snip]

Do it in the query

SELECT id, name, surname, address FROM addresses ORDER BY name
SELECT id, name, surname, address FROM addresses ORDER BY surname

etc.

You can sort the array too, but the database in perfectly equipped to
perform the sort much more efficiently.

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



Re: [PHP] Newbie with sorting problem

2004-01-06 Thread Richard Davey
Hello Bart,

Tuesday, January 6, 2004, 12:40:38 PM, you wrote:

BK This scripts works, but.. my desire is now to be able to sort the
BK output, wich is generated by the 'while' loop, for instance on 'name',
BK or on 'surname' . sort(), ksort()? I couldn't understand the 
BK explanations i found (and so declared myself as newbie :)

It's probably a lot easier to sort the data at the SQL level rather
than messing around with your array.

For example:

$result = mysql_query(
SELECT id, name, surname, address FROM addresses ORDER BY name DESC);

Will list by name alphabetically (A-Z), change to ASC for Z-A).
You can also order by two fields at once:

$result = mysql_query(
SELECT id, name, surname, address FROM addresses ORDER BY name DESC,
surname DESC);

Or some selective sorting:

$result = mysql_query(
SELECT id, name, surname, address FROM addresses WHERE name LIKE 'a%'
ORDER BY name DESC);

Will list all names starting with the letter A, in alphabetical order.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] str_replace to ignore commas

2004-01-06 Thread Vernon
I'm trying to use str_replace to ignore sertain characters from a recordset
field and it seems I am having difficulties with ignoring commas and
carriage returns. I've gotten the following but when searching for, let's
say, New York. When York is at the end of a sentence from a recordset field
it is skipped and if it has a comma like York, it is skipped. Any ideas?
Here's the code I'm using so far

//IGNORED CHARACTERS
$replacement = array(\, \,, ., !, ?);

//CREATE THE ARRAY OF WORDS
//STRIP SLASHES, IGNORE CAPS, IGNORE REPLACEMET CHARACTERS
//$keywords = form field value
$words=explode( , stripslashes(strtolower(str_replace($replacement, ,
$keywords;

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



[PHP] PHP function for length of the array???

2004-01-06 Thread Scott Fletcher
Hi!

   Anyone know what is the php function for finding the length of the array?
I haven't found the answer at http://us3.php.net/manual/en/ref.array.php .

Thanks,
 FletchSOD

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



Re: [PHP] PHP function for length of the array???

2004-01-06 Thread Chris Hayes
At 15:44 6-1-04, you wrote:
Hi!

   Anyone know what is the php function for finding the length of the array?
I haven't found the answer at http://us3.php.net/manual/en/ref.array.php .
looking for the number of elements? -count($arrayname)

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


[PHP] Re: Strange IF(condition) behaviour

2004-01-06 Thread Michal O¹kera
Hi Tim,


 ?php
  if (false)
   ?Hello?php
 ?

 or

 ?php
  if (true)
   ?Hello?php
 ?


at first, I'd like to point out that semicolon as a statement separator is
not required before end of the
php fragment and is supplied automatically during parsing. That's why the
if-statements initiated above
are evaluated independently of the rest of code and 'Hello' is always on
output. It is equivalent to:

 ?php
  if (false);
   ?Hello?php
 ?

 or

 ?php
  if (true);
   ?Hello?php
 ?


 ?php
  if (false)
   ?Hello?php
  else
   echo Hi;

  echo  World\n;
 ?


For this reason the above fragment generates parse error because 'if' is
evaluated separately and then
'else' is unexpected. If You want to interlard the php control blocks (in
case of if, switch, for, etc.
statements) You must use colon syntax as following:

 ?php
  if (false):
   ?Hello?php
  else:
   echo Hi;
 endif; //this is is the end of the if statement; its required when using
colon syntax

  echo  World\n;
 ?

Hope it helps,
Mike

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



Re: [PHP] PHP function for length of the array???

2004-01-06 Thread Scott Fletcher
Ah!  Thanks!!!

Chris Hayes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 At 15:44 6-1-04, you wrote:
 Hi!
 
 Anyone know what is the php function for finding the length of the
array?
 I haven't found the answer at http://us3.php.net/manual/en/ref.array.php
.
 looking for the number of elements? -count($arrayname)

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



Re: [PHP] str_replace to ignore commas

2004-01-06 Thread Chris Hayes
At 15:29 6-1-04, you wrote:
I'm trying to use str_replace to ignore sertain characters from a recordset
field and it seems I am having difficulties with ignoring commas and
carriage returns. I've gotten the following but when searching for, let's
say, New York. When York is at the end of a sentence from a recordset field
it is skipped and if it has a comma like York, it is skipped. Any ideas?
Here's the code I'm using so far
//IGNORED CHARACTERS
$replacement = array(\, \,, ., !, ?);
//CREATE THE ARRAY OF WORDS
//STRIP SLASHES, IGNORE CAPS, IGNORE REPLACEMET CHARACTERS
//$keywords = form field value
$words=explode( , stripslashes(strtolower(str_replace($replacement, ,
$keywords;
could the problem be that you explode on   so the phrase 'New York', 
having a space, is split up?

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


Re: [PHP] str_replace to ignore commas

2004-01-06 Thread Vernon
 could the problem be that you explode on   so the phrase 'New York',
 having a space, is split up?

Could be. Some times the New is on one line and the York is on the next
line. I need for it to explode no matter what. How would I do that?

For instance the print_r for the array shows me this in one instance. None
of which is hightlighted (and should be) in other words all of these where
skipped and the New York should have been selected. I know that the comma is
causing trouble as well.

/ New [913] = York, [914] = New [915] = York
/ Dear [917] = Mr. [918] = Conlin:

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



Re: [PHP] developing a plug-in framework

2004-01-06 Thread Justin French
As a follow-up to my own post, I found the following resources good for 
inspiration of both implementation methods and general insight:

http://gplugs.sourceforge.net/pluginman/
http://nucleuscms.org/documentation/devdocs/plugins.html
I've already written about 1000 words specifying my own ideas for an 
API (much more complex and generic than these blog-centric API's), and 
I'm pretty excited about where it's heading.

Thanks to Brad for his response too.

Justin French

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


Re: [PHP] generating .doc on the fly

2004-01-06 Thread Marek Kilimajer
Simply create a html file and give the user impression that it's in doc 
format - output the right header and give it .doc extension

Naveed Ahmad wrote:
I want to save a document in .doc format on the fly but my server is running
on a linux machine. Can I still make use of COM object? Or there is some
other module which I can easily load on the fly???
somebody told me the link below butI cannot find the module from
there... :S
http://www.45.free.net/~vitus/ice/catdoc/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] str_replace to ignore commas

2004-01-06 Thread Chris Hayes
At 15:58 6-1-04, you wrote:
 could the problem be that you explode on   so the phrase 'New York',
 having a space, is split up?
Could be. Some times the New is on one line and the York is on the next
line. I need for it to explode no matter what. How would I do that?
For instance the print_r for the array shows me this in one instance. None
of which is hightlighted (and should be) in other words all of these where
skipped and the New York should have been selected. I know that the comma is
causing trouble as well.
/ New [913] = York, [914] = New [915] = York
/ Dear [917] = Mr. [918] = Conlin:
well I don't know about the highlighting.
first try to debug by doing the several steps separately,
So start with the str_replace, see if that works as expected. Actually I 
wonder why you are escaping the comma \,. Try to remove that \backslash.
Next idea: what about replacing with   ?

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


[PHP] This is why PHP sucks

2004-01-06 Thread Big Walker
http://www.americansubstandard.com/index.php?sub=vword=vmail

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



Re: [PHP] str_replace to ignore commas

2004-01-06 Thread Richard Davey
Hello Vernon,

Tuesday, January 6, 2004, 2:29:31 PM, you wrote:

V I'm trying to use str_replace to ignore sertain characters from a recordset
V field and it seems I am having difficulties with ignoring commas and
V carriage returns. I've gotten the following but when searching for, let's

Nowhere in your replacement array do you check for, or remove,
carriage returns.

Add this \n to it:

$replacement = array(\, \,, ., !, ?, \n);

Your exploded array should now be correct.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] PHP function for length of the array???

2004-01-06 Thread Neil Freeman
Or you can use sizeof() which is an alias for count()

Scott Fletcher wrote:
***
This Email Has Been Virus Swept
***
Ah!  Thanks!!!

Chris Hayes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
At 15:44 6-1-04, you wrote:

Hi!

  Anyone know what is the php function for finding the length of the
array?

I haven't found the answer at http://us3.php.net/manual/en/ref.array.php
.

looking for the number of elements? -count($arrayname)


--
--
 www.curvedvision.com
--


This communication is confidential to the intended recipient(s). If you are not that person you are not permitted to make use of the information and you are requested to notify the sender immediately of its receipt then destroy the copy in your possession. Any views or opinions expressed are those of the originator and may not represent those of Advanced System Architectures Ltd.

*** This Email Has Been Virus Checked ***

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


RE: [PHP] generating .doc on the fly

2004-01-06 Thread jon
Nah... You can't use COM in Linux, but you can generate an RTF pretty
easily, which will open right up in Word with no problems whatsoever.

-- jon

---
jon roig
web developer
email: [EMAIL PROTECTED]
phone: 888.230.7557



-Original Message-
From: Naveed Ahmad [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 06, 2004 12:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP] generating .doc on the fly


I want to save a document in .doc format on the fly but my server is
running on a linux machine. Can I still make use of COM object? Or there
is some other module which I can easily load on the fly??? somebody told
me the link below butI cannot find the module from there... :S
http://www.45.free.net/~vitus/ice/catdoc/

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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003
 

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



[PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Dave G
PHP Gurus

A while ago on this list I posted a few questions about an eregi
filter for email addresses entered into a form. With the help of people
on this list, I settled on the following code which has worked fine in
the months since I started using it. The code is this:

eregi('[EMAIL PROTECTED]', $email)

But recently, a person was unable to get their email to pass
this eregi test. The email is valid, as they are able to send email to
me. It has the following format:

[EMAIL PROTECTED]

Shouldn't this email pass? I've allowed for hyphens after the @
mark. Is it that there are two many periods?

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]





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



Re: [PHP] str_replace to ignore commas

2004-01-06 Thread Vernon
 Nowhere in your replacement array do you check for, or remove,
 carriage returns.
 Add this \n to it:
 $replacement = array(\, \,, ., !, ?, \n);
 Your exploded array should now be correct.

When I do this I get some really unexpected results. Almost everything comes
up bold.

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



RE: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Ford, Mike [LSS]
On 06 January 2004 15:53, Dave G wrote:

 PHP Gurus
 
   A while ago on this list I posted a few questions about an eregi
 filter for email addresses entered into a form. With the help
 of people
 on this list, I settled on the following code which has worked fine in
 the months since I started using it. The code is this:
 
 eregi('[EMAIL PROTECTED]', $email)
 
   But recently, a person was unable to get their email to pass
 this eregi test. The email is valid, as they are able to send email to
 me. It has the following format:
 
 [EMAIL PROTECTED]
 
   Shouldn't this email pass? I've allowed for hyphens after the @
 mark. Is it that there are two many periods?

No.  You've only allowed for hyphens in the first element after the @ sign
-- this address has them in the 2nd element.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] [Fwd: failure notice] Why??

2004-01-06 Thread Chris Shiflett
--- Richard Davey [EMAIL PROTECTED] wrote:
 Hello Rolf,
 
 Tuesday, January 6, 2004, 1:26:31 AM, you wrote:
 
 RB Whenever I submit a message to this list, I get a bounce back saying
 RB a dupe, anyone have any ideas?
 
 I get exactly the same - it's highly annoying and happens every time.
 
 Do you use Pair Networks by any chance? (I do and post via their SMTP
 server).

I think it happens for everyone, and Pair hosts a lot of the php.net
stuff, including handling the email, so I doubt it matters whether you use
Pair for SMTP.

I assume (I could be wrong) that they're working on the problem, but it
has been several days...

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re[2]: [PHP] str_replace to ignore commas

2004-01-06 Thread Richard Davey
Hello Vernon,

Tuesday, January 6, 2004, 3:56:18 PM, you wrote:

 Nowhere in your replacement array do you check for, or remove,
 carriage returns.
 Add this \n to it:
 $replacement = array(\, \,, ., !, ?, \n);
 Your exploded array should now be correct.

V When I do this I get some really unexpected results. Almost everything comes
V up bold.

Remove the back-slash before the comma in the replacement array, it
doesn't work if you have it.

Otherwise, it fulfills the criteria of removing the characters you
requested from the string, therefore the error lies elsewhere either
in the original data containing something that isn't being taken into
consideration, or the high-lighting working on different rules.

One possible issue is the fact that if you remove all comma's and
carriage returns, the following:

New York,
was here

will become exploded as:

New
Yorkwas
here

Perhaps you don't want to actually remove carriage returns at all, but
rather substitute them with spaces - like I said though, it depends on
your original data.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread CPT John W. Holmes
From: Dave G [EMAIL PROTECTED]

 A while ago on this list I posted a few questions about an eregi
 filter for email addresses entered into a form. With the help of people
 on this list, I settled on the following code which has worked fine in
 the months since I started using it. The code is this:

 eregi('[EMAIL PROTECTED]', $email)

 But recently, a person was unable to get their email to pass
 this eregi test. The email is valid, as they are able to send email to
 me. It has the following format:

 [EMAIL PROTECTED]

 Shouldn't this email pass? I've allowed for hyphens after the @
 mark. Is it that there are two many periods?

You're only allowing hyphens in the first part of the address after the @
symbol, though, before the first period. Maybe your regex should be:

@([a-zA-Z0-9-]+\.)+[a-zA-Z.]

Just noticed that your period is not escaped, either, so you're actually
matching any character with the one that's outside of the [ and ] character
classes.

---John Holmes...

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



Re[2]: [PHP] [Fwd: failure notice] Why??

2004-01-06 Thread Richard Davey
Hello Chris,

Tuesday, January 6, 2004, 4:13:09 PM, you wrote:

CS I think it happens for everyone, and Pair hosts a lot of the php.net
CS stuff, including handling the email, so I doubt it matters whether you use
CS Pair for SMTP.

CS I assume (I could be wrong) that they're working on the problem, but it
CS has been several days...

No, they're not. I emailed their support team about it on the 10th of
December and they wrote back saying they didn't know why it was
happening and maybe it was a local configuration error. Now I know it
happens for everyone, it's obviously not.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread Raditha Dissanayake
Hi,

One man's perl is another man's headache. beeng using perl for six years 
and i have trouble understanding what other people wrote with it and 
vice verce. not so with PHP. and what ever the module you find on CPAN 
you will find an equivalent or similar in PHP as well.

And finally on java, if your collegues think java is ideal for web 
applications they are zealots indeed!

all the best

Warren Vail wrote:

I am looking for a comparison of features supported by PHP vs those
supported by Perl.
My gut tells me PHP is more robust, but we are trying to implement something
in a company that has long had a standard allowing Perl as a sanctioned
language, but current management does not want to fight for PHP as a new
sanctioned language (most managers there have never heard of PHP and the
resident Java zealots have almost established a monopoly).  The kind of
thing I am looking for is SESSION support, I know it's supported by PHP, but
not sure about Perl.  I don't want to have to grow my own session manager.
One alternative is mainframe COBOL, which clearly will not support what we
want to do.
What would I lose by implementing in Perl (other than my mind)?

thanks in advance,

Warren Vail
[EMAIL PROTECTED]
 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread Chris Shiflett
--- Warren Vail [EMAIL PROTECTED] wrote:
 I am looking for a comparison of features supported by PHP vs those
 supported by Perl.

You'll find it difficult to identify a feature in one language that's not
in the other. And, where features differ, the same solutions can probably
be achieved with either anyway

 My gut tells me PHP is more robust

This will be unpopular to say, but my gut tells me the exact opposite. I
prefer PHP, and I would not hesitate to recommend it for most Web
applications. However, Perl has been around a lot longer; it's simply more
mature and hardened than PHP.

The difference may be negligible (I certainly feel comfortable relying on
PHP), but if you're going to split hairs, I'd have to tip my hat to Perl
in the robust category.

 current management does not want to fight for PHP as a new
 sanctioned language (most managers there have never heard of PHP
 and the resident Java zealots have almost established a monopoly).

Java's a different story. :-)

Having to fight in order to adopt a new technology is always a pain, even
when it is an obvious choice. In this case, the choice isn't so obvious
(Perl will satisfy your needs, I'm sure), so your battle will be
difficult.

 The kind of thing I am looking for is SESSION support, I know it's
 supported by PHP, but not sure about Perl. I don't want to have to grow
 my own session manager.

The session mechanism in PHP is very simplistic (on purpose), so it's not
hard to reproduce. In fact, I hope you do more than session_start() and
go in PHP, else you are probably vulnerable to a number of session-based
attacks.

Perl has CPAN for those who want to use an existing session mechanism.

 What would I lose by implementing in Perl (other than my mind)?

Probably nothing, but that last statement is important. A business must
rely on its available resources, and if the developers prefer a particular
language, and all else is even for the most part, it's probably best to
let the developers use what they prefer.

As far as Apache integration goes, I don't think we can match mod_perl,
unless more people get interested in apache_hooks.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread Tristan . Pretty
 In fact, I hope you do more than session_start() and
go in PHP, else you are probably vulnerable to a number of session-based
attacks.

Man, that's all I do alot of the time?
What dangers are there, care to share any facts figures about that...?
I'll go away now and read up again on sessions...!

Cheers for the heads up,
Tris...

*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***



[PHP] Import data from textfile

2004-01-06 Thread Pushpinder Singh
Hello All,

 I am trying to import data into MySQL DB using a CSV file  (using 
phpMyAdmin as the DB Admin tool). I keep getting the following error.

SQL-query :

LOAD DATA LOCAL INFILE '/tmp/phpYRmG0A' INTO TABLE `contacts` FIELDS 
TERMINATED BY ';' LINES TERMINATED BY '\n'(
`company` , `first_name` , `last_name` , `pri_practice` , `phone_1` , 
`city` , `state`
)

MySQL said:

Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)

Here is the CSV file:


Any insights will be appreciated I had this thing working before 
but now I dont know why it seems to be acting up. Thanks in advance.

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

[PHP] Re: eregi filter stopping valid email address, part two

2004-01-06 Thread Manuel Lemos
Hello,

On 01/06/2004 01:52 PM, Dave G wrote:
A while ago on this list I posted a few questions about an eregi
filter for email addresses entered into a form. With the help of people
on this list, I settled on the following code which has worked fine in
the months since I started using it. The code is this:
eregi('[EMAIL PROTECTED]', $email)

But recently, a person was unable to get their email to pass
this eregi test. The email is valid, as they are able to send email to
me. It has the following format:
[EMAIL PROTECTED]

Shouldn't this email pass? I've allowed for hyphens after the @
mark. Is it that there are two many periods?
No, your expression is really excluding many valid addresses. The RFC 
specify a much larger number of valid characters. You are also only 
allowing one possible dot in the domain name.

I think it is better to allow some possibly invalid sequences and then 
perform a DNS/SMTP based validation. In that case you may want to try 
this e-mail validation class that performs first a regular expression 
based validation with a more complete expression and then performs 
DNS/SMTP based validation.

http://www.phpclasses.org/emailvalidation

--

Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Import data from textfile

2004-01-06 Thread Michal Oskera
Hi,
ensure you have FILE privilege on the db-server host.

Mike

Pushpinder Singh [EMAIL PROTECTED] píse v diskusním príspevku
news:[EMAIL PROTECTED]
 Hello All,

   I am trying to import data into MySQL DB using a CSV file  (using
 phpMyAdmin as the DB Admin tool). I keep getting the following error.

 SQL-query :

 LOAD DATA LOCAL INFILE '/tmp/phpYRmG0A' INTO TABLE `contacts` FIELDS
 TERMINATED BY ';' LINES TERMINATED BY '\n'(
 `company` , `first_name` , `last_name` , `pri_practice` , `phone_1` ,
 `city` , `state`
 )

 MySQL said:

 Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)


 Here is the CSV file:










 Any insights will be appreciated I had this thing working before
 but now I dont know why it seems to be acting up. Thanks in advance.

 Pushpinder

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



RE: [PHP] Comparison PHP to Perl

2004-01-06 Thread Brian . Goralczyk
Maybe I am going to show my own ignorance here, but I think if your looking
for Server side web programming that PHP is much easier to use.  Even some
of the developers here that use perl a lot more than me, will say that web
programming with perl is challenging in comparison.  

My logic is JavaScript + client-side, PHP = server-side, perl =
server(scripts and automatic jobs and such).  Some might disagree.  I know
PHP does command line scripting, but I have never used it for that.  I know
that perl does server side pages, but I just don't care for the level of
effort.

I also prefer these languages because they are OS non-specific.  I have
avoided java.  I am not sure what all the hoopla is about.  I am sure I
could get flamed by java programmers for that statement, but I don't see why
I would want to use it.  

Feel free to fill me in.

Brian Goralczyk
Verizon Wireless

-Original Message-
From: Chris Shiflett [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 06, 2004 11:28 AM
To: Warren Vail; [EMAIL PROTECTED]
Subject: Re: [PHP] Comparison PHP to Perl


--- Warren Vail [EMAIL PROTECTED] wrote:
 I am looking for a comparison of features supported by PHP vs those
 supported by Perl.

You'll find it difficult to identify a feature in one language that's not
in the other. And, where features differ, the same solutions can probably
be achieved with either anyway

 My gut tells me PHP is more robust

This will be unpopular to say, but my gut tells me the exact opposite. I
prefer PHP, and I would not hesitate to recommend it for most Web
applications. However, Perl has been around a lot longer; it's simply more
mature and hardened than PHP.

The difference may be negligible (I certainly feel comfortable relying on
PHP), but if you're going to split hairs, I'd have to tip my hat to Perl
in the robust category.

 current management does not want to fight for PHP as a new
 sanctioned language (most managers there have never heard of PHP
 and the resident Java zealots have almost established a monopoly).

Java's a different story. :-)

Having to fight in order to adopt a new technology is always a pain, even
when it is an obvious choice. In this case, the choice isn't so obvious
(Perl will satisfy your needs, I'm sure), so your battle will be
difficult.

 The kind of thing I am looking for is SESSION support, I know it's
 supported by PHP, but not sure about Perl. I don't want to have to grow
 my own session manager.

The session mechanism in PHP is very simplistic (on purpose), so it's not
hard to reproduce. In fact, I hope you do more than session_start() and
go in PHP, else you are probably vulnerable to a number of session-based
attacks.

Perl has CPAN for those who want to use an existing session mechanism.

 What would I lose by implementing in Perl (other than my mind)?

Probably nothing, but that last statement is important. A business must
rely on its available resources, and if the developers prefer a particular
language, and all else is even for the most part, it's probably best to
let the developers use what they prefer.

As far as Apache integration goes, I don't think we can match mod_perl,
unless more people get interested in apache_hooks.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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

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



[PHP] session issues for unauthorized access?

2004-01-06 Thread Scott Fletcher
Is there a really good way to use PHP Session to tell whenether the user is
authorized user or not?  I see one problem here, let's say the user tried to
access certain webpages that are unauthorized then I get to kick the user
out.  But when the user logged in, we assigned a session token to it, then
the user become an authorized user.  That's where I have a problem here.
Suppose when the user closed the browser window without logging off or use
the existing session id when firing up the browser or on the other browser.
(Sort of like copy and paste the URL address from one browser to another).
There, the user will still be an authorized user without logging in.  This
is something that don't need to happen.

So, any best idea, suggestion or thought on a workaround to it?

Thanks,
 FletchSOD

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



[PHP] How can a module find a resource in its environment.

2004-01-06 Thread Jost Boekemeier
Hi,

if I understand this correctly, a module looses its context if it is
required or included.

For example I have a module foo/a.php which is required by b.php via
require (foo/a.php).  Unfortunately within the module a.php the cwd()
is not foo but the context of b.php. The easiest way to fix this would
be to define a new function my_require() which does a
chdir(basename(path)) before the module is included (or one could pass
an environment variable if chdir() is deprecated).  

What is the recommended way for an included or required module to look
for a resource?


BTW: Why is the syntax so that I have to give the full filename of the
module, not only the module name?  For example a require(foo/a) should
also work, but currently doesn't.  I guess PHP currently does not
support pre-compiled modules, does it? :)


Jost

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



[PHP] Identifiying multiple records for databse submission

2004-01-06 Thread Vernon
I'm creating a resume database where I am having resumes submitted to this
database and keyword searches done. All works. Now I need to have a way of
tagging items found in the database much like a shopping cart.

So, I have a unique ID created each time someone does a search on the page
which is based on the time and date. Each time a search is done the old one
is destroyed and a new ID created. Users will search the database and select
resumes they think are suitable and tag them, before doing a new search they
will submit the resumes (actually the IDs of the resumes) to a table. I'm
wondering what is the best way to do something like this. Each resume needs
to be tagged when a popup window of the resume is open.

Any ideas?

Thanks

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



[PHP] counting charactors

2004-01-06 Thread Philip J. Newman
can someone point me to the right place for a thing that would count charactors in a 
string?

---
Philip J. Newman
Master Developer
PhilipNZ.com [NZ] Ltd.
[EMAIL PROTECTED]

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



Re: [PHP] How can a module find a resource in its environment.

2004-01-06 Thread Richard Davey
Hello Jost,

Sunday, January 4, 2004, 3:09:41 PM, you wrote:

JB For example I have a module foo/a.php which is required by b.php via
JB require (foo/a.php).  Unfortunately within the module a.php the cwd()
JB is not foo but the context of b.php. The easiest way to fix this would

Makes sense.

JB be to define a new function my_require() which does a
JB chdir(basename(path)) before the module is included (or one could pass
JB an environment variable if chdir() is deprecated).  

Why not just define a global at the start of each file that holds its
location?

JB BTW: Why is the syntax so that I have to give the full filename of the
JB module, not only the module name?  For example a require(foo/a) should
JB also work, but currently doesn't.  I guess PHP currently does not
JB support pre-compiled modules, does it? :)

Because they're not really modules in the C sense, you're just
including a file - the fact it's a PHP one isn't determined by PHP
itself, nor by the file extension. You could be requiring an HTML
document for all PHP cares :)

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



RE: [PHP] counting charactors

2004-01-06 Thread Jay Blanchard
[snip]
can someone point me to the right place for a thing that would count
charactors in a string?
[/snip]

http://www.php.net/strlen

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



Re: [PHP] counting charactors

2004-01-06 Thread Richard Davey
Hello Philip,

Tuesday, January 6, 2004, 6:25:34 PM, you wrote:

PJN can someone point me to the right place for a thing that
PJN would count charactors in a string?

count_chars() and strlen()

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Comparison PHP to Perl

2004-01-06 Thread Chris Shiflett
--- [EMAIL PROTECTED] wrote:
  In fact, I hope you do more than session_start() and go
  in PHP, else you are probably vulnerable to a number of
  session-based attacks.
 
 Man, that's all I do alot of the time? What dangers are there,
 care to share any facts figures about that...?

PHP provides a convenient session mechanism. However, this is rarely
(never?) a complete solution, and it is up to you to handle the rest. For
example, how do you identify users within your application, and what steps
do you take to complicate impersonation? PHP provides no built-in
security, nor should it, because everyone's needs are different (also,
security often comes at the expense of usability and/or performance, so
different levels of security are desired by different developers).

I recently wrote some of my thoughts on session security in an article for
PHP Magazine that you can get for free from:

http://www.phpmag.net/ssl/phppdf/

Also, this topic has been discussed on this list from time to time, so you
can probably find some good ideas in the archives.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] session issues for unauthorized access?

2004-01-06 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 Is there a really good way to use PHP Session to tell whenether the
 user is authorized user or not?

Yes, there are many good ways, and I'm sure I'm not even aware of many of
them.

 I see one problem here, let's say the user tried to access certain
 webpages that are unauthorized then I get to kick the user out. But
 when the user logged in, we assigned a session token to it, then
 the user become an authorized user. That's where I have a problem
 here.

I don't understand your concern...

 Suppose when the user closed the browser window without logging off
 or use the existing session id when firing up the browser or on the
 other browser. (Sort of like copy and paste the URL address from one
 browser to another). There, the user will still be an authorized user
 without logging in. This is something that don't need to happen.

So, you're worried that a user who doesn't log out will still be logged
in?

At some point, the user is going to have to be responsible for his/her own
actions. After all, I can log into my bank's Web site and then let someone
else use my computer, and there's no way my bank can prevent it.

Session cookies (those with no expiration date set) are expired whenever
the browser is closed, so that eliminates the concern about a cookie being
used to continue a session. Using a session identifier in the URL will
work, but you can easily tell if it's a different browser as you describe,
so you can do whatever you want when that happens (ask them to enter their
password again, require them to completely log in again, etc.).

My advice would be to read more about sessions in the PHP manual. There is
no substitute for a good understanding about what PHP is doing for you.
Also, there is a free article on session security that you can find here:

http://www.phpmag.net/ssl/phppdf/

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



RE: [PHP] session issues for unauthorized access?

2004-01-06 Thread Vail, Warren
Scott,

I suspect you will gets lot's of input on this one.  There is a fairly
glaring hack that allows users to override your session variables (if you
rely on the feature of PHP that automatically adds session variables, as
well as get and post variables, to the global pool [register_globals, I
think]).  They do this by adding the variable and it's value to the end of
the url.

The way around this is to code all references to session data to get it
directly from the $_SESSION array, and correspondingly get input variables
directly from the $_GET or $_POST arrays.  You also may find it necessary to
assign your values to the $_SESSION array directly as well;

$foo = $_SESSION[foo];// retrieves a value from a session
$_SESSION[foo] = $foo;// places a value in a session

this means I only use the session_start() function at the beginning of each
script and the session_unregister(foo) function to remove variables from
the session.

if the only way a variable like $_SESSION[userid] can get into the session
array is thru your code after authentication, you should be fairly safe,
course it doesn't prevent someone from taking over a session on the browser
machine.  A short session timeout will minimize session stealing, but
aggravate your users.

hope this helps,

Warren Vail

-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 06, 2004 10:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP] session issues for unauthorized access?


Is there a really good way to use PHP Session to tell whenether the user is
authorized user or not?  I see one problem here, let's say the user tried to
access certain webpages that are unauthorized then I get to kick the user
out.  But when the user logged in, we assigned a session token to it, then
the user become an authorized user.  That's where I have a problem here.
Suppose when the user closed the browser window without logging off or use
the existing session id when firing up the browser or on the other browser.
(Sort of like copy and paste the URL address from one browser to another).
There, the user will still be an authorized user without logging in.  This
is something that don't need to happen.

So, any best idea, suggestion or thought on a workaround to it?

Thanks,
 FletchSOD

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

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



[PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread Ivo Pletikosic
...no matter what follows the NANC...seems like a bug.

if(NA  0)
{
   print(err 1\n);
}

if(NAN  0)
{
   print(err 2\n);
}

if(NANC  0)
{
   print(err 3\n);
}

if(NANCY  0)
{
   print(err 4\n);
}

// output
err 3
err 4

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



Re: [PHP] session issues for unauthorized access?

2004-01-06 Thread Scott Fletcher
At some point, the user is going to have to be responsible for his/her own
actions. After all, I can log into my bank's Web site and then let someone
else use my computer, and there's no way my bank can prevent it.
Sure the bank can prevent it or otherwise my bank would never use the
website in the first place.  My bank doesn't use PHP, it use JAVA and
surprisely, it work very well.

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Scott Fletcher [EMAIL PROTECTED] wrote:
  Is there a really good way to use PHP Session to tell whenether the
  user is authorized user or not?

 Yes, there are many good ways, and I'm sure I'm not even aware of many of
 them.

  I see one problem here, let's say the user tried to access certain
  webpages that are unauthorized then I get to kick the user out. But
  when the user logged in, we assigned a session token to it, then
  the user become an authorized user. That's where I have a problem
  here.

 I don't understand your concern...

  Suppose when the user closed the browser window without logging off
  or use the existing session id when firing up the browser or on the
  other browser. (Sort of like copy and paste the URL address from one
  browser to another). There, the user will still be an authorized user
  without logging in. This is something that don't need to happen.

 So, you're worried that a user who doesn't log out will still be logged
 in?

 At some point, the user is going to have to be responsible for his/her own
 actions. After all, I can log into my bank's Web site and then let someone
 else use my computer, and there's no way my bank can prevent it.

 Session cookies (those with no expiration date set) are expired whenever
 the browser is closed, so that eliminates the concern about a cookie being
 used to continue a session. Using a session identifier in the URL will
 work, but you can easily tell if it's a different browser as you describe,
 so you can do whatever you want when that happens (ask them to enter their
 password again, require them to completely log in again, etc.).

 My advice would be to read more about sessions in the PHP manual. There is
 no substitute for a good understanding about what PHP is doing for you.
 Also, there is a free article on session security that you can find here:

 http://www.phpmag.net/ssl/phppdf/

 Hope that helps.

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security Handbook
  Coming mid-2004
 HTTP Developer's Handbook
  http://httphandbook.org/

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



Re: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread David Otton
On Tue, 6 Jan 2004 10:57:52 -0800, you wrote:

...no matter what follows the NANC...seems like a bug.

if(NA  0)
{
   print(err 1\n);
}

if(NAN  0)
{
   print(err 2\n);
}

if(NANC  0)
{
   print(err 3\n);
}

if (NANC  0)
{
echo (one);
} else {
echo (two);
}

outputs two here, as expected. PHP 4.3.2 over Win2000.

Maybe you're seeing a side-effect of a Not A Number magic value being
intelligently-evaluated.

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



Re: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread Richard Davey
Hello Ivo,

Tuesday, January 6, 2004, 6:57:52 PM, you wrote:

IP ...no matter what follows the NANC...seems like a bug.

IP // output
IP err 3
IP err 4

Not for me it doesn't. It outputs nothing (as it should).

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re[2]: [PHP] session issues for unauthorized access?

2004-01-06 Thread Richard Davey
Hello Scott,

Tuesday, January 6, 2004, 7:19:55 PM, you wrote:

SF Sure the bank can prevent it or otherwise my bank would never use the
SF website in the first place.  My bank doesn't use PHP, it use JAVA and
SF surprisely, it work very well.

Really? How would your bank determine the difference between you sat
in-front of your keyboard logging onto their Java site, vs. say your
wife/brother/mother/etc?

Basically, they can't - they trust it's you who knows the access
details, and it has nothing to do with them using Java. Any sensible
PHP coder would do the same.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] Vancouver PHP Conference - January 22-23

2004-01-06 Thread Shane Caraveo
Subject: The PHP Vancouver Conference - January 22-23

The Vancouver PHP Users' Association is proud to present The PHP
Vancouver Conference, a professional and technical conference
focused on the PHP scripting language.
Join the world's leading PHP developers and business professionals as
they share their experience with PHP professionals and students from
around the world.
When:   January 22-23, 2004
Where:  SFU Harbour Centre Campus, Vancouver, BC
Keynote:Rasmus Lerdorf, creator of PHP
Standard attendee rate is only $150 plus applicable taxes, offering an
affordable alternative to US-based events. Student pricing is also
available.
For more information or to register, see:
http://vancouver.php.net/?s=conference
The conference will feature a series of talks on topics ranging from the
upcoming PHP5 to the practical implications of implementing PHP in the
enterprise.
'Birds of a Feather' (BOF) and 'Work in Progress' (WIP) sessions will be
held on the first night. These are informal discussions on technical
topics related to PHP, open to all attendees.
As a conference sponsor, ActiveState is pleased to offer attendees a
free copy of Komodo Personal Edition, the award-winning, professional
IDE for PHP. A coupon for your copy will be provided at the conference.
Sponsorship packages are still available, including exhibition space for
those who wish to promote their products and services. For more
information on sponsorship opportunities, see:
http://vancouver.php.net/?s=sponsorship
Space is limited so book early!
http://vancouver.php.net/?s=conference
I look forward to seeing you there.

Shane Caraveo
Senior Developer, PHP
ActiveState
604.484.6435
http://www.ActiveState.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Import data from textfile

2004-01-06 Thread Pushpinder Singh
Hello again,

   I am still stuck with this bug. Can some one advise me, how to find  
out if I have the FILE privilege on my DB or not.

Thanks again
Pushpinder
On Tuesday, January 6, 2004, at 12:08 PM, Michal Oskera wrote:

Hi,
ensure you have FILE privilege on the db-server host.
Mike

Pushpinder Singh [EMAIL PROTECTED] píse v diskusním príspevku
news:[EMAIL PROTECTED]
Hello All,

  I am trying to import data into MySQL DB using a CSV file   
(using
phpMyAdmin as the DB Admin tool). I keep getting the following error.

SQL-query :

LOAD DATA LOCAL INFILE '/tmp/phpYRmG0A' INTO TABLE `contacts` FIELDS
TERMINATED BY ';' LINES TERMINATED BY '\n'(
`company` , `first_name` , `last_name` , `pri_practice` , `phone_1` ,
`city` , `state`
)
MySQL said:

Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)

Here is the CSV file:



--- 
-





Any insights will be appreciated I had this thing working before
but now I dont know why it seems to be acting up. Thanks in advance.
Pushpinder
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] session issues for unauthorized access?

2004-01-06 Thread Vail, Warren
Hate to disillusion you Scott, but Java cannot plug this hole.  Let's
conduct a test, with your account, not mine, eh? ;-)

Warren Vail

-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 06, 2004 11:20 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] session issues for unauthorized access?


At some point, the user is going to have to be responsible for his/her own
actions. After all, I can log into my bank's Web site and then let someone
else use my computer, and there's no way my bank can prevent it.
Sure the bank can prevent it or otherwise my bank would never use the
website in the first place.  My bank doesn't use PHP, it use JAVA and
surprisely, it work very well.

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Scott Fletcher [EMAIL PROTECTED] wrote:
  Is there a really good way to use PHP Session to tell whenether the
  user is authorized user or not?

 Yes, there are many good ways, and I'm sure I'm not even aware of many of
 them.

  I see one problem here, let's say the user tried to access certain
  webpages that are unauthorized then I get to kick the user out. But
  when the user logged in, we assigned a session token to it, then
  the user become an authorized user. That's where I have a problem
  here.

 I don't understand your concern...

  Suppose when the user closed the browser window without logging off
  or use the existing session id when firing up the browser or on the
  other browser. (Sort of like copy and paste the URL address from one
  browser to another). There, the user will still be an authorized user
  without logging in. This is something that don't need to happen.

 So, you're worried that a user who doesn't log out will still be logged
 in?

 At some point, the user is going to have to be responsible for his/her own
 actions. After all, I can log into my bank's Web site and then let someone
 else use my computer, and there's no way my bank can prevent it.

 Session cookies (those with no expiration date set) are expired whenever
 the browser is closed, so that eliminates the concern about a cookie being
 used to continue a session. Using a session identifier in the URL will
 work, but you can easily tell if it's a different browser as you describe,
 so you can do whatever you want when that happens (ask them to enter their
 password again, require them to completely log in again, etc.).

 My advice would be to read more about sessions in the PHP manual. There is
 no substitute for a good understanding about what PHP is doing for you.
 Also, there is a free article on session security that you can find here:

 http://www.phpmag.net/ssl/phppdf/

 Hope that helps.

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security Handbook
  Coming mid-2004
 HTTP Developer's Handbook
  http://httphandbook.org/

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

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



RE: [PHP] Re: Import data from textfile

2004-01-06 Thread Jay Blanchard
[snip]
I am still stuck with this bug. Can some one advise me, how to find

out if I have the FILE privilege on my DB or not.
[/snip]

USE mysql;
SELECT * FROM user WHERE User = 'master';

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



[PHP] Microsoft Word

2004-01-06 Thread Satch
Is there a way to convert a web page into a Microsoft Word document?  ...maybe with a 
PHP header of some kind?

What I want to do is populate a web page with data from MySQL database, then open it 
in Microsoft Word.  Alternatively, if you know how, I could populate the Word document 
directly from MySQL.

Thanks!



Satch
[EMAIL PROTECTED]



Re: [PHP] Re: Import data from textfile

2004-01-06 Thread Pushpinder Singh
Dang ! I get this error when I try to check for priv settings for my DB

SQL-query :
USE mysql
MySQL said:
Access denied for user: '[EMAIL PROTECTED]' to database 'mysql'


Please advise. Thanks
Pushpinder


On Tuesday, January 6, 2004, at 02:29 PM, Jay Blanchard wrote:

[snip]
I am still stuck with this bug. Can some one advise me, how to find
out if I have the FILE privilege on my DB or not.
[/snip]
USE mysql;
SELECT * FROM user WHERE User = 'master';
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread Thorsten Schmidt
Ivo Pletikosic wrote:

...no matter what follows the NANC...seems like a bug.

if(NA  0)
{
  print(err 1\n);
}
if(NAN  0)
{
  print(err 2\n);
}
if(NANC  0)
{
  print(err 3\n);
}
if(NANCY  0)
{
  print(err 4\n);
}
// output
err 3
err 4
 

Same behaviour here,

PHP Version 4.3.4 under Linux debian 2.2.17

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


[PHP] PHP/MySQL with Microsoft Word

2004-01-06 Thread Satch
Is there any way to have a web page (PHP) that draws data from a database (MySQL) then 
populates a Microsoft Word document?  I have some Microsoft Word templates that are 
manually populated and cry out for database integration, but Microsoft Access is not 
robust enough.

For an even harder question:  is there a way to do the reverse?   i.e. take the 
populated fields from the Word document and insert the values in the database?

Thanks!



Satch
[EMAIL PROTECTED]



RE: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread Ivo Pletikosic
Hi,

Never noticed it before...only after the linux box got updated to
v4.3.4...running the script against my v4.2.3 also outputs err 3 
err4...version 4.0.6 outputs nothing as it should.

Odd...not sure where to start digging to figure this...in the meantime
I'll work it around like this:

$data = 'NANC';
if(is_numeric($data)  $data  0)
{
   die('Not OK');
}
print('OK');

Where do I file this for developers with some time on their hands to
look at?

Thanks,

Ivo

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



RE: [PHP] Re: Import data from textfile

2004-01-06 Thread Jay Blanchard
[snip]Dang ! I get this error when I try to check for priv settings for
my DB 



SQL-query : 
USE mysql 
MySQL said: 
Access denied for user: '[EMAIL PROTECTED]' to database
'mysql' 
 [/snip]
 
Well, you (master) do not have access. Please see your database
adminstrator for further information.



Re: [PHP] session issues for unauthorized access?

2004-01-06 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
  At some point, the user is going to have to be responsible for his/her
  own actions. After all, I can log into my bank's Web site and then let
  someone else use my computer, and there's no way my bank can prevent
  it.

 Sure the bank can prevent it or otherwise my bank would never use the
 website in the first place. My bank doesn't use PHP, it use JAVA and
 surprisely, it work very well.

I like Warren's idea. Why don't you drop by, log into your bank's Java Web
site, and then let me use it. Since your bank can prevent this, you have
nothing to worry about, right? :-)

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



[PHP] Site slowdown, elminating possibilities.

2004-01-06 Thread Mike Morton
Hey everybody.  I am trying to eliminate possibilities for a site that is
slowing down, and was hoping that you all could pick apart some code for me
to see if there is some optimizations that you may suggest that may make
some significant difference.

The code in question here is called EVERY page to keep track of a users
activity status.  It is code I have used before elsewhere, without problems,
but as I said, I am trying to eliminate possible problems.

Without Further Ado:

//this is the sessions file that records actions and movement of the
customer
[EMAIL PROTECTED](localhost,removed,removed);
@mysql_select_db(tienda);

session_start();

$SID_VAR=explode(=,SID);
if(isset($SID_VAR[1])) { $PHPSESSID=$SID_VAR[1]; }

if($PHPSESSID) {
[EMAIL PROTECTED](select * from orders where
session_id='$PHPSESSID',$c);
[EMAIL PROTECTED]($res);
//if it exists - update the last_active field.  if not - create it.
if(strlen($row[session_id])  0) {
[EMAIL PROTECTED](update orders set last_active=now() where
session_id='$PHPSESSID',$c);
} else {
[EMAIL PROTECTED](insert into orders set
session_id='$PHPSESSID',affiliate_id='$aid',session_start=now(),status='1',
$c);
}

if(strlen($aid)  0) {
[EMAIL PROTECTED](update orders set affiliate_id='$aid' where
session_id='$PHPSESSID',$c);
}
}

//load the sessions now.
[EMAIL PROTECTED](select * from orders where session_id='$PHPSESSID',$c);
[EMAIL PROTECTED]($res);

//we are going to do affiliate calculations here - if there is an aid then
we are going 
//to consider this a clickthrough.
if($aid) {
//check to see if there is an affiliate by that id first.
$res=mysql_query(select affiliate_id from affiliates where
affiliate_id='$aid',$c) or die(mysql_error());
$row=mysql_fetch_array($res);
if(strlen($row[0])  0) {
$current_date=date(Y-m-d);
//we have an affiliate id - decide if this is an insert or update.
$res=mysql_query(select affiliate_id from affiliate_stats where
affiliate_id='$aid' and stat_date='$current_date',$c) or
die(mysql_error());
$row=mysql_fetch_array($res);
if(strlen($row[0])  0) {
//we are updating
$res=mysql_query(update affiliate_stats set hits=(hits+1) where
affiliate_id='$aid' and stat_date='$current_date',$c) or
die(mysql_error());
} else {
//we are inserting
$res=mysql_query(insert into affiliate_stats set
hits='1',stat_date='$current_date',affiliate_id='$aid',$c) or
die(mysql_error());
}
}

}

As I mentioned - nothing strange, odd, or anything that should cause a large
slowdown in the database.

Running PHP 4.3.2, Mysql 3.23.whatever  The 'orders' database you see here
is really light, 16K rows only, and the sessions_id field is indexed.

I am seeing a number (50-60) sleeping processes in the mysql server, not
sure how they got there, why, or even if they would affect the speed, but
that has been sent to the mysql list anyhow :)

If anyone has any suggestions, criticisms or witty remarks, they are all
accepted :)

TIA 


--
Cheers

Mike Morton


*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*


Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple.
- Byte Magazine

Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey 

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



[PHP] Cross Server, Cross Database connection W/ JOINs

2004-01-06 Thread Jay Blanchard
Does anyone know how, if possible, to connect to two databases on two
different network servers so that join queries can be performed (without
using temporary tables)? 

I am using MySQL so mysql_pconnect() or mysql_connect() will insert a
default server ('localhost:3306', per the docs) if I do not specify one.
Specifying two servers (with the same granted user/pw combo) throws a
syntax error. I have tested and searched, but turned up nothing so far.
This is an experiment, but I can see where the value would be far
ranging for those operating database server farms within their network
(data modularization).

If you have attempted this sort of (or would like to) thing I'd like to
hear your thought, caveats, etc.

TIA!

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



[PHP] Re: PHP/MySQL with Microsoft Word

2004-01-06 Thread Gary C. New
Use MySQLODBC...  I use it to manage my databases through MS Access.

I haven't integrated it yet with Word, but it is my intention in the 
near future.

Hope this helps.

Respectfully,

Gary

Satch wrote:
Is there any way to have a web page (PHP) that draws data from a database (MySQL) then populates a Microsoft Word document?  I have some Microsoft Word templates that are manually populated and cry out for database integration, but Microsoft Access is not robust enough.

For an even harder question:  is there a way to do the reverse?   i.e. take the populated fields from the Word document and insert the values in the database?

Thanks!



Satch
[EMAIL PROTECTED]

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


RE: [PHP] Re: Session expiry issues in IE, still.

2004-01-06 Thread Larry Brown
Interesting point.  After all, to remove a cookie you simply give it an
expire time in the past.  However, it should only explain the lack of cookie
receipt.  Since the user is able to surf for a period of time on the site
before getting the boot, I wouldn't think it would apply.

In the last post it sounded like it is not at 5 min but rather expiring
very speradically.  I bet there is a particular page that is killing them.
Perhaps one of the re-writes or something.  I would take IE and start
traversing the site to see if you can't localize it to one area when it
happens.(or more in particular where you just came from when it dropped).

Larry

PS if you have a dev site to work on, and the session checks are in a
header, try changing the header to display the session ID and watch it for a
change while you surf it.

-Original Message-
From: Matthew Weier O'Phinney [mailto:[EMAIL PROTECTED]
Sent: Monday, January 05, 2004 9:08 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Session expiry issues in IE, still.


* Tarrant Costelloe [EMAIL PROTECTED]:
 I wrote to the list a couple of days ago about issues Planet-Tolkien.com
 members were experiencing with Internet Explorer, where their PHP based
 $_SESSION seemed to be expiring very speradically, where as Mozilla and
 Opera browsers this issue was not occuring and they would stay logged-in.
 It would appear this is a bit of a lost subject and little is known as to
 why this might be happening on the list.

Something I read in the past week while investigating session issues of
my own is that you can run into problems using cookie-based sessions
with IE if your server's clock is behind the client machine's clock --
IE is particularly sensitive to this particular situation, and expires
the cookies -- which leaves the person using IE without a session.

--
Matthew Weier O'Phinney
Webmaster and IT Specialist
National Gardening Association
802-863-5251 x156
mailto:[EMAIL PROTECTED]
http://www.garden.org
http://www.kidsgardening.com

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

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



[PHP] mysql_affected_rows() function

2004-01-06 Thread Tyler Longren
Hi,

I don't think mysql_affected_rows() is working like it should for me. 
In the manual for mysql_affected_rows() it has this (Example 1):

/* this should return the correct numbers of deleted records */
   mysql_query(DELETE FROM mytable WHERE id  10);
   printf(Records deleted: %d\n, mysql_affected_rows());

However, when I do this:
$delete_assignment = mysql_query(DELETE FROM consultingprojectassign
WHERE workerid='$assigned[$i]');
printf(Records deleted: %d\n, mysql_affected_rows());

It always says Records deleted: 0.  Even though the record was,
indeed, deleted.  I have an if statement also that says if
mysql_affected_rows()  1, then print an error message.  Well, since
it always returns 0, no matter what, the error is always shown, even
when the record is deleted.

As I understand it, if no WHERE clause is in the query, then it will
automatically return a 0.  As you can see, my query above does have a
WHERE clause.  Can anyone help me out?

Thanks!!!

Best Regards,
--
Tyler Longren
J.D. Web Services, L.C.

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



Re: [PHP] counting charactors

2004-01-06 Thread Tyler Longren
Hi Philip,

strlen() will work.
http://www.php.net/manual/en/function.strlen.php

Best Regards,
--
Tyler Longren
J.D. Web Services, L.C.

On Wed, 2004-01-07 at 01:25, Philip J. Newman wrote:
 can someone point me to the right place for a thing that would count charactors in a 
 string?
 
 ---
 Philip J. Newman
 Master Developer
 PhilipNZ.com [NZ] Ltd.
 [EMAIL PROTECTED]

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



RE: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread Kelly Hallman
On Tue, 6 Jan 2004, Ivo Pletikosic wrote:
 $data = 'NANC';
 if(is_numeric($data)  $data  0) { die('Not OK'); }

Interesting problem, one of the first legit oddities I've seen since
joining the list.  Anyway, in addition to your workaround, casting the
variable as an int also appears to result in the desired behavior:

(int)NANC  0 == false

-- 
Kelly Hallman
// Ultrafancy

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



[PHP] PHP SNMP

2004-01-06 Thread Luke Bailey
I'm trying to access some SNMP agents.  I have to have use 
SNMP v2, otherwise the snmp requests time out.  PHP seems 
to use SNMP v1 by default.  How can I change this?

EX:
I need it to replicate the following command
snmpget -v2c ...
Luke Bailey

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


[PHP] fdf merge problem using version 6

2004-01-06 Thread Ford, Jon
Has anyone been successful in using the new FDF Toolkit version 6?  I have
been able to compile it into Apache and then compile php with fdftk but when
I try to actually merge fdf data into a PDF I get errors in Acrobat.  If
anyone can shed some light it would be greatly appreciated.

Thank you,

Jon Ford

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



Re: [PHP] generating .doc on the fly

2004-01-06 Thread Naveed Ahmad
How can I generate .rtf files ???

Jon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Nah... You can't use COM in Linux, but you can generate an RTF pretty
 easily, which will open right up in Word with no problems whatsoever.

 -- jon

 ---
 jon roig
 web developer
 email: [EMAIL PROTECTED]
 phone: 888.230.7557



 -Original Message-
 From: Naveed Ahmad [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, January 06, 2004 12:53 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] generating .doc on the fly


 I want to save a document in .doc format on the fly but my server is
 running on a linux machine. Can I still make use of COM object? Or there
 is some other module which I can easily load on the fly??? somebody told
 me the link below butI cannot find the module from there... :S
 http://www.45.free.net/~vitus/ice/catdoc/

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


 ---
 Incoming mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003


 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/2003


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



RE: [PHP] Re: PHP/MySQL with Microsoft Word

2004-01-06 Thread Vail, Warren
for accessing the word document, assuming your server is a windows platform
consider the following;

http://www.php.net/manual/en/ref.com.php

good luck,

Warren Vail

-Original Message-
From: news [mailto:[EMAIL PROTECTED] Behalf Of Gary C. New
Sent: Tuesday, January 06, 2004 12:12 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: PHP/MySQL with Microsoft Word


Use MySQLODBC...  I use it to manage my databases through MS Access.

I haven't integrated it yet with Word, but it is my intention in the 
near future.

Hope this helps.

Respectfully,


Gary


Satch wrote:
 Is there any way to have a web page (PHP) that draws data from a database
(MySQL) then populates a Microsoft Word document?  I have some Microsoft
Word templates that are manually populated and cry out for database
integration, but Microsoft Access is not robust enough.
 
 For an even harder question:  is there a way to do the reverse?   i.e.
take the populated fields from the Word document and insert the values in
the database?
 
 Thanks!
 



 
 Satch
 [EMAIL PROTECTED]
 
 

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

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



Re: [PHP] mysql_affected_rows() function

2004-01-06 Thread CPT John W. Holmes
From: Tyler Longren [EMAIL PROTECTED]

 I don't think mysql_affected_rows() is working like it should for me.
 In the manual for mysql_affected_rows() it has this (Example 1):

 /* this should return the correct numbers of deleted records */
mysql_query(DELETE FROM mytable WHERE id  10);
printf(Records deleted: %d\n, mysql_affected_rows());

 However, when I do this:
 $delete_assignment = mysql_query(DELETE FROM consultingprojectassign
 WHERE workerid='$assigned[$i]');
 printf(Records deleted: %d\n, mysql_affected_rows());

 It always says Records deleted: 0.  Even though the record was,
 indeed, deleted.  I have an if statement also that says if
 mysql_affected_rows()  1, then print an error message.  Well, since
 it always returns 0, no matter what, the error is always shown, even
 when the record is deleted.

I can't see a reason why that wouldn't work. Is that your exact code, i.e.
you're not doing anything else between the mysql_query() call and the
mysql_affected_rows() call? What versions of PHP/MySQL are you using?

---John Holmes...

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



[PHP] PHP and SNMP

2004-01-06 Thread Luke Bailey
*This message was transferred with a trial version of CommuniGate(tm) Pro*
I'm trying to access some SNMP agents.  I have to have use
SNMP v2, otherwise the snmp requests time out.  PHP seems
to use SNMP v1 by default.  How can I change this?
EX:
I need it to replicate the following command
snmpget -v2c ...
Luke Bailey

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


Re: [PHP] mysql_affected_rows() function

2004-01-06 Thread Tyler Longren
Hi Cpt,

That's not the exact code.  The exact code is below.  Multiple workers
are being selected from a MULTIPLE select form field.  I just use a
while loop do go through the selected ones to delete them individually.

PHP Version: 4.3.4
MySQL Version: 4.0.17

$i=0;
while ($i = $selected) {
$delete_assignment = mysql_query(DELETE FROM webprojectassign WHERE
workerid='$assigned[$i]');
$i++;
}
if (mysql_affected_rows($delete_assignment)  1) {
$tpl-newBlock('message');
$tpl-assign(message,bERROR:/b There was an error deleting those
workers from the project.);
}
else {
$tpl-newBlock('message');
$tpl-assign(message,The workers have been deleted from the
project.);
}

If you (or anyone else) know of another way I should be doing this,
please let me know.  I'm open to any suggestions.

Best Regards,
--
Tyler Longren
J.D. Web Services, L.C.


On Tue, 2004-01-06 at 15:14, CPT John W. Holmes wrote:
 From: Tyler Longren [EMAIL PROTECTED]
 
  I don't think mysql_affected_rows() is working like it should for me.
  In the manual for mysql_affected_rows() it has this (Example 1):
 
  /* this should return the correct numbers of deleted records */
 mysql_query(DELETE FROM mytable WHERE id  10);
 printf(Records deleted: %d\n, mysql_affected_rows());
 
  However, when I do this:
  $delete_assignment = mysql_query(DELETE FROM consultingprojectassign
  WHERE workerid='$assigned[$i]');
  printf(Records deleted: %d\n, mysql_affected_rows());
 
  It always says Records deleted: 0.  Even though the record was,
  indeed, deleted.  I have an if statement also that says if
  mysql_affected_rows()  1, then print an error message.  Well, since
  it always returns 0, no matter what, the error is always shown, even
  when the record is deleted.
 
 I can't see a reason why that wouldn't work. Is that your exact code, i.e.
 you're not doing anything else between the mysql_query() call and the
 mysql_affected_rows() call? What versions of PHP/MySQL are you using?
 
 ---John Holmes...
 

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



Re: [PHP] mysql_affected_rows() function

2004-01-06 Thread Michal Oskera
Hello,
I use PHP v. 4.3.3 and MySQL v 4.1.0a and
I have the same experience as Tyler. Also when performing INSERT and UPDATE
commands.
And I also don't know why.

Mike

Cpt John W. Holmes [EMAIL PROTECTED] píse v diskusním príspevku
news:[EMAIL PROTECTED]
 From: Tyler Longren [EMAIL PROTECTED]

  I don't think mysql_affected_rows() is working like it should for me.
  In the manual for mysql_affected_rows() it has this (Example 1):
 
  /* this should return the correct numbers of deleted records */
 mysql_query(DELETE FROM mytable WHERE id  10);
 printf(Records deleted: %d\n, mysql_affected_rows());
 
  However, when I do this:
  $delete_assignment = mysql_query(DELETE FROM consultingprojectassign
  WHERE workerid='$assigned[$i]');
  printf(Records deleted: %d\n, mysql_affected_rows());
 
  It always says Records deleted: 0.  Even though the record was,
  indeed, deleted.  I have an if statement also that says if
  mysql_affected_rows()  1, then print an error message.  Well, since
  it always returns 0, no matter what, the error is always shown, even
  when the record is deleted.

 I can't see a reason why that wouldn't work. Is that your exact code, i.e.
 you're not doing anything else between the mysql_query() call and the
 mysql_affected_rows() call? What versions of PHP/MySQL are you using?

 ---John Holmes...

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



Re: [PHP] mysql_affected_rows() function

2004-01-06 Thread CPT John W. Holmes
From: Tyler Longren [EMAIL PROTECTED]

 That's not the exact code.  The exact code is below.  Multiple workers
 are being selected from a MULTIPLE select form field.  I just use a
 while loop do go through the selected ones to delete them individually.

 PHP Version: 4.3.4
 MySQL Version: 4.0.17

 $i=0;

Don't put quotes around numbers. $i = 0; is all you need.

 while ($i = $selected) {

You also don't need quotes around just a variable. ($i = $selected) is all
you need.

 $delete_assignment = mysql_query(DELETE FROM webprojectassign WHERE
 workerid='$assigned[$i]');
 $i++;
 }
 if (mysql_affected_rows($delete_assignment)  1) {
 $tpl-newBlock('message');
 $tpl-assign(message,bERROR:/b There was an error deleting those
 workers from the project.);
 }
 else {
 $tpl-newBlock('message');
 $tpl-assign(message,The workers have been deleted from the
 project.);
 }

The problem you're having is that your IF check of mysql_affected_rows() is
outside of your WHILE loop. So, you're executing a series of DELETE queries,
yet only checking mysql_affected_rows() for the very last one (which
evidently does not actually delete anything).

You could probably benifit from a DELETE FROM webprojectassign WHERE
worderid IN (1,2,3,45) syntax, too, so you only need to do a single query.
Since it's coming from a MULTIPLE select, a simple

$list = implode(',',$_POST['select_name']);

will create the list. Although you'd be better off looping through each one
making sure it's a number, though, to prevent any SQL injection attacks.

Ask if you need anymore info. :)

---John Holmes...

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



Re: [PHP] if(NANC 0) - always evaluates TRUE...

2004-01-06 Thread CPT John W. Holmes
From: Kelly Hallman [EMAIL PROTECTED]

 On Tue, 6 Jan 2004, Ivo Pletikosic wrote:
  $data = 'NANC';
  if(is_numeric($data)  $data  0) { die('Not OK'); }

 Interesting problem, one of the first legit oddities I've seen since
 joining the list.  Anyway, in addition to your workaround, casting the
 variable as an int also appears to result in the desired behavior:

 (int)NANC  0 == false

This all kind of begs the question of why you'd check if a string was less
than zero, anyhow, doesn't it???

---John Holmes...

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



RE: [PHP] generating .doc on the fly

2004-01-06 Thread Williams, Olwen - SAL
I tried this in another (rather odd) environment and had some success.  I
took a word document and saved it as HTML and then opened it in a text
editor.  
I used a .doc extension and kept:
html xmlns:o=urn:schemas-microsoft-com:office:office
xmlns:w=urn:schemas-microsoft-com:office:word
xmlns=http://www.w3.org/TR/REC-html40;
HTML
HEAD
meta http-equiv=Content-Type content=text/html; charset=windows-1252
meta name=ProgId content=Word.Document
meta name=Generator content=Microsoft Word 9
meta name=Originator content=Microsoft Word 9
TITLE

/TITLE
xml
 w:WordDocument
  w:ViewPrint/w:View
 /w:WordDocument
/xml  

Antyhing apart from that was my HTML. When I browse to it it opens as a word
document.  Presuming you are using apache you could specify that it is to be
processed using PHP.

Olwen Williams
[EMAIL PROTECTED]


-Original Message-
From: Naveed Ahmad [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 06, 2004 8:53 PM
To: [EMAIL PROTECTED]
Subject: [PHP] generating .doc on the fly


I want to save a document in .doc format on the fly but my server is running
on a linux machine. Can I still make use of COM object? Or there is some
other module which I can easily load on the fly???
somebody told me the link below butI cannot find the module from
there... :S
http://www.45.free.net/~vitus/ice/catdoc/

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


CAUTION - This message may contain privileged and confidential 
information intended only for the use of the addressee named above.
If you are not the intended recipient of this message you are hereby 
notified that any use, dissemination, distribution or reproduction 
of this message is prohibited. If you have received this message in 
error please notify Safe Air Ltd immediately. Any views expressed 
in this message are those of the individual sender and may not 
necessarily reflect the views of Safe Air.
_
For more information on the Safe Air Group, visit us online
at http://www.safeair.co.nz/ 
_

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



[PHP] Looping problem?

2004-01-06 Thread Jas
require 'database.php';
$t_02 = subnets;
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error());	 while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) 
= mysql_fetch_array($sql_subs)) {
   $num = mysql_num_rows($sql_subs);
  for($z = 0; $z  $num; $z++) {
	$vlans[] = subnet $subbrnetmask $msk {broption domain-name-servers 
$dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br; }
}
// Write everything out formated...
echo $vlans[$z]br /\n;

Right now it only pulling the last record???
Jas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Looping problem?

2004-01-06 Thread Brad Pauly
On Tue, 2004-01-06 at 15:04, Jas wrote:
 require 'database.php';
 $t_02 = subnets;
 $sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
 die(mysql_error());while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) 
 = mysql_fetch_array($sql_subs)) {
 $num = mysql_num_rows($sql_subs);
for($z = 0; $z  $num; $z++) {
   $vlans[] = subnet $subbrnetmask $msk {broption domain-name-servers 
 $dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br; }
 }
 // Write everything out formated...
 echo $vlans[$z]br /\n;
 
 Right now it only pulling the last record???

You are only echo'ing the last record, $vlanz[$z]. You will need to loop
over $vlans again or put the echo line inside the for loop.

- Brad

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



RE: [PHP] Looping problem?

2004-01-06 Thread Martin Towell
This is probably more like what you need.
I can't see why you'd need to loop through your results using two different
methods (while and for)

require 'database.php';
$t_02 = subnets;
$sql_subs = mysql_query(SELECT * FROM $t_02,$db) or die(mysql_error());
$num = mysql_num_rows($sql_subs);
for ($z = 0; $z  $num; $z++)
{
  list($id, $sub, $msk, $dns01, $dns02, $rtrs, $rnge) =
mysql_fetch_array($sql_subs);
  $vlans[] = subnet $subbrnetmask $msk {broption domain-name-servers
$dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br;
}
// Write everything out formated...
for ($z = 0; $z  $num; $z++)
  echo $vlans[$z]br /\n;


Martin


 -Original Message-
 From: Jas [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, 7 January 2004 9:05 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Looping problem?
 
 
 require 'database.php';
 $t_02 = subnets;
 $sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
 die(mysql_error());
 while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) 
 = mysql_fetch_array($sql_subs)) {
 $num = mysql_num_rows($sql_subs);
for($z = 0; $z  $num; $z++) {
   $vlans[] = subnet $subbrnetmask $msk {broption 
 domain-name-servers 
 $dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br; }
 }
 // Write everything out formated...
 echo $vlans[$z]br /\n;
 
 Right now it only pulling the last record???
 Jas
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP] PHP function for length of the array???

2004-01-06 Thread Mike Migurski
   Anyone know what is the php function for finding the length of the array?
I haven't found the answer at http://us3.php.net/manual/en/ref.array.php .

You are aware that all the available array functions are listed about
halfway down that page, right?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Looping problem?

2004-01-06 Thread joel boonstra
On Wed, Jan 07, 2004 at 09:17:35AM +1100, Martin Towell wrote:
 This is probably more like what you need.
 I can't see why you'd need to loop through your results using two different
 methods (while and for)
 
 require 'database.php';
 $t_02 = subnets;
 $sql_subs = mysql_query(SELECT * FROM $t_02,$db) or die(mysql_error());
 $num = mysql_num_rows($sql_subs);
 for ($z = 0; $z  $num; $z++)
 {
   list($id, $sub, $msk, $dns01, $dns02, $rtrs, $rnge) =
 mysql_fetch_array($sql_subs);
   $vlans[] = subnet $subbrnetmask $msk {broption domain-name-servers
 $dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br;
 }
 // Write everything out formated...
 for ($z = 0; $z  $num; $z++)
   echo $vlans[$z]br /\n;

No need to calculate the number of rows:

?php
require 'database.php';
$t_02 = subnets;
$sql_subs = mysql_query(SELECT * FROM $t_02,$db) 
  or die(mysql_error());
while (list($id, $sub, $msk, $dns01, $dns02, $rtrs, $rnge) =
 mysql_fetch_array($sql_subs)) {
  $tmp = subnet $subbrnetmask $msk {broption domain-name-servers
$dns01, $dns02;broption routers $rtrs;brrange $rnge;br}br;
  print $tmp;
  $vlans[] = $tmp;
}
?

I would recommend not simply doing a select *, but rather specifying
which columns you want.  That way, if your database schema changes
(e.g., you add two more columns), your code won't break.

joel

-- 
[ joel boonstra | gospelcom.net ]

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



Re: [PHP] PHP function for length of the array???

2004-01-06 Thread Chris Shiflett
--- Mike Migurski [EMAIL PROTECTED] wrote:
  Anyone know what is the php function for finding the length of the
  array? I haven't found the answer at
  http://us3.php.net/manual/en/ref.array.php .
 
 You are aware that all the available array functions are listed about
 halfway down that page, right?

To answer the original question, what do you mean by length? That's a bit
ambiguous. So, I'll take a guess.

If you mean the length of each element of the array, and it's a
one-dimensional array, you can use a combination of implode() and
strlen():

?
$foo[] = '1';
$foo[] = '22';
$foo[] = '333';
 
echo strlen(implode($foo));
?

This outputs 6, the length of 122333.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] Looping problem?

2004-01-06 Thread joel boonstra
On Tue, Jan 06, 2004 at 05:33:41PM -0500, joel boonstra wrote:
snip
 I would recommend not simply doing a select *, but rather specifying
 which columns you want.  That way, if your database schema changes
 (e.g., you add two more columns), your code won't break.

And, responding to myself, specifying your columns is also good practice
because MySQL makes no guarantees about the order that columns are
returned when you say SELECT *.  Today, it may well be the order that
you specified when you created your table.  With the next upgrade, it
may be alphabetical order, or by column type, or some other order that
the software chooses.  If you specify column names in your SELECT
statement, you don't need to worry about it.  This is especially
important when you are using list() to assign variables based on their
position in your fetched array.

joel

-- 
[ joel boonstra | gospelcom.net ]

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



[PHP] Re: web-based and command line mcrypting and back again

2004-01-06 Thread Gary C. New
Tom,

I appreciate the suggestion, but even after setting the iv to zero 
within the php code and including the --noiv option within the command 
line; it still does not produce the same base64 encoded string under 
both methods.

I noticed that the command line was keying off of 2 passphrases and the 
php code off of only 1, so I forced the command line to key off of only 
1 passphrase--to no avail.

I am obviously missing something.  Someone out there has had to have 
done this at least once before.

Any other suggestions would be appreciated.

Respectfully,

Gary

Tom Rogers wrote:
Hi,

Tuesday, January 6, 2004, 8:48:17 PM, you wrote:
GCN I am trying to figure out how to encrypt data using the web-based php
GCN mcrypt function and then decrypt it using the command line (cli) mcrypt
GCN binary, and vica-versa.
GCN I cannot seem to get the same encrypted output for the same data,
GCN between the two methods.  I've tried to ensure I am using the same
GCN algorithms and modes for both methods by testing the mcrypt_enc_get_*
GCN functions.  I think the problem may lie in the way both methods are
GCN being seeded.
GCN Web-Based PHP Example:

GCN $key = 'test';
GCN $data[] = 'abcdefghijklmnopqrstuvwxyz';
GCN $m = 0;
GCN foreach ($data as $dt)
GCN {
GCN $td = mcrypt_module_open('tripledes', '', 'ecb', '');
GCN $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
GCN mcrypt_generic_init($td, $key, $iv);
GCN $CRYPT[$m] = mcrypt_generic($td, $dt);
GCN /*
GCN echo mcrypt_enc_get_algorithms_name($td);
GCN echo mcrypt_enc_get_block_size($td);
GCN echo mcrypt_enc_get_iv_size($td);
GCN echo mcrypt_enc_get_key_size($td);
GCN echo mcrypt_enc_get_modes_name($td);
GCN echo mcrypt_enc_get_supported_key_sizes($td);
GCN echo mcrypt_enc_is_block_algorithm_mode($td);
GCN echo mcrypt_enc_is_block_algorithm($td);
GCN echo mcrypt_enc_is_block_mode($td);
GCN echo mcrypt_enc_self_test($td);
GCN */
GCN $DECRYPT[$m] = mdecrypt_generic($td, $dt);
GCN mcrypt_generic_deinit($td);
GCN mcrypt_module_close($td);
GCN echo crypt_ . base64_encode($CRYPT[$m]) . _br /\n;
GCN echo decrypt_ . base64_decode(rtrim($DECRYPT[$m])) . _br /\n;
GCN $m++;
GCN }
GCN Note:  I believe it is the line where the $iv variable is being set that
GCN is causing the issue and/or I cannot reproduce the same seeding using
GCN the command line options.
GCN Command Line Example:

GCN echo abcdefghijklmnopqrstuvwxyz | mcrypt -Fb -m ecb -a tripledes |
GCN encode-base64
GCN echo  | decode-base64 | mcrypt -dFb -m ecb -a tripledes

GCN I would appreciate any comments or suggestions.

GCN Respectfully,

GCN Gary

try setting the iv to all 0's
$iv = 0;
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Bizzare form problem - Please Help!

2004-01-06 Thread Paul
Sorry if this is a repost, I could not see the original.

Any help with this would be immensely appreciated!

Here is what the problem I am having is:

I have a .php page. There are several form fields. When I populate the
fields, submit to another page, and then use the browser's back button, the
data is still there. This is indeed what I want.

HOWEVER, when one field has a javascript event (ie. onClick open a browser
window) when I submit the form, and try to go back, the data is gone :(

If I use the exact same page without a php extension, things are still fine.
Unfortunately I need
this to be a PHP as I will be linking dynamic data to drop down lists.

This seems bizarre to me. Following is a very simple sample. Served as an
.html file it is just fine, served as a .php file the form data is lost on a
back click.

Thanks for any help!


Code:


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
head
titleUntitled Document/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /
script language=JavaScript type=text/JavaScript
!--
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//--
/script
/head

body
form name=form1 id=form1 method=post action=http://www.cnn.com;
  table width=400 border=1
tr
  td width=92One/td
  td width=292
input name=textfield1 type=text id=textfield1 /
  /td
/tr
tr
  tdTwo/td
  tdinput name=textfield2 type=text id=textfield2 //td
/tr
tr
  tdThree/td
  tdinput name=textfield3 type=text id=textfield3
onclick=openBrWindow('http://www.cnn.com','','width=50,height=50') //td
/tr
tr
  tdnbsp;/td
  tdinput type=submit name=Submit value=Submit //td
/tr
  /table
/form
pnbsp;/p
/body
/html

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



Re: [PHP] Bizzare form problem - Please Help!

2004-01-06 Thread Nelson Rodríguez-Peña Alarcón
Hi Paul,

Paul wrote:
I have a .php page. There are several form fields. When I populate
the fields, submit to another page, and then use the browser's back
button, the data is still there. This is indeed what I want.
HOWEVER, when one field has a javascript event (ie. onClick open a
browser window) when I submit the form, and try to go back, the data
is gone :(
Question: are you really filling the form with the values sent by the 
user with, say, PHP, or are you relying on the ability of some browsers 
to 'remember' form data?

You should be dynamically filling the form using PHP, then this wouldn't 
happen, something like:

input type=text value=?php echo $thisItemValue; ? name=bla /

hope it helps.

--

regards,


 Nelson Rodríguez-Peña A.
 Diseño y Desarrollo
 Web  Multimedia

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


  1   2   >