Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 02:46:14PM -0400, Gerard Samuel wrote:
: 
: When I say that I don't know what characters Im expecting.
: Im not talking about normal html entities, like &   <
: Im talking about chinese/japanese/korean/taiwanese alphabet, numbers 
: (even punctuation if applicable).
: Maybe Im thinking too hard, but trying to take far east languages 
: alphanumeric charaters into account,
: seems like overkill.
: Feel free to correct me.

Okay, I will.  :-)

There's two issues: input and output.

HTML character references address the problem of displaying certain
characters on a web browser.  This is an output issue.

When you get CJKV data, you are most likely getting it in some encoding.
Different Asian languages use their own encoding sets.  For example, if
you get Japanese text, it will be encoded in JIS, Shift-JIS, EUC, or
something Unicode.  You *have* to determine the type of data and its
encoding.  This is an input issue.

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



Re: [PHP] storing japanese in mysql (or pgsql)

2003-10-01 Thread - Edwin -
On Wed, 1 Oct 2003 09:10:05 -0700
"Chris W. Parker" <[EMAIL PROTECTED]> wrote:

> - Edwin - 
> on Tuesday, September 30, 2003 7:00 PM said:
> 
> > What exactly do you mean by "extended characters"? And, do you
> > mean all *other* characters are inserted properly? Anyway,... 
> 
> I just mean the characters that you can't type unless you do
> something like alt-250, alt-145, etc.

Hmm... these characters can be entered as ú (for alt-250) and
‘ (for alt-145) and this has nothing to do with your DB being
able to handle Japanese characters...

> > If they're not "ujis" (for euc-jp), add this to your "my.cnf"
> > file:(Under [mysqld] and [client]) 
> > 
> >   default-character-set = ujis
> 
> I added that line to the [mysqld] section but there was no [client]
> section so i added the following.
> 
> [client]
> default-character-set = ujis

That's correct.

> > Btw, check your php.ini as well and make sure that your settings
> > under [mbstring] are correct. 
> 
> Each line in the [mbstring] section was commented out. So I
> uncommented them. I also uncommented the mbstring extension.

Hmm... (sounds like you're on Windows) since I don't do Windows, I'm
not really sure if that will work. Under Linux, for example, the
extension should be compiled in... Anyway, just try it. If it doesn't
work, maybe you need to grab a copy of a "patched" or "compiled for
Japanese" version of php at http://www.php.gr.jp/project/i18n/ . (I
don't think this is necessary though...)

> I'm just about to restart both servers, so we'll see what happens.
> 

Ok.

- E -
__
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/

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



Re: [PHP] Re: your method for validating forms

2003-10-01 Thread Chris Shiflett
--- Robert Cummings <[EMAIL PROTECTED]> wrote:
> Personally I find Javascript validation intrusive and ugly. It
> decreases my experience and IMHO makes the site less usable *grin*.

I was going to say the same thing. :-)

There are definitely benefits to saving the extra request and response
necessary to properly display errors, but I'm not so sure I would count
usability as one of them. In addition, the user's perception of the site's
general quality and professionalism may be a concern, and a JavaScript popup
certainly doesn't improve this.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

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



Re: [PHP] Re: your method for validating forms

2003-10-01 Thread Robert Cummings
On Thu, 2003-10-02 at 01:57, Manuel Lemos wrote:
> 
> I suppose that you missed the point that the class provides you to do 
> both client side and server side validation in cases that it is possible.
> 

[--CROPPED--]

> I don't think that hardware speed will make the Internet connections any 
> faster. A lot of people still use dial-up connections and having to 
> submit a form to let the server tell the user that something is wrong is 
> a needless additional round trip that many times could be avoided and 
> make your site more usable, ie, less annoying for the users.

Personally I find Javascript validation intrusive and ugly. It decreases
my experience and IMHO makes the site less usable *grin*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: your method for validating forms

2003-10-01 Thread Manuel Lemos
Hello,

On 10/02/2003 12:14 AM, Brad Pauly wrote:
$_SESSION['form_errors'] = validateFormData($formdata);

redirect("to_the_previous_page.php");
You may want to study how this classic form validation and generation 
class works. It generates the necessary Javascript to validate on the 
client side and uses the class methods to validate on the server side.

It makes it simple to generate, validate and process a form in the same 
script, thus avoiding needless server access roundtrips that only slow 
down the sites for the users.


While there is overhead in making that round trip, I wanted to note a
few reasons that I prefer server side validation.
I suppose that you missed the point that the class provides you to do 
both client side and server side validation in cases that it is possible.


Also, hardware is very fast for what it costs (I know, don't solve a
problem by throwing money at it). Anyway, just some things to consider.
I don't think that hardware speed will make the Internet connections any 
faster. A lot of people still use dial-up connections and having to 
submit a form to let the server tell the user that something is wrong is 
a needless additional round trip that many times could be avoided and 
make your site more usable, ie, less annoying for the users.

--

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: PHP Session not working

2003-10-01 Thread Nicole
Which method are you using to set and access your session variables?

--
Nicole
aeontrek.com

"Sheni R. Meledath" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi:
>
> We are facing some problems in using sessions in our applications.
Recently
> we have moved our web site to a new Apache server (1.3). We have installed
> PHP on this server. But sessions are not working on this server. The
values
> in the session variables are not carried forward to the consequent pages.
> PHP Module entry in httpd.conf file: LoadModule php4_module
> modules/mod_php4-4.3.2.so
>
> The same scripts & web site are working fine on a similar Apache server
and
> same version of PHP.
>
> Could you please help me to figure out this problem. Are we missing
> anything in the installation or settings in the php.ini file.
>
> PHP.INI
> [Session]
> session.save_handler = files
> session.save_path = /tmp
> session.use_cookies = 1
> session.name = PHPSESSID
> session.auto_start = 0
> session.cookie_lifetime = 0
> session.cookie_path = /
> session.cookie_domain =
> session.serialize_handler = php
> session.gc_probability = 1
> session.gc_maxlifetime = 1440
> session.referer_check =
> session.entropy_length = 0
> session.entropy_file =
> session.cache_limiter = nocache
> session.cache_expire = 180
> session.use_trans_sid = 1
> url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
>
>
> Sheni R Meledath
> [EMAIL PROTECTED]

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



[PHP] Help with treeview

2003-10-01 Thread Stephen
Does anyone know how to implement a treeview style display in PHP?

Thanks,

Stephen

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



[PHP] PHP Session not working

2003-10-01 Thread Sheni R. Meledath
Hi:

We are facing some problems in using sessions in our applications. Recently 
we have moved our web site to a new Apache server (1.3). We have installed 
PHP on this server. But sessions are not working on this server. The values 
in the session variables are not carried forward to the consequent pages.
PHP Module entry in httpd.conf file: LoadModule php4_module 
modules/mod_php4-4.3.2.so

The same scripts & web site are working fine on a similar Apache server and 
same version of PHP.

Could you please help me to figure out this problem. Are we missing 
anything in the installation or settings in the php.ini file.

PHP.INI
[Session]
session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_maxlifetime = 1440
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 1
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Sheni R Meledath
[EMAIL PROTECTED] 

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


Re: [PHP] Testing Variables

2003-10-01 Thread Curt Zirzow
* Thus wrote Curt Zirzow ([EMAIL PROTECTED]):
> * Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
> > --- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > > if ($do || false == $do ) {
> > >   try();
> > > }
> > > /* Do, or do not. There is no try. */
> > 
> > Isn't there always try? :-)
> 
> Only in php5 :)

oops, you were pointing out the flaw in the logic, here I'll
correct it:

while ($do || false == $do ) 
  have_fun();

try();


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] problem with if..else condition

2003-10-01 Thread Curt Zirzow
* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
> 
> 
> Hi all, 
> I'm having some problem with my PHP script here. Do hope to receive some
> help. I have written the script with a if..elseif..else ...condition to check if
> my checkbox have been checked. There is 3 radio button to be clicked: eg button1
> , button 2 and button3.Only one to be checked at one time. Supposely "button1"
> is clicked, it should output "button1" as the selection once the submit button
> has been clicked. I have attached my HTMl and PHP code below. Hope to get some
> help here.
> 
[... big snip ..]
   
> if ($payment==Cash AND $payment != Nets AND $payment != Cheque)

Always put quotes around strings!!!

Also, your AND conditions are pointless, if $payment is equal to
'Cash' then there is no way that it will be either 'Nets' or
'Cheque'.

> {
>  echo ("Payment Mode:   Cash");
> }
>   elseif ($payment==Nets AND $payment != Cash AND $payment != Cheque )
>   {
>echo ("Payment Mode:   Nets");
[...]

This is screaming to use a switch statement:
  switch ($payment) {
case 'Cash':
  break;
case 'Nets':
  break;
...
default: /* else */
  break;
  }

>   Cash: 
>   Cheque:

Again, Be sure to quote strings, and if you access an array inside
a string enclose them with curly brackets:

  "{$$_GET['cheque']}"

AND:
You're accessing a variable variable, if someone entered 2.30 for
cheque then your trying to echo the variable $2.30, which brings
to attention why you use the syntax above:

  echo "\${$_GET['cheque']}";

It is more clear to me and the php parser that you want a dollar sign
(note the escaped $) followed the GET var value of 'cheque'.

>  
>
>$total = $_GET[cheque] + $_GET[cash];

Again, use the quotes! (more yoda references :)

>$total=number_format($total, 2, ".", " ");
> echo "Total payable: $$total";

And again, confusion as to what you want; clarify it!
  echo "Total Payable: \${$total}";

> ?>
EOF

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] With problem about imagestring() function.

2003-10-01 Thread So-Net
I'm using windows XP professional sp1 with IIS5.0
I installed PHP 4.3.3 with GD 2.0 already.

 It is because I'm a Hong Kong people, so we required to draw some strings that is 
chinese in language. However, imagestring() cannot show it properly, so I'm writing to 
ask whether we can draw the chinese sentence to the created image ?

I have tried to use chinese font, but still failed.

Thank you for your help.

Re: [PHP] Show index.php instead of index.html

2003-10-01 Thread Chris Shiflett
Regarding DirectoryIndex, you can try to put the following line in a .htaccess
file within your document root:

DirectoryIndex index.php index.html

Your Web host must allow .htaccess to override certain directives (or all), but
I have found that most do. It's definitely worth trying.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

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



Re: [PHP] Testing Variables

2003-10-01 Thread Gerard Samuel
Curt Zirzow wrote:

Yep. Just make sure you dont start speaking english like that,

people will look at you funny, or think your yoda :)

if ('away' == $put_your_weapon) {
 $harm = false;
}
/* Away put your weapon, I mean you no harm */
or 
if ( 'help' == $you_can )  {
 hmm();
}
/* Help you can, Hmm! */

Or more popular:

if ($do || false == $do ) {
 try();
}
/* Do, or do not. There is no try. */
Definately funny :)

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


Re: [PHP] Show index.php instead of index.html

2003-10-01 Thread Becoming Digital
Contact your hosting provider and ask them to make the change, or go through your 
control panel and look for a setting that will achieve the desired effect.  It's 
probably hiding under your nose, as this is a fairly common requirement for 
data-driven sites.  In the meantime, upload a new index.html file with the following 
in the  section:



This will immediately send users to the index.php file while you resolve the 
configuration issues.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message - 
From: "Ryan A" <[EMAIL PROTECTED]>
To: "Chris Garaffa" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Martin Towell" <[EMAIL PROTECTED]>
Sent: Wednesday, 01 October, 2003 22:23
Subject: Re: [PHP] Show index.php instead of index.html


Hi,
Thanks for replying.

I am on a shared hosting account and dont have access to my httpd.conf file,
is there some way to do the same via .htaccess or something?

Any ideas? i want to open the site today.

Thanks,
-Ryan


We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com


- Original Message - 
From: "Chris Garaffa" <[EMAIL PROTECTED]>
To: "Ryan A" <[EMAIL PROTECTED]>
Sent: Thursday, October 02, 2003 4:18 AM
Subject: Re: [PHP] Show index.php instead of index.html


> On Oct 1, 2003, at 10:14 PM, Ryan A wrote:
>
> > Hi,
> > I just deleted my index.html page because i want to use my index.php
> > page
> > instead but when i visit my site i see the directory listing instead,
> > what
> > should i do to display the index.php page automatically??
>
> If you're using Apache, edit your httpd.conf file so that
> DirectoryIndex is set to index.php (you can leave index.html in there
> if you think you'll bring it back sometime. Apache will look for the
> files in the order specified in httpd.conf).
>
> For example:
> DirectoryIndex index.html index.php
>
>
> -- 
> Chris Garaffa
> [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] Testing Variables

2003-10-01 Thread Curt Zirzow
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
> --- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > if ($do || false == $do ) {
> >   try();
> > }
> > /* Do, or do not. There is no try. */
> 
> Isn't there always try? :-)

Only in php5 :)

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] Testing Variables

2003-10-01 Thread Chris Shiflett
--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> if ($do || false == $do ) {
>   try();
> }
> /* Do, or do not. There is no try. */

Isn't there always try? :-)

Chris

=
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp
My Blog
 http://shiflett.org/

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



Re: [PHP] Testing Variables

2003-10-01 Thread Curt Zirzow
* Thus wrote Richard Baskett ([EMAIL PROTECTED]):
> on 10/1/03 8:23 PM, Gerard Samuel at [EMAIL PROTECTED] wrote:
> 
> > I've noticed code written in this order ->
> > if (FALSE === $foo)
> > {
> >   // yada yada
> > }
> > 
> > Is there a reason/benefit to test variables like that instead of ->
> > if ($foo === FALSE)
> > {
> >   // yada yada
> > }
> > 
> > Thanks
> 
> I think it's more to catch errors.. for example.. if I typed this:
> 
> if ($foo = FALSE)
> 
> You will not get an error since you are assigning $foo the value of FALSE
> 
> while if you did this:
> 
> if (FALSE = $foo)
> 
> PHP will throw up an error because you can not assign FALSE the value of
> $foo :)
> 
> That's the only reason that I can think of.

Yep.  Just make sure you dont start speaking english like that,
people will look at you funny, or think your yoda :)

if ('away' == $put_your_weapon) {
  $harm = false;
}
/* Away put your weapon, I mean you no harm */

or 
if ( 'help' == $you_can )  {
  hmm();
}
/* Help you can, Hmm! */

Or more popular:

if ($do || false == $do ) {
  try();
}
/* Do, or do not. There is no try. */



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Chris Shiflett
--- Nicole <[EMAIL PROTECTED]> wrote:
> So I switched to connect, with no luck in fixing the "too many
> connections" problem.

Now that's some helpful information. The first thing you need to do is forget
about persistent connections being the problem.

I don't claim to be an expert at debugging MySQL issues such as this, but I
have always found Jeremy Zawodny's mytop to be a very handy tool:

http://jeremy.zawodny.com/mysql/mytop/

Using this tool, you might notice some hung query, and you will be able to view
the specific SQL statement that is causing problems (for whatever reason). If
you are not using persistent connections and getting a "too many connections"
message, it means you have at least one situation that results in a connection
to MySQL to remain open, possibly even after the Apache child process
terminates (a crash, perhaps?).

Hope that helps.

Chris

=
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
RAMP Training Courses
 http://www.nyphp.org/ramp
My Blog
 http://shiflett.org/

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Chris Shiflett
--- Nicole <[EMAIL PROTECTED]> wrote:
>  I don't see a MaxConnections in Apache conf, or maybe I overlooked
> it. I do see:
> 
> MaxClients 150

Maximum connections is the MySQL configuration option. MaxClients is the Apache
directive I mentioned.

Ultimately, all you have to do to use persistent connections is make sure that
you allow more connections to MySQL than could possibly be used by all
applications that use it. In an environment where you only have Apache (PHP)
accessing the database, this means you want MySQL's maximum connections set
higher than Apache's maximum number of clients. I usually leave at least one
extra MySQL connection for myself (in case a bug in my application causes all
connections to be hung).

Other than that, you just use mysql_pconnect to connect, and you don't use
mysql_close (otherwise you'll be making things worse).

One big caveat to using persistent connections is that if you have problems in
your scripts or with the stability of your applications, using persistent
connections can potentially make things worse. If your script hangs due to an
infinite loop or some other programming error, you may cause a MySQL lock to
remain that ties up other Apache child processes indefinitely. I'm sure there
are a lot of things like this that I can't even think of at the moment. But, if
things are working well, persistent connections can be a big help to a stressed
database server.

> I did read -- in various places -- that it was better to use
> connect, including PHP. Because php and mysql are fast to open a
> regular connection, using connect may ultimately be better. That's
> just what I read.

Where? If you found it in the PHP Manual, then it may need to be corrected
(depending on exactly what is stated). What the manual does state (when
speaking about persistent database connections in general) is that persistent
connections are helpful if the cost of establishing a connection is high. This
is just to be safe. Because managing the pool of connections and performing the
lookup does take some finite amount of time, it is possible that establishing a
connection to a database could be faster than this overhead. With MySQL, I have
never seen this to be the case, and you won't see this statement made here:

http://www.php.net/mysql_pconnect

> I found this bit:
> http://us2.php.net/manual/en/features.persistent-connections.php
> 
> So really, I am confused on this matter. I believe it boils down to
> configuration issues betweeen MySQL's conf and Apache's conf files.
> Maybe even in php.ini. I can't seem to find a correct article on how
> to fix these things. What I read in forums I become leary of,
> thinking the person may be incorrect. So I like to stick to
> documentation. But I can't seem to find enough.

Don't rule our programming errors. If you want more specific help, you might
try to give us some statistics, such as how quickly MySQL's connections are
filled up and whether it is at a faster rate than Apache seems to be spawning
new child processes. Any sort of data would help us to make a guess. If
possible, you might want to load test a very simple script that performs a
simple query and see what the characteristics are. Can you be certain that all
of your PHP scripts are terminating properly?

Also, documentation is just written by regular people. They can be wrong. I've
contributed to the PHP Manual, and I've been wrong plenty of times (hopefully
not in the manual, of course).

Hope that helps.

Chris

=
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
RAMP Training Courses
 http://www.nyphp.org/ramp
My Blog
 http://shiflett.org/

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



[PHP] problem with if..else condition

2003-10-01 Thread irinchiang


Hi all, 
I'm having some problem with my PHP script here. Do hope to receive some
help. I have written the script with a if..elseif..else ...condition to check if
my checkbox have been checked. There is 3 radio button to be clicked: eg button1
, button 2 and button3.Only one to be checked at one time. Supposely "button1"
is clicked, it should output "button1" as the selection once the submit button
has been clicked. I have attached my HTMl and PHP code below. Hope to get some
help here.

HTML:



Payment Mode

@import url(receipt.css);







Payment Mode:

  
  Cash
  
  
  
*For Cheque plus Cash payment only:

 
Cheque: $ 


Cash:   $ 





pe="radio" name="payment" value="Nets">Nets
  
  
  Cheque


PHP:




Payment Mode

@import url(receipt.css);









   
 




  Cash: 
  Cheque:
   
 
   
 
   
   Total payable: $$total";
?>




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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Nicole
Thanks. My problem is that I am getting a "too many connections" error, and
wondered if  there was a proper configuration to handle this. I have the
problem, regardless of using connect or pconnect. I originally used pconnect
for the last year. But my site is growing and growing and am looking for
anything to help fix the problem. So I switched to connect, with no luck in
fixing the "too many connections" problem. Originallly, increasing
max_connections in my.cnf solved the problem for a while. But the growth has
caught up again.

I thought I read that increasing this max_connections number too high could
cause problems as well. So I am hesitant to raise it anymore.

--
Nicole
aeontrek.com

"Jason Sheets" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Generally persistent connections will almost always be faster there are
> some considerations though, first resource usage if you are busy site
> and don't have enough memory to support one connection to the db for
> each apache process you will run into problems, second if you site is
> not busy enough and you rarely connect to the database you wont see much
> of a performance increase.  Sometimes you need to take precautions to
> safely restart apache otherwise you can have connections to the db left
> open.
>
> Obviously persistent connections are faster because you don't have the
> overhead of building and tearing down the connection on each request,
> I've seen a 5 to 15% increase in page generation time on some
> applications by using persistent connections depending on the db server
> and the protocol.
>
> Becoming Digital wrote:
>
> >I'm with Chris on this one.  I did some serious load testing on my
servers and always faired better with persistent connections.  I don't have
the logs handy right now, but I can probably dig them up if anyone really
wants to see the numbers.
> >
> >Edward Dudlik
> >Becoming Digital
> >www.becomingdigital.com
> >
> >
> >
> >- Original Message -
> >From: "Chris Shiflett" <[EMAIL PROTECTED]>
> >To: "Curt Zirzow" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
> >Sent: Wednesday, 01 October, 2003 22:53
> >Subject: Re: [PHP] "Too many connections" fix?
> >
> >
> >--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> >
> >
> >>This may be debatable, which is better? php searching through a
> >>pool of 1000 connections for a free one or the overhead of opening
> >>a new resource to the database each request.
> >>
> >>
> >
> >I suppose people can debate just about anything, but I doubt anyone can
come up
> >with any statistics to defend the stance that persistent connections are
slower
> >under heavy traffic. Of course, I'd love to see people's results, but my
> >experience has shown quite the opposite.
> >
> >Also, the difference becomes exaggerated with heavier traffic. So, a
better
> >argument would be to ask whether the overhead of managing persistent
> >connections is worth it when you only have one database connection per
hour. In
> >that case, it may actually be worse, but that's not the situation that
was
> >described. :-)
> >
> >Hope that helps.
> >
> >Chris
> >
> >=
> >RAMP - Rapid AMP Training from the Experts
> > http://www.nyphp.org/content/training/ramp.php
> >HTTP Developer's Handbook
> > http://shiflett.org/books/http-developers-handbook
> >My Blog
> > http://shiflett.org/
> >
> >
> >

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



Re: [PHP] your method for validating forms

2003-10-01 Thread John W. Holmes
Chris W. Parker wrote:

What I'd like to do is get rid of all the if's and what not and throw
them into a function. What I thought of doing to replace all this is:


$formdata['fname']['data'] = (!empty($_GET['fname'])) ? $_GET['fname'] :
"" ;
$formdata['fname']['type'] = "name";

$_SESSION['form_errors'] = validateFormData($formdata);

redirect("to_the_previous_page.php");

?>
I use a validation class that's kind of like this. It has a main "check" 
method:

function check($type,$key,$allow_empty=0,$reqlength=0)

where you pass the "type" of validation you want to do (number, string, 
email, website, etc), the $_REQUEST array "key" that holds the value to 
be validated, a flag to allow empty values, and a flag to set a required 
 length for numeric validations.

Validation ends up looking something like this:

$input['name']= $val->check('string','name');
$input['email']   = $val->check('email','email');
$input['phone']   = $val->check('phone','phone',1);
$input['company_name']= $val->check('string','company_name');
$input['job_description'] = $val->check('ml_string','job_description');
$input['website'] = $val->check('website','website',1);
$input['expiration']  = $val->check('number','expiration');
if($val->isErrors()
{ //display errors }
else
{ //process "safe" values within $input }
Each "type" of validation is a different method within the class that 
has it's own rules. There are also methods to validate entries against a 
configuration arrays and methods to turn on and off things like 
htmlentities() of returned values.

If there is an error, the class makes a $css array entry with a key 
matching what was supposed to be validated. So for the above, if the 
"name" validation failed, a $css['name'] variable would be created with 
the value of an error CSS class. This is easily assigned to smarty to 
"mark" parts of the form to highlight where the errors were at:

Name:

The default will be a normal class and when there is an error, it'll get 
an "error" class that makes it bold, red, whatever.

A simple $smarty->assign_by_ref('css',$val->css); is all that's needed. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Jason Sheets
Generally persistent connections will almost always be faster there are 
some considerations though, first resource usage if you are busy site 
and don't have enough memory to support one connection to the db for 
each apache process you will run into problems, second if you site is 
not busy enough and you rarely connect to the database you wont see much 
of a performance increase.  Sometimes you need to take precautions to 
safely restart apache otherwise you can have connections to the db left 
open. 

Obviously persistent connections are faster because you don't have the 
overhead of building and tearing down the connection on each request, 
I've seen a 5 to 15% increase in page generation time on some 
applications by using persistent connections depending on the db server 
and the protocol. 

Becoming Digital wrote:

I'm with Chris on this one.  I did some serious load testing on my servers and always faired better with persistent connections.  I don't have the logs handy right now, but I can probably dig them up if anyone really wants to see the numbers.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message - 
From: "Chris Shiflett" <[EMAIL PROTECTED]>
To: "Curt Zirzow" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, 01 October, 2003 22:53
Subject: Re: [PHP] "Too many connections" fix?

--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
 

This may be debatable, which is better? php searching through a
pool of 1000 connections for a free one or the overhead of opening
a new resource to the database each request.
   

I suppose people can debate just about anything, but I doubt anyone can come up
with any statistics to defend the stance that persistent connections are slower
under heavy traffic. Of course, I'd love to see people's results, but my
experience has shown quite the opposite.
Also, the difference becomes exaggerated with heavier traffic. So, a better
argument would be to ask whether the overhead of managing persistent
connections is worth it when you only have one database connection per hour. In
that case, it may actually be worse, but that's not the situation that was
described. :-)
Hope that helps.

Chris

=
RAMP - Rapid AMP Training from the Experts
http://www.nyphp.org/content/training/ramp.php
HTTP Developer's Handbook
http://shiflett.org/books/http-developers-handbook
My Blog
http://shiflett.org/
 

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


Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Nicole
Pardon me, I misread a pervious comment. I meant MaxClients. Sigh. too
much sleep.

--
Nicole
aeontrek.com

"Nicole" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I don't see a MaxConnections in Apache conf, or maybe I overlooked it. I
do
> see:
>
> MaxClients 150
>
> MaxKeepAliveRequests 100
>
> It seems the latter var there relates more. Any ideas which or if both
> should be bumped up?
>
> I did read -- in various places -- that it was better to use connect,
> including PHP. Because php and mysql are fast to open a regular
connection,
> using connect may ultimately be better. That's just what I read.
>
> I found this bit:
> http://us2.php.net/manual/en/features.persistent-connections.php
>
> And decided it would be ok to use either, and preferrably connect due to
> some other bits I read regarding persistent connections.
>
> So really, I am confused on this matter. I believe it boils down to
> configuration issues betweeen MySQL's conf and Apache's conf files. Maybe
> even in php.ini. I can't seem to find a correct article on how to fix
these
> things. What I read in forums I become leary of, thinking the person may
be
> incorrect. So I like to stick to documentation. But I can't seem to find
> enough.
>
> --
> Nicole
>
>
> "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > --- Nicole <[EMAIL PROTECTED]> wrote:
> > > I run Apache with PHP and MySQL [snip]
> > >
> > > I last increased my max connections to 500. That seemed to fix things
> > > for a while. Now I am getting the problems (database freezing up
> > > because too many connections) again. The site I run is pretty high
> > > traffic.
> >
> > This has nothing to do with traffic (other than the fact that heavy
> traffic can
> > reveal configuration problems more easily).
> >
> > Are you using persistent connections (mysql_pconnect)? If so, you need
to
> make
> > sure you have MySQL maximum connections (max_connections in my.cnf) set
to
> a
> > number that is higher than Apache's MaxClients directive (in
httpd.conf).
> If
> > you have MaxClients at 512, for example, and MySQL only allows a maximum
> of 500
> > connections, you're likely to run into the "too many connections"
problems
> once
> > your traffic pushes the number of Apache clients past 500.
> >
> > Hope that helps.
> >
> > Chris
> >
> > =
> > HTTP Developer's Handbook
> >  http://shiflett.org/books/http-developers-handbook
> > My Blog
> >  http://shiflett.org/

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



Re: [PHP] Testing Variables

2003-10-01 Thread Richard Baskett
on 10/1/03 8:23 PM, Gerard Samuel at [EMAIL PROTECTED] wrote:

> I've noticed code written in this order ->
> if (FALSE === $foo)
> {
>   // yada yada
> }
> 
> Is there a reason/benefit to test variables like that instead of ->
> if ($foo === FALSE)
> {
>   // yada yada
> }
> 
> Thanks

I think it's more to catch errors.. for example.. if I typed this:

if ($foo = FALSE)

You will not get an error since you are assigning $foo the value of FALSE

while if you did this:

if (FALSE = $foo)

PHP will throw up an error because you can not assign FALSE the value of
$foo :)

That's the only reason that I can think of.

Cheers!

Rick

"You've got to stand for something or you will fall for anything" - Unknown

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



[PHP] Testing Variables

2003-10-01 Thread Gerard Samuel
I've noticed code written in this order ->
if (FALSE === $foo)
{
   // yada yada
}
Is there a reason/benefit to test variables like that instead of ->
if ($foo === FALSE)
{
   // yada yada
}
Thanks

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


[PHP] Re: "Too many connections" fix?

2003-10-01 Thread Nicole
I am working on a way to do this. The site is for tracking. The hits get
stored in the database. The database must be hit in order to retrieve the
URL that is needed to redirect to. I am contemplating storing this URL in a
file instead of db. Perhaps this will reduce the load. Thanks.

I run several sites on this server, and the majority of the auto-emails I
get about the database being down is for this one site. But I do get an
email for my other site(s) every now and then. So I think that I need to
work on the configuration of the conf files for MySQL and Apache to fix this
problem as much as possible.

Thanks,

--
Nicole
aeontrek.com

"Cristian Lavaque" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Nicole wrote:
> > Hello,
> >
> > I run Apache with PHP and MySQL on a RedHat 7.2 box with 1GB Ram @
> > 2GHZ (p4).
> >
> > I last increased my max connections to 500. That seemed to fix things
> > for a while. Now I am getting the problems (database freezing up
> > because too many connections) again. The site I run is pretty high
> > traffic.
> >
> > I wondered if anyone encountered a solution to handle this sort of
> > problem.
> >
> > TIA!
>
> Wouldn't it be good to cache the dynamic pages to files to take some of
the
> load off the db?
>
> Cristian

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Nicole
 I don't see a MaxConnections in Apache conf, or maybe I overlooked it. I do
see:

MaxClients 150

MaxKeepAliveRequests 100

It seems the latter var there relates more. Any ideas which or if both
should be bumped up?

I did read -- in various places -- that it was better to use connect,
including PHP. Because php and mysql are fast to open a regular connection,
using connect may ultimately be better. That's just what I read.

I found this bit:
http://us2.php.net/manual/en/features.persistent-connections.php

And decided it would be ok to use either, and preferrably connect due to
some other bits I read regarding persistent connections.

So really, I am confused on this matter. I believe it boils down to
configuration issues betweeen MySQL's conf and Apache's conf files. Maybe
even in php.ini. I can't seem to find a correct article on how to fix these
things. What I read in forums I become leary of, thinking the person may be
incorrect. So I like to stick to documentation. But I can't seem to find
enough.

--
Nicole


"Chris Shiflett" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> --- Nicole <[EMAIL PROTECTED]> wrote:
> > I run Apache with PHP and MySQL [snip]
> >
> > I last increased my max connections to 500. That seemed to fix things
> > for a while. Now I am getting the problems (database freezing up
> > because too many connections) again. The site I run is pretty high
> > traffic.
>
> This has nothing to do with traffic (other than the fact that heavy
traffic can
> reveal configuration problems more easily).
>
> Are you using persistent connections (mysql_pconnect)? If so, you need to
make
> sure you have MySQL maximum connections (max_connections in my.cnf) set to
a
> number that is higher than Apache's MaxClients directive (in httpd.conf).
If
> you have MaxClients at 512, for example, and MySQL only allows a maximum
of 500
> connections, you're likely to run into the "too many connections" problems
once
> your traffic pushes the number of Apache clients past 500.
>
> Hope that helps.
>
> Chris
>
> =
> HTTP Developer's Handbook
>  http://shiflett.org/books/http-developers-handbook
> My Blog
>  http://shiflett.org/

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



[PHP] multi uploads permissions

2003-10-01 Thread Cameron Metzke
Hi all,
I have a multi upload script, which works, but the end result is that the
files that are uploaded are set to permissions of 600. Im think this is
because they have a tmp name then are written to the "uploads" folder so in
effect they are written by another system user? (lol ok so im new to php not
sure if i followed that myself). well here is the script.
---Start Code--

$where_to_go = $path."/home/user/uploader/originals/"; //with trailing slash
   if (!$Submit)
   {
while (list ($key, $value) = each ($_FILES['file']['tmp_name']))
{
umask(000);
$ok = (move_uploaded_file($_FILES['file']['tmp_name'][$key], $where_to_go .
$_FILES['file']['name'][$key]));

--End Code---
is there anyway to set the permissions to 777 as i would like to further
manipulate the images? and is that a good idea? or would it be better to
chown them, (which i have no idea how to do via php). Or does anyone have
any other ideas im completely stumped.
Thankyou
Cam

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Becoming Digital
I'm with Chris on this one.  I did some serious load testing on my servers and always 
faired better with persistent connections.  I don't have the logs handy right now, but 
I can probably dig them up if anyone really wants to see the numbers.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message - 
From: "Chris Shiflett" <[EMAIL PROTECTED]>
To: "Curt Zirzow" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, 01 October, 2003 22:53
Subject: Re: [PHP] "Too many connections" fix?


--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> This may be debatable, which is better? php searching through a
> pool of 1000 connections for a free one or the overhead of opening
> a new resource to the database each request.

I suppose people can debate just about anything, but I doubt anyone can come up
with any statistics to defend the stance that persistent connections are slower
under heavy traffic. Of course, I'd love to see people's results, but my
experience has shown quite the opposite.

Also, the difference becomes exaggerated with heavier traffic. So, a better
argument would be to ask whether the overhead of managing persistent
connections is worth it when you only have one database connection per hour. In
that case, it may actually be worse, but that's not the situation that was
described. :-)

Hope that helps.

Chris

=
RAMP - Rapid AMP Training from the Experts
 http://www.nyphp.org/content/training/ramp.php
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
My Blog
 http://shiflett.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: your method for validating forms

2003-10-01 Thread Brad Pauly
On Wed, 2003-10-01 at 20:26, Manuel Lemos wrote:
> Hello,
> 
> On 10/01/2003 08:43 PM, Chris W. Parker wrote:
> > $_SESSION['form_errors'] = validateFormData($formdata);
> > 
> > 
> > redirect("to_the_previous_page.php");
> 
> You may want to study how this classic form validation and generation 
> class works. It generates the necessary Javascript to validate on the 
> client side and uses the class methods to validate on the server side.
> 
> 
> It makes it simple to generate, validate and process a form in the same 
> script, thus avoiding needless server access roundtrips that only slow 
> down the sites for the users.

While there is overhead in making that round trip, I wanted to note a
few reasons that I prefer server side validation.

Some input validation cannot be easily done with Javascript (like
checking for existing usernames in a database) so you end up showing
error messages in two ways. Sometimes the user sees a Javascript alert
and other times a message within the browser.

Validating server side also gives you an opportunity to gather
information about the way your application is being used. Supposed you
have a logging mechanism that writes validation errors to a log. You
might notice that there is a high frequency of failure for one kind of
validation. Maybe the instructions for a file upload are confusing and
users are constantly messing it up.

Also, hardware is very fast for what it costs (I know, don't solve a
problem by throwing money at it). Anyway, just some things to consider.

- Brad

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



[PHP] Re: need PHP server

2003-10-01 Thread Cameron Metzke
If your on windows try this -- http://apache2triad.org/
"Hung Cuong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I need an server to put my php file to post mail.
> So anybody can introduce me some server
> Thanks.

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



Re: [PHP] your method for validating forms

2003-10-01 Thread Robert Cummings
InterJinn works something like this for it's FormJinn engine. So I'd say
it sounds quite good :)

Cheers,
Rob.

On Wed, 2003-10-01 at 19:43, Chris W. Parker wrote:
> Hey people.
> 
> I'm trying to come up with an easy way to validate forms. I've got an
> idea and I'd like your feedback as well as suggestions and/or your own
> methods.
> 
> My idea is to have a multi-dimensional array with fields: data and type.
> 
> Let's say you have a form with three fields. First Name (fname), Last
> Name (lname), and Phone Number (phone). It's sent to a processing script
> via GET. On the processing script you have the basics:
> 
>  
> // collect data
> $fname = (!empty($_GET['fname'])) ? $_GET['fname'] : "" ;
> $lname = (!empty($_GET['lname'])) ? $_GET['lname'] : "" ;
> $phone = (!empty($_GET['phone'])) ? $_GET['phone'] : "" ;
> 
> // validate data
> if($fname is not [a-zA-Z]{2,20})
> {
>   // mark as error
> }
> 
> if($lname is not [a-zA-Z]{2,20})
> {
>   // mark as error
> }
> 
> $phone = stripOutEverythingButTheNumbers($phone);
> 
> if($phone is not [0-9]{10}) // we only sell to US via website
> {
>   // mark as error
> }
> 
> $_SESSION['form_errors'] = put_the_errors_in_here;
> 
> redirect("to_the_previous_page.php"); // where the errors will be read
>   // and the fields with bad data
>   // will be marked appropriately
> 
> ?>
> 
> What I'd like to do is get rid of all the if's and what not and throw
> them into a function. What I thought of doing to replace all this is:
> 
>  
> $formdata['fname']['data'] = (!empty($_GET['fname'])) ? $_GET['fname'] :
> "" ;
> $formdata['fname']['type'] = "name";
> $formdata['lname']['data'] = (!empty($_GET['lname'])) ? $_GET['lname'] :
> "" ;
> $formdata['lname']['type'] = "name";
> $formdata['phone']['data'] = (!empty($_GET['phone'])) ? $_GET['phone'] :
> "" ;
> $formdata['phone']['type'] = "phonenumber";
> 
> 
> $_SESSION['form_errors'] = validateFormData($formdata);
> 
> 
> redirect("to_the_previous_page.php");
> 
> ?>
> 
> The validateFormDate() function would be defined something like this:
> 
> function validateFormData($input)
> {
>   foreach($input as $field)
>   {
>   switch ($field['type'])
>   {
>   case 'name':
>   // do the magic
>   break;
>   case 'phonenumber':
>   // do the magic
>   break;
>   }
>   }
> }
> 
> 
> The validateFormData() function will return false if there are no errors
> to report.
> 
> For a form that has a lot of fields to validate I think this can make
> things pretty easy.
> 
> 
> So... what do you think?
> 
> 
> 
> Chris.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] need PHP server

2003-10-01 Thread Hung Cuong
I need an server to put my php file to post mail.
So anybody can introduce me some server
Thanks.

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



[PHP] if..else condition for checkbox

2003-10-01 Thread irinchiang

Hi all, 
   May I just ask how do I do a "if..elseif..else" condition to check if a
"checkbox" have been checked. For some reference, I have attached my HTML code
and  PHP code below:

HTML:


Payment Mode

@import url(receipt.css);







Payment Mode:

  
  Cash
  
  
  Nets
  

  
  Cheque

*For Cheque plus Cash payment only:

 
Cheque: $ 


Cash:   $ 








PHP Code:


Payment Mode

@import url(receipt.css);














  Cash: 
  Cheque:


   
   Total payable: $$total";
?>




Regards, 
Irin.

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Chris Shiflett
--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> This may be debatable, which is better? php searching through a
> pool of 1000 connections for a free one or the overhead of opening
> a new resource to the database each request.

I suppose people can debate just about anything, but I doubt anyone can come up
with any statistics to defend the stance that persistent connections are slower
under heavy traffic. Of course, I'd love to see people's results, but my
experience has shown quite the opposite.

Also, the difference becomes exaggerated with heavier traffic. So, a better
argument would be to ask whether the overhead of managing persistent
connections is worth it when you only have one database connection per hour. In
that case, it may actually be worse, but that's not the situation that was
described. :-)

Hope that helps.

Chris

=
RAMP - Rapid AMP Training from the Experts
 http://www.nyphp.org/content/training/ramp.php
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
My Blog
 http://shiflett.org/

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



[PHP] PHP Bug Problems

2003-10-01 Thread Richard Baskett
Well I saw a post on a forum talking about a certain bug that PHP has for
Mac OS X.. so I thought.. Im on OS X, I should see if that bug is real since
on bugs.php.net they say it's bogus which you can view here:

http://bugs.php.net/bug.php?id=25394

So I tried it out.. at first I created a loop that assigned $x = 1; a whole
bunch of times, but that didn¹t crash anything..  I then read the authors
post a little closer and I realized it was a number of lines problem.. so I
crated a php file that had a whole bunch of $x = 1; commands in it.. 7996 to
be exact.. add the opening and closing php tag.. that made 7998 lines.. the
script still worked.. Now I added one more line so that there were 7999
lines and guess what?  Yep you got it.. my script didn¹t work anymore.
Which the author it looks like it took 8014 lines instead of my 7999 lines
to break it.

I thought this was strange and it looked like the author of the php bug
report was indeed on the up-and-up and it wasn¹t a bogus bug as bugs.php.net
had said it was.

So I thought to myself.. well I should post to bugs.php.net and tell them
that I to can reproduce the bug.  So I did.

Well to make an already long story short.. it looks like after a couple of
hours bugs.php.net has removed my post.

My question to you is.. is there any reason why they would remove my post?
For me.. since I do not write that many lines of code for one run of a
script it really didn¹t matter much to me, but since they removed my post..
it's beginning to make me wonder what's going on..

Hopefully someone can shed some light!

Cheers and thanks!

Rick

"Not one of them who took up in his youth with this opinion that there are
no gods, ever continued until old age faithful to his conviction." - Plato 

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



[PHP] need a php server

2003-10-01 Thread Hung Cuong
I need an server to put my php file to test.
So anybody can introduce me some server
Thanks.

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



[PHP] Very first web app and questions

2003-10-01 Thread mike
I've just to put together my very first little web application project in
PHP and I have a couple of questions.

The first isn't that important because it's no where near finished yet but
the help would be appreciated. Can those who have the time visit
http://www.array-media.com/WebDev/TestClassifieds/ and let me know what I
need to work on to make this easier to use etc. I know it's broken all
over the place but I'd like some outside input before I start to polish
this turd on the weekend.

The second question is the real one. Because this site may eventually be
put onto the web as an unmoderated site, I was wondering what would be the
best way to test the users input for inappropriate content (Bad words). I
was thinking of using a table in MySql containing the questionable words
and basically break up the users input, search through the Db and if it
returns a positive, dump the offender to an error page reporting the
rejected word found. This seemed like a hell of a lot of overhead
(breaking up the string, opening a connection to the database, searching
the database, creating the custom error page, closing the connection,
etc.) for such a simple task. I also thought of doing it from within the
script using something like strtok(), or str_replace() to loop through and
compare the users input string to an array of the bad words (I'm thinking
20-30 depending on how creative my friends and I get).

So which is faster, smarter, better? What else could I use to accomplish
this task? I kinda like the MySql option myself seems easier to deal with
for some reason

Mike

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



[PHP] Re: your method for validating forms

2003-10-01 Thread Manuel Lemos
Hello,

On 10/01/2003 08:43 PM, Chris W. Parker wrote:
$_SESSION['form_errors'] = validateFormData($formdata);

redirect("to_the_previous_page.php");
You may want to study how this classic form validation and generation 
class works. It generates the necessary Javascript to validate on the 
client side and uses the class methods to validate on the server side.

It makes it simple to generate, validate and process a form in the same 
script, thus avoiding needless server access roundtrips that only slow 
down the sites for the users.

http://www.phpclasses.org/formsgeneration

--

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


Re: [PHP] Show index.php instead of index.html

2003-10-01 Thread Ryan A
Hi,
Thanks for replying.

I am on a shared hosting account and dont have access to my httpd.conf file,
is there some way to do the same via .htaccess or something?

Any ideas? i want to open the site today.

Thanks,
-Ryan


We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com


- Original Message - 
From: "Chris Garaffa" <[EMAIL PROTECTED]>
To: "Ryan A" <[EMAIL PROTECTED]>
Sent: Thursday, October 02, 2003 4:18 AM
Subject: Re: [PHP] Show index.php instead of index.html


> On Oct 1, 2003, at 10:14 PM, Ryan A wrote:
>
> > Hi,
> > I just deleted my index.html page because i want to use my index.php
> > page
> > instead but when i visit my site i see the directory listing instead,
> > what
> > should i do to display the index.php page automatically??
>
> If you're using Apache, edit your httpd.conf file so that
> DirectoryIndex is set to index.php (you can leave index.html in there
> if you think you'll bring it back sometime. Apache will look for the
> files in the order specified in httpd.conf).
>
> For example:
> DirectoryIndex index.html index.php
>
>
> -- 
> Chris Garaffa
> [EMAIL PROTECTED]
>
>
>

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



RE: [PHP] Show index.php instead of index.html

2003-10-01 Thread Martin Towell
Hi

It depends on the web server you're using...

Martin

-Original Message-
From: Ryan A [mailto:[EMAIL PROTECTED]
Sent: Thursday, 2 October 2003 12:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Show index.php instead of index.html


Hi,
I just deleted my index.html page because i want to use my index.php page
instead but when i visit my site i see the directory listing instead, what
should i do to display the index.php page automatically??

Kindly help.

Thanks,
-Ryan

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



[PHP] Show index.php instead of index.html

2003-10-01 Thread Ryan A
Hi,
I just deleted my index.html page because i want to use my index.php page
instead but when i visit my site i see the directory listing instead, what
should i do to display the index.php page automatically??

Kindly help.

Thanks,
-Ryan

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



Re: [PHP] your method for validating forms

2003-10-01 Thread Curt Zirzow
* Thus wrote Chris W. Parker ([EMAIL PROTECTED]):
> Hey people.
> 
> 
> function validateFormData($input)
> {
>   foreach($input as $field)
>   {
>   switch ($field['type'])
>   {
>   case 'name':
>   // do the magic
>   break;
>   case 'phonenumber':
>   // do the magic
>   break;
>   }
>   }
> }
> 
> 
> The validateFormData() function will return false if there are no errors
> to report.

I usually return an empty array.

> 
> For a form that has a lot of fields to validate I think this can make
> things pretty easy.
> 
> 
> So... what do you think?

I do this very exact thing in a lot of my code. The validation
function's are usually related to the object I'm validating.

function customer_info_validate($customer);

Then you can take it a step further and make some generic common
validation's like email, phone numbers, etc and your magic code
would just call those.

Then make a generic function that accepts a value and a regex
pattern to validate against the value. So now your switch would be
something like:

  case 'name':
validate_regex($field['value'], '/^[a-z ]{5,50}$/i');
break;
  case 'us_phone':
validate_us_phone($field['value']);
break;
  etc..

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] your method for validating forms

2003-10-01 Thread Brad Pauly
On Wed, 2003-10-01 at 17:43, Chris W. Parker wrote:
> Hey people.

Hey

[snip]

> What I'd like to do is get rid of all the if's and what not and throw
> them into a function. What I thought of doing to replace all this is:
> 
>  
> $formdata['fname']['data'] = (!empty($_GET['fname'])) ? $_GET['fname'] :
> "" ;
> $formdata['fname']['type'] = "name";
> $formdata['lname']['data'] = (!empty($_GET['lname'])) ? $_GET['lname'] :
> "" ;
> $formdata['lname']['type'] = "name";
> $formdata['phone']['data'] = (!empty($_GET['phone'])) ? $_GET['phone'] :
> "" ;
> $formdata['phone']['type'] = "phonenumber";
> 
> 
> $_SESSION['form_errors'] = validateFormData($formdata);
> 
> 
> redirect("to_the_previous_page.php");
> 
> ?>
> 
> The validateFormDate() function would be defined something like this:
> 
> function validateFormData($input)
> {
>   foreach($input as $field)
>   {
>   switch ($field['type'])
>   {
>   case 'name':
>   // do the magic
>   break;
>   case 'phonenumber':
>   // do the magic
>   break;
>   }
>   }
> }
> 
> 
> The validateFormData() function will return false if there are no errors
> to report.
> 
> For a form that has a lot of fields to validate I think this can make
> things pretty easy.
> 
> 
> So... what do you think?

I have done something similar to this in a couple projects and have been
fairly happy with it. Without going into too much detail, I define a few
more array elements and call functions instead of doing everything in a
switch statement.

Instead of a 'type' element, I have 'rules' which is a comma delimited
list of the validation I want it to run on each field. For example,
IsEmail, IsNotBlank, IsPhoneNumber. These correspond to functions of the
same name. The reason I have more than one per field (why not just use
IsPhoneNumber in place of IsNotBlank,IsPhoneNumber?) is so that I can
give more detailed error messages.

I think it is a good idea to move your validation into one place,
whether it be in a switch statement or different functions. Not only
does it save you time, but it keeps your validation consistent across
your application.

- Brad 

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



Re: [PHP] upapck() woes

2003-10-01 Thread Tom Rogers
Hi,

Thursday, October 2, 2003, 3:31:40 AM, you wrote:
JB> I have kibitzed and kaboodles all morning seeking the answer to the
JB> unpack question. I need to unpack some binary data and make sense of it.
JB> Unfortunately I am unsure how the binary for this was created. I have
JB> tried converting ascii but I am thinking (after much frustration) that I
JB> should go hex and then convert that. Has anyone had any experience in
JB> unpacking unknown binaries and making sense of them?

JB> TVMIA!

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


Have you tried using the unpack() function ?

If you need to dump the data to see what it looks like here is a couple of
functions that will help.

function hexDumpChar($str,$len){
//echo 'Len '.strlen($str);
$strlen = strlen($str);
for($z=0;$z < $strlen;$z+=$len){
$left = $strlen - $z;
$jlen = ($left > $len)? $len:$left;
for($j=$z;$j<$z+$jlen;$j++){
printf(" %02x",ord($str[$j]));
}
echo '';
for($j=$z;$j<$z+$jlen;$j++){
printf(" %c",ord($str[$j]));
}
echo '';
}
echo '';
}
function hexDumpWord($str,$len){
//little endian;
for($z=0,$y=strlen($str);$z < $y;$z+=$len){
for($j=$z;$j<$z+$len;$j+=2){
printf(" %02x%02x ",ord($str[$j+1]),ord($str[$j]));
}
echo '';
}
echo '';
}
function hexDumpDoubleWord($str,$len){
//little endian;
for($z=0,$y=strlen($str);$z < $y;$z+=$len){
for($j=$z;$j<$z+$len;$j+=4){
printf(" 
%02x%02x%02x%02x  ",ord($str[$j+3]),ord($str[$j+2]),ord($str[$j+1]),ord($str[$j]));
}
echo '';
}
echo '';
}

to use

$str = substr($binary_data,0 256);
hexDumpChar($str,16);

will dump the first 256 bytes of data with 16 chars per line.

If the binary data is little endian and you need to extract a 2 words (word = 2
bytes) you can do something like this:
$ptr = 0;
$word1 = (ord($binary_data[$ptr+1]) << 8) | ord($binary_data[$ptr]);
$ptr +=2;
$word2 = (ord($binary_data[$ptr+1]) << 8) | ord($binary_data[$ptr]);

or
$str = substr($binary_data,0,2);
$up = unpack("vword1/vword2",$str);

will give you an array
$up['word1'] and $up['word2'];


If you don't know the format of the original data it can be a long process
undoing it :)


-- 
regards,
Tom

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



[PHP] Changing users in php script

2003-10-01 Thread John Nichel
I know php runs under the same user/group as the webserver for web based 
applications, but is there a way to change to another user?  All the 
recent talk about exec got me thinking that I could set something up to 
automatically create user mailboxes under qmail + vmailmgr.  I normall 
do this via the command line by running 'vadduser' while I'm su'ed to 
the owner of the virtual host.  So basically, to do this via php, I 
would need to su to the owner of the vhost inside of the script, run the 
command, and exit out of the su.  Can this be done?

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] exec shell command from php

2003-10-01 Thread Tom Rogers
Hi,

Thursday, October 2, 2003, 1:54:38 AM, you wrote:
N> hi all;

N> - When i run php.. what user am i using ? is it apache user (nobody) ??
N> - How can i execute useradd command from php ? should i write it in
N> pearl/cgi ??
N> - I want to grant my user on my web a free pop account (or webmail) so i
N> need to create an user with bin/false so he has no shell login but pop login
N> ... how can i do this by php.. as exec('useradd ...
N> couldn't be done only by root . what user should i do ? what solution ..
N> i googled for virtual popuser .. and i didn't manage .. so i decided to do
N> it this way
N> any comment ?


You are better using something like vpopmail that creates virtual accounts
without the need for system accounts.
http://www.inter7.com/vpopmail.html needs qmail but the other mail systems can
do similar things and not need system accounts.

-- 
regards,
Tom

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



Re: [PHP] PHP OOP

2003-10-01 Thread Tom Rogers
Hi,

Wednesday, October 1, 2003, 9:00:18 AM, you wrote:
GH> I'm working for the first time with object orientated programming in php and
GH> I can't figure out how to access elements or methods when you place objects
GH> inside objects inside other objects.

GH> my origonal idea was to  use the following syntax:
$a->>b->c
GH> but this just returns:
$a->>b  . "->c"

GH> Please, need advice on the finer points of OOP in PHP


if you have this

class a {
  var $var_a = 'A';
  function a ($var){
$this->$var_a = $var;
  }
  function get_var(){
return $this->var_a;
  }
}
class b {
  var $a = '';
  function b ($var){
$this->$a = new a($var);
  }
  function get_var(){
return $this->a->get_var();
  }
}

$class_b = new b("Hello');

You can access class a directly with

$class_a_var = $class_b->a->var_a;

but this relies on you knowing the structure of your classes. (note we drop the
$ after the ->)

What is better is to use the black box method and make access functions in each
class and do

$class_a_var = $class_b->get_var();

This way we can change how class a works and not worry about how it stores its
data. With this method if we change the variable name in class a to $new_a the
code will still work, where as $class_b->a->var_a will now fall in a heap.

Hope this helps
-- 
regards,
Tom

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



[PHP] Re: upload security

2003-10-01 Thread Dennis Sterzenbach
"Philippe Lemmerling" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> I have a question concerning security of my file upload script. I'm
using
> the php upload routines (move_uploaded_file,...) and variables
($_FILES) to
> upload images to a webdirectory. Everything works fine, meaning that I
can
> upload images BUT only if I change the permission of the directory to
which
> the uploaded images are moved to 777. I guess that this is not such a
good
> thing from security point of view. So here are some questions I have:
Yeah, pretty sure about that 777-thingie.

> 1) is this really that dangerous? How could this be exploited by an
> attacker?
Am unsure about it, as to I'm no attacker to any system.
But from my background I can say, that whereever public write
permissions are set, any (tricky) attacker will find a way into.

> 2)using chmod in my php script (to switch back and forth between 700
and
> 777) is not an option since I'm on a virtual host and PHP is in safe
mode
Are you really sure about the privileges set to 777?
Think of the following: My server does run under account
User websrv
Group webusers
So the PHP script will be running under the same user account, using it
while
doing all the chown,chmod,move_uploaded_file... things.
But if the upload directory /www/uploads/ is created by root,
the websrv user will have no write privilege to that directory.

Another thing to keep in mind is the umask. If you chmod to 777, might
be
755 only, due to an umask value of 022. So always keep an eye on that.

Try looking up the ini-setting about upload-directory defined by the ISP
(for you it should be the local value rather than a global)

> 3)creating a directory which is not reachable by webbrowser does not
seem to
> be possible either since outside my webdirectory; everything is
root-owned
> and obviously only my ISP has root permission ;-)
You are able to do so, but not outside your chroot/docroot!
Simple create the directory within the chroot you are able to and create
an
.htaccess disallowing all users from remote systems to change into or
request
files from inside (lookup some resource about .htaccess files. Should be
something like the following (surrounded by  I guess):
Order Deny,Allow
Deny from all
Allow from localhost

--
 Dennis Sterzenbach
 www.darknoise.de

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



RE: [PHP] Output data repeatedly more than once

2003-10-01 Thread esctoday.com | Wouter van Vliet
What I would advise is to capture the output of your reciept into a
variable. Assuming that you've got some function calls, maybe even Database
request mixed up with some print commands .. Or even some times where you
escape out of php (?>). Something like this



And you don't want to run the script multiple times. Do like this:



Hope it helps !

Wouter
-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 30, 2003 1:24 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Output data repeatedly more than once

On Tuesday 30 September 2003 18:59, Marek Kilimajer wrote:
> Yes, you can. But would not it be smarter to increase the number of
> copies in the print dialog?

But that would be environmentally unfriendly because it uses more paper ;-)

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
"Do you believe in intuition?"
"No, but I have a strange feeling that someday I will."
*/

--
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] your method for validating forms

2003-10-01 Thread Chris W. Parker
Hey people.

I'm trying to come up with an easy way to validate forms. I've got an
idea and I'd like your feedback as well as suggestions and/or your own
methods.

My idea is to have a multi-dimensional array with fields: data and type.

Let's say you have a form with three fields. First Name (fname), Last
Name (lname), and Phone Number (phone). It's sent to a processing script
via GET. On the processing script you have the basics:



What I'd like to do is get rid of all the if's and what not and throw
them into a function. What I thought of doing to replace all this is:



The validateFormDate() function would be defined something like this:

function validateFormData($input)
{
foreach($input as $field)
{
switch ($field['type'])
{
case 'name':
// do the magic
break;
case 'phonenumber':
// do the magic
break;
}
}
}


The validateFormData() function will return false if there are no errors
to report.

For a form that has a lot of fields to validate I think this can make
things pretty easy.


So... what do you think?



Chris.

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



Re: [PHP] printf....

2003-10-01 Thread Curt Zirzow
* Thus wrote Dan Joseph ([EMAIL PROTECTED]):
> Hi Folks..
> 
[... messy code that probably had a width="something%" in it ...]

> 
> I have that code, and I get this error:
> 
> Warning: printf(): too few arguments in /home/sites/site8/web/index_test.php
> on line 34

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Curt Zirzow
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
> --- Nicole <[EMAIL PROTECTED]> wrote:
> > Originally, I used pconnect for a while. Then I learned that with
> > high traffic site, that's not the best idea.
> 
> Where did you learn this? I disagree with that notion.

This may be debatable, which is better? php searching through a
pool of 1000 connections for a free one or the overhead of opening
a new resource to the database each request.



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] Re: "Too many connections" fix?

2003-10-01 Thread Cristian Lavaque
Nicole wrote:
> Hello,
>
> I run Apache with PHP and MySQL on a RedHat 7.2 box with 1GB Ram @
> 2GHZ (p4).
>
> I last increased my max connections to 500. That seemed to fix things
> for a while. Now I am getting the problems (database freezing up
> because too many connections) again. The site I run is pretty high
> traffic.
>
> I wondered if anyone encountered a solution to handle this sort of
> problem.
>
> TIA!

Wouldn't it be good to cache the dynamic pages to files to take some of the
load off the db?

Cristian

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



[PHP] upload security

2003-10-01 Thread Philippe Lemmerling
I have a question concerning security of my file upload script. I'm using
the php upload routines (move_uploaded_file,...) and variables ($_FILES) to
upload images to a webdirectory. Everything works fine, meaning that I can
upload images BUT only if I change the permission of the directory to which
the uploaded images are moved to 777. I guess that this is not such a good
thing from security point of view. So here are some questions I have:
1) is this really that dangerous? How could this be exploited by an
attacker?
2)using chmod in my php script (to switch back and forth between 700 and
777) is not an option since I'm on a virtual host and PHP is in safe mode
3)creating a directory which is not reachable by webbrowser does not seem to
be possible either since outside my webdirectory; everything is root-owned
and obviously only my ISP has root permission ;-)
4)I know that changing to ftp functions might solve this problem but I want
to do image resize operations on the uploaded image afterwards anyway so I
would prefer solutions allowing the creation of safe directories or
something similar
5)Any hints and or tips on making safe file upload applications in php are
welcome;

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



[PHP] Re: (another) regex difficulty

2003-10-01 Thread Cristian Lavaque
Cristian Lavaque wrote:
> Jonas_weber @ Gmx . Ch wrote:
>> regular expressions
>> the example below should turn any character exept "\*" (*= any char)
>> into an "x":
>>
>> $term = preg_replace('/[^(\\\)+(.){1}]/', 'x', $term);
>>
>> but i guess because of the [brackets] the "." (period) is treated as
>> character "." instead as metacharacter (that matches any char).
>
> I'm new to regex too, but if you want to match anything that's not an
> *, couldn't it be done like this?
>
> $term = preg_replace('/[^\*\s]*/', 'x', $term);
>
> I put the \s there to skip the whitespace characters too. I haven't
> tested, but I hope it helps.
>
> Cristian

doh, I now understand your question, you don't mean the asterisk literally,
but as any character that follows a backslash... sorry -_-

In a character class, you can negate that class by starting it with ^, but
how do you negate something that's not a class? in this case "\\.", cause if
it's in a charactar class, it'll match "\n" or "n\\". Is there a simple
way to negate a string with regular expression? I hope I wasn't too
confusing in my question.

Cristian

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



Re: [PHP] Session_start() problem

2003-10-01 Thread Curt Zirzow
* Thus wrote Jeff McKeon ([EMAIL PROTECTED]):

Not related to your problem but:

>   session_regisister("userid", "userpassword");
spelling ~~~^^




Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] Re: mail(): can it reply with quoted text?

2003-10-01 Thread Manuel Lemos
Hello,

On 10/01/2003 05:28 PM, Chris wrote:
I wrote an ultra basic mail interface as a part of my client's customer 
administration area to handle emails.  Basically, the standard email 
form gets stored in a database, and when they respond to the help 
request, they fill out the form and PHP emails the message.

Now, they want to have the original email appear as a part of their 
reply.  I could use wordwrap() at around 70 characters and have every 
line appear with the traditional '>' to indicate the replied text.  It 
doesn't seem to be a very elegant solution for mail clients that reflow 
quoted text (not certain how to explain this, but Opera's mail client 
does it).

Is there a way to for mail() to include quoted text like it was actually 
replying to an actual mail client would?
Try this class that comes with the function QuoteText("your text 
here","> ") that does precisely what you need:

http://www.phpclasses.org/mimemessage

--

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: What's the difference ?

2003-10-01 Thread Jon Kriek
$_ENV
http://www.phpbuilder.com/manual/reserved.variables.php#reserved.variables.environment
Variables provided to the script via the environment

$_SERVER
http://www.phpbuilder.com/manual/reserved.variables.php#reserved.variables.server
Variables set by the web server or otherwise directly related to the
execution environment of the current script

-- 
Jon Kriek
http://phpfreaks.com

"X-Virus" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
What's the difference between :

$_SERVER["COMPUTERNAME"] and $_ENV["COMPUTERNAME"] ?

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



Re: [PHP] Sort an array of objects

2003-10-01 Thread Marek Kilimajer
Matt Palermo wrote:
I have an array of object for files on my site.  The objects hold a file's
name, size, extension, etc...  I was wondering if anyone knows where I could
find a relatively easy function for sorting the array of these objects by
either name, size, etc...  Please let me know if got any tips.  Thanks a
lot!
Matt

function sort_objects_by_name($a, $b) {
if ($a->name == $b->name) return 0;
return ($a->name > $b->name) ? -1 : 1;
}
usort($objects, 'sort_objects');

It might work to define the function as
function sort_objects_by_name(&$a, &$b), try it yourself
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sort an array of objects

2003-10-01 Thread Kevin Stone

"Matt Palermo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I have an array of object for files on my site.  The objects hold a file's
> name, size, extension, etc...  I was wondering if anyone knows where I could
> find a relatively easy function for sorting the array of these objects by
> either name, size, etc...  Please let me know if got any tips.  Thanks a
> lot!
> 
> Matt

Off the top of my head..

 'Kevin',
'company' => 'IBM'),
array(
'name' => 'Steve',
'company' => 'Apple'),
array(
'name' => 'Bill',
'company' => 'Solaris')
);

// Store names by group index..
foreach($object_array as $i => $a) {
$sorted_array[$i] = $a['name'];
}

// Sort names and keep associated indicies..
asort($sorted_array);

// Store original groups on sorted indicies..
foreach($sorted_array as $i => $v) {
$sorted_object_array[$i] = $object_array[$i];
}

echo "";
print_r($sorted_object_array);
?>

Badda bing.

- Kevin


[PHP] Sort an array of objects

2003-10-01 Thread Matt Palermo
I have an array of object for files on my site.  The objects hold a file's
name, size, extension, etc...  I was wondering if anyone knows where I could
find a relatively easy function for sorting the array of these objects by
either name, size, etc...  Please let me know if got any tips.  Thanks a
lot!

Matt

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



Re: [PHP] regex drive me crazy

2003-10-01 Thread Curt Zirzow
* Thus wrote jonas_weber @ gmx. ch ([EMAIL PROTECTED]):
> Am Mittwoch, 01.10.03 um 22:27 Uhr schrieb Chris W. Parker:
> >Seeing as how you haven't had a response yet, I'll ask this: what
> >exactly is your question? I'm not sure as to what it is that you want.
> 
> My question are:
> a) Why does the PHP manual say that backslashes get escaped by writing 
> them twice while this causes an error in my example (see below)?

'\\' always gets translated to '\'  So the string:

'/(\\)/' translates to '/(\)/' which is an invalid regex, you'll
get a complaint about unclosed paren.

> b) Why does a different input (2.1. and 2.2.) result in the same output 
> (in the example I enclosed)?

try:
echo "beg \\ end\n";
echo "beg \ end\n";

Answer is also mentioned above.


> c) Why do I hate regular expressions so much?

perhaps because you're using them wrong.

> 
> Choose one.

I've answered all 5 of em so far.

> >1. The PHP manual sais to escape the escape char, it has to be written 
> >twice*, but:
> >$term = preg_replace('/(\\)/', 'backslash $1', $term);
> >causes an error** while using three backslashes (see 2.) works.
> >
> >2.1.
> >$term = "beg \ end";
> >print preg_replace('/(\\\)/', 'backslash $1', $term);
> >returns: beg backslash \ end
> >
> >2.2.
> >$term = "beg \\ end";
> >print preg_replace('/(\\\)/', 'backslash $1', $term);
> >returns: beg backslash \ end (the same as 2.1.)
> >
> >2.3.
> >$term = "beg \\\ end";
> >print preg_replace('/(\\\)/', 'backslash $1', $term);
> >returns: beg backslash \backslash \ end
> >
> >* http://www.php.net/manual/en/pcre.pattern.syntax.php
> >** "Warning: Compilation failed: missing ) at offset 3 in 
> >/home/jonas/public_html/test01.php on line 3"

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] OT(?): mod_rewrite not passing GET variables to php

2003-10-01 Thread Leif K-Brooks
Steven Jarvis wrote:

I'm just starting to experiment with mod_rewrite on Apache 1.3.x and 
php 4.3.3. Register_globals is off.

I have the following rules in my .htaccess file (which sits in the 
site's root dir along with paper.php):

RewriteEngine On
RewriteRule ^/([a-z]+)/([a-z]+)/$ paper.php?paper=$1§ion=$2 [L]
The browser gets served up paper.php, but I can't access the variables 
that should be in $1 and $2. They're supposed to be GET variables, right?

I've tried accessing them with $_GET["varname"] and 
$_REQUEST["varname"]  (and directly with $varname, even though 
register_globals is off), but I get nothing.

Can someone point out the (probably obvious) problem I'm having?

thanks,

Steven

Try this (I'm no mod_rewrite expert, so no promises):

RewriteEngine On
RewriteRule /^([a-z]+)\/([a-z]+)$/ paper.php?paper=$1§ion=$2 [L]
--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [Stats] PHP Net List Stats; September 2003

2003-10-01 Thread Bill Doerrfeld
Greetings:

For those of you curious to see the stats for usage of this list, 
please check out the following. You can create your own reports based 
on custom date ranges and search the archives via the URL below.

Enjoy!

--
Searchable archives for this list are available at

--
==
PHP Net List Stats
September, 2003
==
Note: Up/Down % as compared with August, 2003

Posts:   3142 (Up 23%)
Authors:  558 (Up  6%)
Threads:  809 (Up 16%)
Top 20 Contributors by Number of Posts
--
Curt Zirzow159
Jay Blanchard  126
Marek Kilimajer118
Robert Cummings 91
Raditha Dissanayake 80
Dan Anderson76
CPT John W. Holmes  66
Jason Wong  63
Chris Shiflett  61
John W. Holmes  55
Chris W. Parker 50
Ryan A  45
Eugene Lee  43
daniel  31
jsWalter30
Tom Rogers  29
Becoming Digital29
Jason Sheets29
Scott Fletcher  27
andu23
Top 20 Threads by Number of Posts
--
[PHP] PHP Editor - which to use?58
[PHP] PHP|Con insane pricing30
[PHP] non-php issue 27
[PHP] 3 mins of your time please...logic problem27
[PHP]  SQL statement25
[PHP] Cleaning up my messy code 23
[PHP] Integrating an Applet with PHP21
[PHP] Control Structure problem 19
[PHP] mysql.sock file location  19
[PHP] Session data getting lost 18
[PHP] Session var read by form C++ CGI prog ?   17
[PHP] loading classes and efficiency17
[PHP] Too Advanced?  Cookies & Hidden Image 16
[PHP] PHP coders spare time [OT}16
[PHP] arrays and php16
[PHP] Header won't redirect 15
[PHP] php|cruise15
[PHP] register_globals won't turn off!  15
[PHP] How to access a program outside of PHP?   14
[PHP] webhost --0T-->   14
Top 20 Search Terms by Number of Requests
--
wizard   3
apache   3
phplib   2
isset1
Lasso1
save 1
pdf  1
upload   1
mathe1
2.0  1
21
--
-
Bill Doerrfeld[EMAIL PROTECTED]
Blue World Communications, Inc.   http://www.blueworld.com/
-
 Build and serve powerful d

Re: [PHP] (another) regex difficulty

2003-10-01 Thread Curt Zirzow
* Thus wrote jonas_weber @ gmx. ch ([EMAIL PROTECTED]):
> 01.10.03 at 18:17 Curt Zirzow wrote:
> >preg_replace('/(? 
> 01.10.03 at 18:27 CPT John W. Holmes wrote:
> >$term = preg_replace('/[^\\]./','x',$term);
> 
> they don't work (thanks anyway)


the example below should turn any character exept "\*" (*= any
char) into an "x":


Besides that all mine needed was a extra \ 

$term = 'char \not xed';

preg_replace('/(? 
> it's pretty simple: i need a regex that matches any character in a 
> string except "\*" (* stands for any char that follows the "\").
> 
> example: "this is \ba test"
> should match: this a is test
> 
> isn't there a way to do this?

This is completly different problem. It isn't a matching issue but
a replacement issue.

preg_replace('/\\\.{1}/', '', $term);

You want to remove all \* characters.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] Plugin System Implementation

2003-10-01 Thread Eric Czarny
I am thinking about writing a content management system which allows 
user to use plugins written by other developers. It would allow me to 
easily update system functionality simply through creating and 
releasing plugins, as well as giving the user some power when it comes 
to using this system. However, I am faced with a problem... Which would 
be the best way to implement this design idea? I believe there is one 
way which I think could work but I need further insight upon this 
conjecture.

How about starting with a class, PluginManager, which would be 
responsible upon creation to scan a directory for plugins. These 
plugins would have to follow a distinct naming pattern to allow the 
manager to access the main class of the plugin. Suppose we have a 
directory, ../plugins/, which contains the plugins used by the system. 
Each of these plugins would need to be named after their primary class. 
For instance, SamplePlugin.php would contain a class SamplePlugin which 
the system would instantiate and utilize. The PluginManager would find 
this file, include it, and verify that it is a proper plugin.

Another important aspect of the plugin is that it must implement a 
protocol, or interface, that the system understands and takes advantage 
of to provide the link between system and plugin. I'm not sure how much 
power a plugin could be given or how much access to the system it could 
be granted but I am sure after some tests and examples I could figure 
out a way. There are a lot of holes in this design, but it's a place to 
start. I would like to be able to write plugins such as an XML-RPC 
interface, etc. Movable Type includes a plugin system which is used 
with HTML templates and output. I would also like to include this 
functionality. It's a rather complicated mess, come to think of it, but 
once I begin working on it or I get even clearer ideas from others will 
it begin to make sense.

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


[PHP] OT(?): mod_rewrite not passing GET variables to php

2003-10-01 Thread Steven Jarvis
I'm just starting to experiment with mod_rewrite on Apache 1.3.x and 
php 4.3.3. Register_globals is off.

I have the following rules in my .htaccess file (which sits in the 
site's root dir along with paper.php):

RewriteEngine On
RewriteRule ^/([a-z]+)/([a-z]+)/$ paper.php?paper=$1§ion=$2 [L]
The browser gets served up paper.php, but I can't access the variables 
that should be in $1 and $2. They're supposed to be GET variables, 
right?

I've tried accessing them with $_GET["varname"] and 
$_REQUEST["varname"]  (and directly with $varname, even though 
register_globals is off), but I get nothing.

Can someone point out the (probably obvious) problem I'm having?

thanks,

Steven

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


Re: [PHP] regex drive me crazy

2003-10-01 Thread jonas_weber
Am Mittwoch, 01.10.03 um 22:27 Uhr schrieb Chris W. Parker:
Seeing as how you haven't had a response yet, I'll ask this: what
exactly is your question? I'm not sure as to what it is that you want.
My question are:
a) Why does the PHP manual say that backslashes get escaped by writing 
them twice while this causes an error in my example (see below)?
b) Why does a different input (2.1. and 2.2.) result in the same output 
(in the example I enclosed)?
c) Why do I hate regular expressions so much?

Choose one.

- Jns

8<
1. The PHP manual sais to escape the escape char, it has to be written 
twice*, but:
$term = preg_replace('/(\\)/', 'backslash $1', $term);
causes an error** while using three backslashes (see 2.) works.

2.1.
$term = "beg \ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \ end
2.2.
$term = "beg \\ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \ end (the same as 2.1.)
2.3.
$term = "beg \\\ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \backslash \ end
* http://www.php.net/manual/en/pcre.pattern.syntax.php
** "Warning: Compilation failed: missing ) at offset 3 in 
/home/jonas/public_html/test01.php on line 3"
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP OOP

2003-10-01 Thread Raquel Rice
On Tue, 30 Sep 2003 19:00:18 -0400
"Geoff Hellstrand" <[EMAIL PROTECTED]> wrote:

> I'm working for the first time with object orientated programming
> in php and I can't figure out how to access elements or methods
> when you place objects inside objects inside other objects.
> 
> my origonal idea was to  use the following syntax:
> $a->b->c
> but this just returns:
> $a->b  . "->c"
> 
> Please, need advice on the finer points of OOP in PHP
> 

$a->$b->$c->method();

--
Raquel

We must learn to live together as brothers or perish together as
fools.
  --Martin Luther King, Jr.

--
Raquel

We must learn to live together as brothers or perish together as
fools.
  --Martin Luther King, Jr.

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



RE: [PHP] PHP OOP

2003-10-01 Thread Daniel Purdy
[snip]I'm working for the first time with object orientated programming
in php and I can't figure out how to access elements or methods when you
place objects inside objects inside other objects.

my origonal idea was to  use the following syntax:
$a->b->c
but this just returns:
$a->b  . "->c"

Please, need advice on the finer points of OOP in PHP
[/snip]

Here is a link to an article that helped get me started on oop in php
http://www.phpbuilder.com/columns/luis2420.php3

Daniel

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



[PHP] PHP OOP

2003-10-01 Thread Geoff Hellstrand
I'm working for the first time with object orientated programming in php and
I can't figure out how to access elements or methods when you place objects
inside objects inside other objects.

my origonal idea was to  use the following syntax:
$a->b->c
but this just returns:
$a->b  . "->c"

Please, need advice on the finer points of OOP in PHP

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



Re: [PHP] Read a PDF File using php

2003-10-01 Thread Kevin Stone


Launching this script will prompt a file download screen if the Acrobat Reader Plugin 
is not available on the client browser.  Otherwise it will display inside the browser 
window using the plugin.

Hope that helps.

- Kevin


"Pushpinder Singh Garcha" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> No I am not sending any headers to the browser. Any suggestions !
> 
> Thanks
> 
> On Wednesday, October 1, 2003, at 04:05 PM, Tyler Lane wrote:
> 
> >
> > Are you sending a Content-Type header to the browser to let it know 
> > what
> > type of file you are sending it?


Re: [PHP] Variables not passed on localhost setup [FIXED]

2003-10-01 Thread Chris
On Wed, 01 Oct 2003 14:22:30 -0400, Greg Watson <[EMAIL PROTECTED]> 
wrote:

I'll check up on the security implications. Unfortunately for me, this
is the way I was taught PHP. I'll have to rethink things I suppose!
(and make sure you understand the security implications that may arise 
from
having globals on and poorly written code)

It would be best if you *do* get used to registered globals being off.  
It's gotten so that I can't even download premade PHP scripts anymore 
because 2 of the 3 webservers I work on have it turned off.  It's not fun 
having to sort through other people's code and making it work with 
registered globals being off (extract() is the easiest way, but I still 
have to sort through which include needs it).  It ends up being almost as 
much work as building a new one from scratch.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] regex drive me crazy

2003-10-01 Thread Chris W. Parker
[EMAIL PROTECTED] 
on Wednesday, October 01, 2003 1:02 PM said:

> Does this make ANY sense?

Seeing as how you haven't had a response yet, I'll ask this: what
exactly is your question? I'm not sure as to what it is that you want.



c.

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



[PHP] mail(): can it reply with quoted text?

2003-10-01 Thread Chris
I wrote an ultra basic mail interface as a part of my client's customer 
administration area to handle emails.  Basically, the standard email form 
gets stored in a database, and when they respond to the help request, they 
fill out the form and PHP emails the message.

Now, they want to have the original email appear as a part of their 
reply.  I could use wordwrap() at around 70 characters and have every line 
appear with the traditional '>' to indicate the replied text.  It doesn't 
seem to be a very elegant solution for mail clients that reflow quoted 
text (not certain how to explain this, but Opera's mail client does it).

Is there a way to for mail() to include quoted text like it was actually 
replying to an actual mail client would?

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Chris Shiflett
--- Nicole <[EMAIL PROTECTED]> wrote:
> Originally, I used pconnect for a while. Then I learned that with
> high traffic site, that's not the best idea.

Where did you learn this? I disagree with that notion.

I manage a Web site that serves 10 million hits a day, and if I didn't use
persistent connections (in addition to avoiding database queries whenever
possible), my servers would never survive.

Chris

=
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
My Blog
 http://shiflett.org/

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Chris Shiflett
--- Nicole <[EMAIL PROTECTED]> wrote:
> I run Apache with PHP and MySQL [snip]
> 
> I last increased my max connections to 500. That seemed to fix things
> for a while. Now I am getting the problems (database freezing up
> because too many connections) again. The site I run is pretty high
> traffic.

This has nothing to do with traffic (other than the fact that heavy traffic can
reveal configuration problems more easily).

Are you using persistent connections (mysql_pconnect)? If so, you need to make
sure you have MySQL maximum connections (max_connections in my.cnf) set to a
number that is higher than Apache's MaxClients directive (in httpd.conf). If
you have MaxClients at 512, for example, and MySQL only allows a maximum of 500
connections, you're likely to run into the "too many connections" problems once
your traffic pushes the number of Apache clients past 500.

Hope that helps.

Chris

=
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
My Blog
 http://shiflett.org/

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



Re: [PHP] Read a PDF File using php

2003-10-01 Thread Pushpinder Singh Garcha
No I am not sending any headers to the browser. Any suggestions !

Thanks

On Wednesday, October 1, 2003, at 04:05 PM, Tyler Lane wrote:

Are you sending a Content-Type header to the browser to let it know 
what
type of file you are sending it?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Read a PDF File using php

2003-10-01 Thread Tyler Lane
Are you sending a Content-Type header to the browser to let it know what
type of file you are sending it?


On Wed, 2003-10-01 at 12:27, Pushpinder Singh Garcha wrote:
> Hello All
> 
> I need to allow a user to access a PDF file, only if he/she is logged 
> in as a registered user. So here is the code that I am trying to use. I 
> have been able to make this work in the past, when I had to read .html 
> file, now since the file in question is a .pdf file, I am having 
> trouble. The browser shows a long list of weird characters instead of 
> the pdf file
> 
> 
> if(session_is_registered("user_valid")){
>   
> $filepath ="docs/any_file.pdf";
-- 
Tyler Lane <[EMAIL PROTECTED]>
Lyrical Communications

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



[PHP] regex drive me crazy

2003-10-01 Thread jonas_weber
1. The PHP manual sais to escape the escape char, it has to be written 
twice*, but:
$term = preg_replace('/(\\)/', 'backslash $1', $term);
causes an error** while using three backslashes (see 2.) works.

2.1.
$term = "beg \ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \ end
2.2.
$term = "beg \\ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \ end (the same as 2.1.)
2.3.
$term = "beg \\\ end";
print preg_replace('/(\\\)/', 'backslash $1', $term);
returns: beg backslash \backslash \ end
Does this make ANY sense?

- jns

* http://www.php.net/manual/en/pcre.pattern.syntax.php
** "Warning: Compilation failed: missing ) at offset 3 in 
/home/jonas/public_html/test01.php on line 3"



Am Mittwoch, 01.10.03 um 19:14 Uhr schrieb CPT John W. Holmes:
Regular expressions are for "pattern matching"... not matching 
everything
BUT a pattern.
good point! ;)

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


RE: [PHP] printf....

2003-10-01 Thread Dan Joseph
OH!  Heh...  learn something new everyday..  Thank you!

-Dan Joseph

> -Original Message-
> From: Mike Migurski [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 01, 2003 3:49 PM
> To: Dan Joseph
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] printf
> 
> 
> >Warning: printf(): too few arguments in
> >/home/sites/site8/web/index_test.php on line 34
> >
> >I cannot for the life of me figure out what the problem is.  I've looked
> >thru archives, examples, and pages of a book all about printf, and this
> >just doesn't add up to me..  Anyone see the problem?
> 
> To print a literal '%' (as in '100%'), you need to escape it with another
> '%' (as in '100%%').
> 
> -
> 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] printf....

2003-10-01 Thread Chris Sherwood
well for starters dan I would pass the first element as a string variable
that way I could echo the string and see what it actually says ie

$stringtopass = " ";

$stringtopass .=" ";

$stringtopass .="  ";

$stringtopass .=" Search
";

$stringtopass .="  by
Borrower";

$stringtopass .=" ";

$stringtopass .="   by
Loan Number";

$stringtopass .=" ";

$stringtopass .= " 
";

$stringtopass .="  
";

$stringtopass .=" ";

what I cant figure out is why your trying to print the serverinfo
($_SERVER['PHP_SELF'])

as the second part is the arguements section ie
printf("hi my name is %s and your name is %s", $myname, $yourname);

maybe you want to use echo if you want it displayed on screen

Chris

<-- SNIP -->
From: "Dan Joseph" <[EMAIL PROTECTED]>

> Hi Folks..
>
> printf ("
> 
> 
>
> 
>
> 
> 
>
> 
>  bgcolor=#003366>
> Search
> 
> 
> by Borrower
>  type=checkbox name=borrower value=1>
> 
> 
> by Loan
> Number
>  type=checkbox name=loan_number value=1 checked>
> 
> 
>  type=text name=search_info style=\"width=100%;\">
> 
> 
>  type=submit value=\"SEARCH\">
> 
> 
> 
>
> 
> ", $_SERVER['PHP_SELF']
> );
>
> I have that code, and I get this error:
>
> Warning: printf(): too few arguments in
/home/sites/site8/web/index_test.php
> on line 34
>
> I cannot for the life of me figure out what the problem is.  I've looked
> thru archives, examples, and pages of a book all about printf, and this
just
> doesn't add up to me..  Anyone see the problem?
<-- snip -->

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Nicole
Originally, I used pconnect for a while. Then I learned that with high
traffic site, that's not the best idea. So I changed to 'connect.' But I
still get the problems.

Nicole
aeontrek.com


"Brad Pauly" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Nicole wrote:
>
> > I last increased my max connections to 500. That seemed to fix things
for a
> > while. Now I am getting the problems (database freezing up because too
many
> > connections) again. The site I run is pretty high traffic.
> >
> > I wondered if anyone encountered a solution to handle this sort of
problem.
>
> Are you using mysql_connect or mysql_pconnect?
>
> - Brad

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



Re: [PHP] printf....

2003-10-01 Thread Mike Migurski
>Warning: printf(): too few arguments in
>/home/sites/site8/web/index_test.php on line 34
>
>I cannot for the life of me figure out what the problem is.  I've looked
>thru archives, examples, and pages of a book all about printf, and this
>just doesn't add up to me..  Anyone see the problem?

To print a literal '%' (as in '100%'), you need to escape it with another
'%' (as in '100%%').

-
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] "Too many connections" fix?

2003-10-01 Thread Brad Pauly
Brad Pauly wrote:
Nicole wrote:

I last increased my max connections to 500. That seemed to fix things 
for a
while. Now I am getting the problems (database freezing up because too 
many
connections) again. The site I run is pretty high traffic.

I wondered if anyone encountered a solution to handle this sort of 
problem.


Are you using mysql_connect or mysql_pconnect?
The reason I ask is that some people have problems with mysql_pconnect.

- Brad

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


[PHP] Re: (another) regex difficulty

2003-10-01 Thread Cristian Lavaque
Jonas_weber @ Gmx . Ch wrote:
> regular expressions
> the example below should turn any character exept "\*" (*= any char)
> into an "x":
>
> $term = preg_replace('/[^(\\\)+(.){1}]/', 'x', $term);
>
> but i guess because of the [brackets] the "." (period) is treated as
> character "." instead as metacharacter (that matches any char).

I'm new to regex too, but if you want to match anything that's not an *,
couldn't it be done like this?

$term = preg_replace('/[^\*\s]*/', 'x', $term);

I put the \s there to skip the whitespace characters too. I haven't tested,
but I hope it helps.

Cristian

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



[PHP] printf....

2003-10-01 Thread Dan Joseph
Hi Folks..

printf ("










Search


by Borrower



by Loan
Number












", $_SERVER['PHP_SELF']
);

I have that code, and I get this error:

Warning: printf(): too few arguments in /home/sites/site8/web/index_test.php
on line 34

I cannot for the life of me figure out what the problem is.  I've looked
thru archives, examples, and pages of a book all about printf, and this just
doesn't add up to me..  Anyone see the problem?

-Dan Joseph

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



Re: [PHP] "Too many connections" fix?

2003-10-01 Thread Brad Pauly
Nicole wrote:

I last increased my max connections to 500. That seemed to fix things for a
while. Now I am getting the problems (database freezing up because too many
connections) again. The site I run is pretty high traffic.
I wondered if anyone encountered a solution to handle this sort of problem.
Are you using mysql_connect or mysql_pconnect?

- Brad

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


[PHP] What's the difference ?

2003-10-01 Thread X-Virus
What's the difference between :

$_SERVER["COMPUTERNAME"] and $_ENV["COMPUTERNAME"] ?

[PHP] "Too many connections" fix?

2003-10-01 Thread Nicole
Hello,

I run Apache with PHP and MySQL on a RedHat 7.2 box with 1GB Ram @ 2GHZ
(p4).

I last increased my max connections to 500. That seemed to fix things for a
while. Now I am getting the problems (database freezing up because too many
connections) again. The site I run is pretty high traffic.

I wondered if anyone encountered a solution to handle this sort of problem.

TIA!
--
Nicole
aeontrek.com

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



[PHP] Portability of Php across Solaris systems

2003-10-01 Thread Donahue, Peter

I successfully built Php 4.3.3 on Solaris for apache with ora8 support.
I noticed that the .reg files in php/lib/.registry have hardcoded
pathnames to the php files.
I want to be able to take the php files (along with the apache files)
and install them on a different Solaris system, possibly in a different
directory.
Will I be able to do this, or will the hardcoded paths prevent this?

I haven't seen anything in the php.ini file that appears to help here.

Thanks

Peter

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



Re: [PHP] Read a PDF File using php

2003-10-01 Thread Chris Sherwood
http://ca.php.net/manual/en/ref.pdf.php

check this out you should find what you need
<-- snip -->
From: "Pushpinder Singh Garcha" <[EMAIL PROTECTED]>

I need to allow a user to access a PDF file, only if he/she is logged 
in as a registered user. So here is the code that I am trying to use. I 
have been able to make this work in the past, when I had to read .html 
file, now since the file in question is a .pdf file, I am having 
trouble. The browser shows a long list of weird characters instead of 
the pdf file

<-- snip-->

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



[PHP] Read a PDF File using php

2003-10-01 Thread Pushpinder Singh Garcha
Hello All

I need to allow a user to access a PDF file, only if he/she is logged 
in as a registered user. So here is the code that I am trying to use. I 
have been able to make this work in the past, when I had to read .html 
file, now since the file in question is a .pdf file, I am having 
trouble. The browser shows a long list of weird characters instead of 
the pdf file

if(session_is_registered("user_valid")){

$filepath ="docs/any_file.pdf";
 $h1 = @fopen($filepath,"r");
  
  while (!feof($h1)) {
$a = fread($h1,4096);
echo "$a";
}
    }
Any ideas / suggestions would be welcome. Thanks in advance

Pushpinder




Re: [PHP] Session_start() problem

2003-10-01 Thread CPT John W. Holmes
From: "Jeff McKeon" <[EMAIL PROTECTED]>
[snip]
> where do I set the default location for session data?

session.save_path in php.ini

---John Holmes...

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



Re: [PHP] Mail.php help

2003-10-01 Thread Eugene Lee
On Thu, Oct 02, 2003 at 02:23:44AM +0800, Jason Wong wrote:
: On Thursday 02 October 2003 01:28, Eugene Lee wrote:
: > On Wed, Oct 01, 2003 at 08:31:49AM -0700, Eric Rounds wrote:
: > :
: > : By the way, is there a way I can check, without looking into the
: > : serving Mac, to see if it is running?
: >
: > The only way to be is to log into the Mac and check for a process that
: > looks like "/usr/sbin/sendmail -C /etc/mail/submit.cf -q1h".
: 
: No idea whether it's different for OS X, but under, say Linux, PHP calls the 
: sendmail *binary*, thus you do not need the sendmail daemon running.

Doesn't matter.  Same problem.  PHP sends emails by submitting messages
to the Sendmail MTA.  If Sendmail itself is not running, it will not
deliver your message to the next-hop MTA.

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-01 Thread Gerard Samuel
Eugene Lee wrote:

On Wed, Oct 01, 2003 at 02:02:08PM -0400, Gerard Samuel wrote:
: CPT John W. Holmes wrote:
: >From: "Eugene Lee" <[EMAIL PROTECTED]>
: >>On Wed, Oct 01, 2003 at 01:12:16AM -0400, Gerard Samuel wrote:
: >>:
: >>: Got a problem with htmlspecialchars being too greedy, where
: >>: for example, it converts
: >>: &foo;
: >>: to
: >>: &foo;
[...]
: >>: $foo = '中文 & http://www.foo.com/index.php?foo=1&bar=2';
: >>
: >>The problem isn't with htmlspecialchars().  It doesn't know what parts
: >>of the string are HTML character references and which parts are not.
: >>But if you're willing to dig up the numeric character references for
: >>those specific Chinese characters, then split the string into the part
: >>that needs no translation and the part that needs it.  That is:
: >>
: >>$foo1encoded = '中文'
: >>$foo2raw = ' & http://www.foo.com/index.php?foo=1&bar=2';
: >>$foo = $foo1 . htmlspecialchars(foo2raw);
: >
: >Maybe you should run html_entity_decode() on the string first, then run
: >encode again. The decode will take 中 and turn it into it's actual
: >character but not affect anything else. Then the recoding will turn it back
: >into 中 and also encode any other characters.
: 
: Eugene, your example leads me to believe that one knows before hand
: what characters needs special attention, in order to not run it
: through htmlspecialchars.  I would never know what characters needs
: special attention.

But it seems that you do know what characters need to be converted,
because you included the exact Unicode character references for those
Chinese characters.  You have to know your data.  Or modify your code
with specific assumptions about the data.
For example, let's say I have a string that I got from somewhere
(database, user form, text file, another web site, etc.):
	$foo = 'Dick & Jane';

When you eventually display this to someone's web browser, what do you
want them to see?
Dick & Jane
or
Dick & Jane
This really depends on the format of the data inside $foo.  Is '&'
a character reference that you want to leave alone?  Or is it a literal
string that you want to convert to '&' for display?  And the
only person that knows the format of the data is you.  Again, you have
to know your data.
When I say that I don't know what characters Im expecting.
Im not talking about normal html entities, like &   <
Im talking about chinese/japanese/korean/taiwanese alphabet, numbers 
(even punctuation if applicable).
Maybe Im thinking too hard, but trying to take far east languages 
alphanumeric charaters into account,
seems like overkill.
Feel free to correct me.

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


[PHP] Session_start() problem

2003-10-01 Thread Jeff McKeon
Hey all, I'm working out of a book teaching myself PHP4 here and I've
got this code from a login web page...

[begin code]
session_start();
if(!isset($userid)) {
login_form();
exit;
}
else {
session_regisister("userid", "userpassword");
if(!$username) {
session_unregister("userid");
session_unregister("userpassword");
echo "Authorization failed. " . 
 "You must enter a valid userid and password
combo. " .
 "Click on teh following link to try
again.\n";
echo "login";
echo "If you do not have login, please contact
Operations to obtain one.\n";
exit;
}
else echo "welcome, $username!";
}
[end code]

The page puts up a for with fields for username, password etc. nothing
crazy, but when I open the page I get the following error displayed
(before data is entered into the form and subitted).

[begin error]
PHP Warning: session_start():
open(/tmp\sess_d7d909aa6e85cf5489a50f6e42f03b12, O_RDWR) failed: No such
file or directory (2) in c:\inetpub\wwwroot\auth_user.php on line 54 PHP
Warning: Unknown(): open(/tmp\sess_d7d909aa6e85cf5489a50f6e42f03b12,
O_RDWR) failed: No such file or directory (2) in Unknown on line 0 PHP
Warning: Unknown(): Failed to write session data (files). Please verify
that the current setting of session.save_path is correct (/tmp) in
Unknown on line 0 
[end error]

Not sure what I did wrong except to think that PHP is trying to write
the session id file to a directory that doesn't exist "/tmp."  This is
running on a MS IIS server.  If I'm correct in my assessment, where do I
set the default location for session data?

Thanks,

Jeff

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 02:02:08PM -0400, Gerard Samuel wrote:
: CPT John W. Holmes wrote:
: >From: "Eugene Lee" <[EMAIL PROTECTED]>
: >>On Wed, Oct 01, 2003 at 01:12:16AM -0400, Gerard Samuel wrote:
: >>:
: >>: Got a problem with htmlspecialchars being too greedy, where
: >>: for example, it converts
: >>: &foo;
: >>: to
: >>: &foo;
[...]
: >>: $foo = '中文 & http://www.foo.com/index.php?foo=1&bar=2';
: >>
: >>The problem isn't with htmlspecialchars().  It doesn't know what parts
: >>of the string are HTML character references and which parts are not.
: >>But if you're willing to dig up the numeric character references for
: >>those specific Chinese characters, then split the string into the part
: >>that needs no translation and the part that needs it.  That is:
: >>
: >>$foo1encoded = '中文'
: >>$foo2raw = ' & http://www.foo.com/index.php?foo=1&bar=2';
: >>$foo = $foo1 . htmlspecialchars(foo2raw);
: >
: >Maybe you should run html_entity_decode() on the string first, then run
: >encode again. The decode will take 中 and turn it into it's actual
: >character but not affect anything else. Then the recoding will turn it back
: >into 中 and also encode any other characters.
: 
: Eugene, your example leads me to believe that one knows before hand
: what characters needs special attention, in order to not run it
: through htmlspecialchars.  I would never know what characters needs
: special attention.

But it seems that you do know what characters need to be converted,
because you included the exact Unicode character references for those
Chinese characters.  You have to know your data.  Or modify your code
with specific assumptions about the data.

For example, let's say I have a string that I got from somewhere
(database, user form, text file, another web site, etc.):

$foo = 'Dick & Jane';

When you eventually display this to someone's web browser, what do you
want them to see?

Dick & Jane
or
Dick & Jane

This really depends on the format of the data inside $foo.  Is '&'
a character reference that you want to leave alone?  Or is it a literal
string that you want to convert to '&' for display?  And the
only person that knows the format of the data is you.  Again, you have
to know your data.

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



  1   2   3   >