RE: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Murray @ PlanetThoughtful
I don't understand why you have the 'Weight_kg = "6"' clause in your WHERE
statement?

Aren't you attempting to return one of the zone values depending on a value
that falls between range and weight_kg?

Let's say, for example, that the value you're searching for is .45. The
following statement would correctly return the record below:

SELECT * FROM rates_dhl WHERE .45 BETWEEN range AND Weight_KG

In your PHP code, you'd probably use a variable when building the SQL
statement.

Something like:



This is assuming range and Weight_KG are both decimals in your db, rather
than VARCHARS etc.

It may be that I've misunderstood what you're attempting to do.

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.


> -Original Message-
> From: Louie Miranda [mailto:[EMAIL PROTECTED]
> Sent: Friday, 5 November 2004 4:06 PM
> To: Murray @ PlanetThoughtful; [EMAIL PROTECTED]
> Subject: Re: [PHP] getting a number range from user input.. (weight)
> 
> I have this on my db.
> 
> mysql> select * from rates_dhl where weight_kg = "6" between range and
> Weight_KG;
> ++---+---++++++---
> -+++
> | id | range | Weight_KG | Zone_A | Zone_B | Zone_C | Zone_D | Zone_E
> | Zone_F | Zone_G | Zone_H |
> ++---+---++++++---
> -+++
> |  1 | .000  | .5| 9.45   | 12.29  | 14.18  | 15.12  | 16.59
> | 18.48  | 21.32  | 23.63  |
> ++---+---++++++---
> -+++
> 1 row in set (0.00 sec)
> 
> When i did try the between, even when i try to change the weight_kg to
> any number, it only display the first entry.
> 
> 
> On Fri, 5 Nov 2004 15:52:16 +1000, Murray @ PlanetThoughtful
> <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > OK, here is what it should do.
> > >
> > > I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
> > > each weight it has a succeeding value, i cannot jump or just round off
> > > the numbers. So i need a range detector to do it.
> > >
> > > Because for each of the item below:
> > >
> > > > weight   value
> > > > .59.45
> > > > 1.0 10.71
> > > > 1.5 11.97
> > > > 2.0 13.23
> > >
> > > I must get the exact value, so let say for example. I have 1.3 it
> > > should fall under 1.5 the idea i had was to do this, so i can detect
> > > where the number should fall..
> >
> > Put the weight ranges in a MySQL table and use the BETWEEN operator to
> > retrieve the appropriate weight.
> >
> > Something like:
> >
> > fromweight, toweight, value
> > 0,0.5,9.45
> > 0.501,1.0,10.71
> > 1.001,1.5,11.97
> >
> > Then, the following SQL statement will pull the appropriate value:
> >
> > SELECT value FROM weights WHERE 1.3 BETWEEN fromweight AND toweight
> >
> > Much warmth,
> >
> > Murray
> > http://www.planetthoughtful.org
> > Building a thoughtful planet,
> > One quirky comment at a time.
> >
> > --
> >
> >
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> --
> Louie Miranda
> http://www.axishift.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



Re: [PHP] PHP5 syntax question

2004-11-04 Thread Thomas Goyne
On Fri, 05 Nov 2004 09:19:58 +0200, Simas Toleikis <[EMAIL PROTECTED]>  
wrote:

I think PHP5 docs are not full yet. Wasnt there supposed to be  
namespaces in PHP5? PHP documentation doesnt even mentions them...
No, they were cut, and it is highly doubtful they will show up any time  
before php6.

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


Re: [PHP] PHP5 syntax question

2004-11-04 Thread Simas Toleikis
Gerard Samuel wrote:
I dont see it in the documentation, but I've seen samples of code using
something to the effect of ->
$foo->method1()->method2()

It's called object dereferencing and its not implemented in PHP4. It is 
avalaible in PHP5.
If method1() returns an instance of some object then the returned object 
method2() will be called.

I think PHP5 docs are not full yet. Wasnt there supposed to be 
namespaces in PHP5? PHP documentation doesnt even mentions them...

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


RE: [PHP] Reservation technique

2004-11-04 Thread Roger Thomas
Yes. I flipped thru the manpages and found:
expr BETWEEN min AND max
If expr is greater than or equal to min and expr is less than or equal to max, 
BETWEEN returns 1, otherwise it returns 0. This is equivalent to the expression (min 
<= expr AND expr <= max) if all the arguments are of the same type.

Thanks again.

--
roger


Quoting "Murray @ PlanetThoughtful" <[EMAIL PROTECTED]>:

> 
> > Great! Thanks Murray.
> 
> Hi Roger,
> 
> On second thoughts, perhaps the BETWEEN operator isn't what you're looking
> for, since it will probably return false matches on bordering reservations.
> 
> In other words, someone attempting to make a reservation between 10am and
> 12pm might be told there's a conflicting reservation if there is already a
> reservation for between, for example, 12pm and 2pm on the same day. The end
> time of 12pm on the new reservation will return a match for the start time
> of 12pm on the existing reservation using the BETWEEN operator.
> 
> As an alternative, you might try something like:
> 
> SELECT * FROM reservation_table WHERE (new_start_datetime >
> reservation_start_datetime AND new_start_datetime <
> reservation_end_datetime) OR (new_end_datetime > reservation_start_datetime
> AND new_end_datetime < reservation_end_datetime)
> 
> This should exclude false matches on bordering reservations.
> 
> Much warmth,
> 
> Murray
> http://www.planetthoughtful.org
> Building a thoughtful planet,
> One quirky comment at a time.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 





---
Sign Up for free Email at http://ureg.home.net.my/
---

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



Re: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Louie Miranda
I have this on my db.

mysql> select * from rates_dhl where weight_kg = "6" between range and
Weight_KG;
++---+---+++++++++
| id | range | Weight_KG | Zone_A | Zone_B | Zone_C | Zone_D | Zone_E
| Zone_F | Zone_G | Zone_H |
++---+---+++++++++
|  1 | .000  | .5| 9.45   | 12.29  | 14.18  | 15.12  | 16.59 
| 18.48  | 21.32  | 23.63  |
++---+---+++++++++
1 row in set (0.00 sec)

When i did try the between, even when i try to change the weight_kg to
any number, it only display the first entry.


On Fri, 5 Nov 2004 15:52:16 +1000, Murray @ PlanetThoughtful
<[EMAIL PROTECTED]> wrote:
> 
> 
> 
> > OK, here is what it should do.
> >
> > I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
> > each weight it has a succeeding value, i cannot jump or just round off
> > the numbers. So i need a range detector to do it.
> >
> > Because for each of the item below:
> >
> > > weight   value
> > > .59.45
> > > 1.0 10.71
> > > 1.5 11.97
> > > 2.0 13.23
> >
> > I must get the exact value, so let say for example. I have 1.3 it
> > should fall under 1.5 the idea i had was to do this, so i can detect
> > where the number should fall..
> 
> Put the weight ranges in a MySQL table and use the BETWEEN operator to
> retrieve the appropriate weight.
> 
> Something like:
> 
> fromweight, toweight, value
> 0,0.5,9.45
> 0.501,1.0,10.71
> 1.001,1.5,11.97
> 
> Then, the following SQL statement will pull the appropriate value:
> 
> SELECT value FROM weights WHERE 1.3 BETWEEN fromweight AND toweight
> 
> Much warmth,
> 
> Murray
> http://www.planetthoughtful.org
> Building a thoughtful planet,
> One quirky comment at a time.
> 
> --
> 
> 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Louie Miranda
http://www.axishift.com

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



RE: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Murray @ PlanetThoughtful

> OK, here is what it should do.
> 
> I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
> each weight it has a succeeding value, i cannot jump or just round off
> the numbers. So i need a range detector to do it.
> 
> Because for each of the item below:
> 
> > weight   value
> > .59.45
> > 1.0 10.71
> > 1.5 11.97
> > 2.0 13.23
> 
> I must get the exact value, so let say for example. I have 1.3 it
> should fall under 1.5 the idea i had was to do this, so i can detect
> where the number should fall..

Put the weight ranges in a MySQL table and use the BETWEEN operator to
retrieve the appropriate weight.

Something like:

fromweight, toweight, value
0,0.5,9.45
0.501,1.0,10.71
1.001,1.5,11.97

Then, the following SQL statement will pull the appropriate value:

SELECT value FROM weights WHERE 1.3 BETWEEN fromweight AND toweight


Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.

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



Re: [PHP] $_SERVER['HTTP_REFERER'] does not work

2004-11-04 Thread Jason Wong
On Friday 05 November 2004 01:13, Michelle Konzack wrote:

[snip]

> Then I have the same problem with
>
> echo $_SERVER['SERVER_NAME'];
>
> which tell me every time the "ServerName" but not the public
> "ServerAlias".
>
> WHY ?

Look up "UseCanonicalName" in the Apache docs and see if this relates to your 
problem.

> Does anyone have an example, which I can put at the beginning
> of my Web-Pages which allow or deny access to the HTML-Page ?
>
> I need to protect my php-Scripts, because I have had already
> a DoS by calling my php-scripts several tenthousandth times.

The surest way to prevent unauthorised access is to require a login.

-- 
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
--
/*
Nature is by and large to be found out of doors, a location where,
it cannot be argued, there are never enough comfortable chairs.
  -- Fran Lebowitz
*/

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



Re: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Louie Miranda
Im thingking of putting the fixed value into an array and compare thru
< and > and get the fixed rate.


On Fri, 05 Nov 2004 14:38:17 +1100, Devraj Mukherjee
<[EMAIL PROTECTED]> wrote:
> Well, I dont know if there is a function that can do this in PHP, but
> you could always split the number using the dot, and then compare the
> number that follows to make the decision.
> 
> (I am sure you knew that)
> 
> Devarj
> 
> 
> 
> 
> Louie Miranda wrote:
> > OK, here is what it should do.
> >
> > I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
> > each weight it has a succeeding value, i cannot jump or just round off
> > the numbers. So i need a range detector to do it.
> >
> > Because for each of the item below:
> >
> >
> >>weight   value
> >>.59.45
> >>1.0 10.71
> >>1.5 11.97
> >>2.0 13.23
> >
> >
> > I must get the exact value, so let say for example. I have 1.3 it
> > should fall under 1.5 the idea i had was to do this, so i can detect
> > where the number should fall..
> >
> > range:
> > . => .5
> > 1.001 => 1
> > 1.501 => 2
> > 2.001 => 2.5
> > 2.501 => 3
> > 3.001 => 3.5
> >
> > and so on..
> >
> > But i dont know how to do this on PHP
> >
> > Louie
> >
> > On Thu, 4 Nov 2004 20:23:53 -0700, Vail, Warren <[EMAIL PROTECTED]> wrote:
> >
> >>Not sure I completely understand what you are trying to do.  In your
> >>problem, seems to me that both 1.3 and 1.6 would fall under 2.0 and neither
> >>of them would fall under 1.0.  You must be using some logic that I am not
> >>getting.  Can you be a little more specific?
> >>
> >>Warren Vail
> >>
> >>
> >>
> >>
> >>-Original Message-
> >>From: Louie Miranda [mailto:[EMAIL PROTECTED]
> >>Sent: Thursday, November 04, 2004 7:09 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: [PHP] getting a number range from user input.. (weight)
> >>
> >>How can i match a range of numbers from a given input?
> >>i tried round() but it rounds off the numbers to the next number, so that
> >>will be wrong.
> >>
> >>My example below show 4 examples of what my db tables looks like.
> >>
> >>weight   value
> >>.59.45
> >>1.0 10.71
> >>1.5 11.97
> >>2.0 13.23
> >>
> >>How can i get the range of:
> >>
> >>.1 to fall under .5 and
> >>1.3 to fall under 1.0 and
> >>1.6 to fall under 2.0
> >>
> >>and so on.. any ideas?
> >>
> >>--
> >>Louie Miranda
> >>http://www.axishift.com
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> >
> 
> -- 
> --
> Devraj Mukherjee, Eternity Technologies Pty. Ltd. Australia
> Host: Debian (Sarge) 3.1 Kernel 2.4.27-1-686 / GCC version 3.3.5
> Target: LPD7A400 (ARM9) LogicPD eval. board / ARM GCC 3.3 GlibC 2.3.2
> LAMP environment specs. Apache: 2.0.52 PHP: 5 MySQL: 4.0.21
> --
> 


-- 
Louie Miranda
http://www.axishift.com

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



[PHP] PHP5 syntax question

2004-11-04 Thread Gerard Samuel
I dont see it in the documentation, but I've seen samples of code using
something to the effect of ->
$foo->method1()->method2()
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Reservation technique

2004-11-04 Thread Murray @ PlanetThoughtful
> Great! Thanks Murray.

Hi Roger,

On second thoughts, perhaps the BETWEEN operator isn't what you're looking
for, since it will probably return false matches on bordering reservations.

In other words, someone attempting to make a reservation between 10am and
12pm might be told there's a conflicting reservation if there is already a
reservation for between, for example, 12pm and 2pm on the same day. The end
time of 12pm on the new reservation will return a match for the start time
of 12pm on the existing reservation using the BETWEEN operator.

As an alternative, you might try something like:

SELECT * FROM reservation_table WHERE (new_start_datetime >
reservation_start_datetime AND new_start_datetime <
reservation_end_datetime) OR (new_end_datetime > reservation_start_datetime
AND new_end_datetime < reservation_end_datetime)

This should exclude false matches on bordering reservations.

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.

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



RE: [PHP] Reservation technique

2004-11-04 Thread Roger Thomas
Great! Thanks Murray. 

--
roger

Quoting "Murray @ PlanetThoughtful" <[EMAIL PROTECTED]>:

> 
> > How will a PHP script perform such checking to prevent that sort of
> > overlapping in reservation ? Or could it be that my database design is bad
> > that's blocking ideas into my head ?
> 
> Hi Roger,
> 
> I think you need to check out the BETWEEN operator in MySQL (assuming you're
> using MySQL? Look for the equivalent operator in whatever db platform you're
> using, if otherwise). Essentially what you're looking to do is find out if
> either the start time or the end time of the new booking falls BETWEEN the
> start time or the end time of an existing booking. If either of them does,
> it's safe to assume there's a booking conflict.
> 
> Much warmth,
> 
> Murray
> http://www.planetthoughtful.org
> Building a thoughtful planet,
> One quirky comment at a time.
> 
> 





---
Sign Up for free Email at http://ureg.home.net.my/
---

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



[PHP] Reservation technique

2004-11-04 Thread Roger Thomas
I would like to do some sort of facilities reservation system. Suppose this is for 
booking , say, a meeting room.

Booking detail to be stored in db:
- name or id of person
- meeting room number
- date and time (when room will be used)
- number of hours to be allocated

Now say Peter booked room R1 for 20th Nov starting from 9am to 12pm.
Then Mary try to book the same room on the same date beginning 10am for 4 hours.

How will a PHP script perform such checking to prevent that sort of overlapping in 
reservation ? Or could it be that my database design is bad that's blocking ideas into 
my head ?

I need help.

--
roger


---
Sign Up for free Email at http://ureg.home.net.my/
---

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



Re: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Louie Miranda
OK, here is what it should do.

I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
each weight it has a succeeding value, i cannot jump or just round off
the numbers. So i need a range detector to do it.

Because for each of the item below:

> weight   value
> .59.45
> 1.0 10.71
> 1.5 11.97
> 2.0 13.23

I must get the exact value, so let say for example. I have 1.3 it
should fall under 1.5 the idea i had was to do this, so i can detect
where the number should fall..

range:
. => .5
1.001 => 1
1.501 => 2
2.001 => 2.5
2.501 => 3
3.001 => 3.5

and so on..

But i dont know how to do this on PHP

Louie

On Thu, 4 Nov 2004 20:23:53 -0700, Vail, Warren <[EMAIL PROTECTED]> wrote:
> Not sure I completely understand what you are trying to do.  In your
> problem, seems to me that both 1.3 and 1.6 would fall under 2.0 and neither
> of them would fall under 1.0.  You must be using some logic that I am not
> getting.  Can you be a little more specific?
> 
> Warren Vail
> 
> 
> 
> 
> -Original Message-
> From: Louie Miranda [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 04, 2004 7:09 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] getting a number range from user input.. (weight)
> 
> How can i match a range of numbers from a given input?
> i tried round() but it rounds off the numbers to the next number, so that
> will be wrong.
> 
> My example below show 4 examples of what my db tables looks like.
> 
> weight   value
> .59.45
> 1.0 10.71
> 1.5 11.97
> 2.0 13.23
> 
> How can i get the range of:
> 
> .1 to fall under .5 and
> 1.3 to fall under 1.0 and
> 1.6 to fall under 2.0
> 
> and so on.. any ideas?
> 
> --
> Louie Miranda
> http://www.axishift.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
Louie Miranda
http://www.axishift.com

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



RE: [PHP] Reservation technique

2004-11-04 Thread Murray @ PlanetThoughtful

> How will a PHP script perform such checking to prevent that sort of
> overlapping in reservation ? Or could it be that my database design is bad
> that's blocking ideas into my head ?

Hi Roger,

I think you need to check out the BETWEEN operator in MySQL (assuming you're
using MySQL? Look for the equivalent operator in whatever db platform you're
using, if otherwise). Essentially what you're looking to do is find out if
either the start time or the end time of the new booking falls BETWEEN the
start time or the end time of an existing booking. If either of them does,
it's safe to assume there's a booking conflict.

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.

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



[PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Louie Miranda
How can i match a range of numbers from a given input?
i tried round() but it rounds off the numbers to the next number, so
that will be wrong.

My example below show 4 examples of what my db tables looks like.

weight   value
.59.45
1.0 10.71
1.5 11.97
2.0 13.23

How can i get the range of:

.1 to fall under .5 and
1.3 to fall under 1.0 and
1.6 to fall under 2.0

and so on.. any ideas?

-- 
Louie Miranda
http://www.axishift.com

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



RE: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Vail, Warren
Are you trying to round to the nearest .5 value?

Warren Vail


-Original Message-
From: Vail, Warren 
Sent: Thursday, November 04, 2004 7:24 PM
To: 'Louie Miranda'; [EMAIL PROTECTED]
Subject: RE: [PHP] getting a number range from user input.. (weight)


Not sure I completely understand what you are trying to do.  In your
problem, seems to me that both 1.3 and 1.6 would fall under 2.0 and neither
of them would fall under 1.0.  You must be using some logic that I am not
getting.  Can you be a little more specific?

Warren Vail


-Original Message-
From: Louie Miranda [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 7:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] getting a number range from user input.. (weight)


How can i match a range of numbers from a given input?
i tried round() but it rounds off the numbers to the next number, so that
will be wrong.

My example below show 4 examples of what my db tables looks like.

weight   value
.59.45
1.0 10.71
1.5 11.97
2.0 13.23

How can i get the range of:

.1 to fall under .5 and
1.3 to fall under 1.0 and
1.6 to fall under 2.0

and so on.. any ideas?

-- 
Louie Miranda
http://www.axishift.com

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

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

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



[PHP] Is there an HTTP server that parses PHP that will run on the Axim x3i?

2004-11-04 Thread Megiddo
Is there an HTTP server that parses PHP that will run on the Axim x3i?

I'd really like to know the answer to this question.

I'm a big PHP programmer, and would love to be able to test my scripts on my Axim.

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



RE: [PHP] getting a number range from user input.. (weight)

2004-11-04 Thread Vail, Warren
Not sure I completely understand what you are trying to do.  In your
problem, seems to me that both 1.3 and 1.6 would fall under 2.0 and neither
of them would fall under 1.0.  You must be using some logic that I am not
getting.  Can you be a little more specific?

Warren Vail


-Original Message-
From: Louie Miranda [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 7:09 PM
To: [EMAIL PROTECTED]
Subject: [PHP] getting a number range from user input.. (weight)


How can i match a range of numbers from a given input?
i tried round() but it rounds off the numbers to the next number, so that
will be wrong.

My example below show 4 examples of what my db tables looks like.

weight   value
.59.45
1.0 10.71
1.5 11.97
2.0 13.23

How can i get the range of:

.1 to fall under .5 and
1.3 to fall under 1.0 and
1.6 to fall under 2.0

and so on.. any ideas?

-- 
Louie Miranda
http://www.axishift.com

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

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



Re: [PHP] using require or include?

2004-11-04 Thread John Nichel
Reinhart Viane wrote:
i have made a page (overall.php) in which several elements are defined:
the connection with the database
a function called session_checker to check if users are logged in
and a last function(function getuserinfo()) that substracts values from
the database based on the session variables of the logged in user
 
Now this last function sets 2 variables eg.
$username=$row['user_name'];
$userstatus=$row['user_status'];
like this i do not have to recall this script on every page but i just
can do the function at the top of every page
 
Now on every page of my site I require this file
require(overall.php);
 
But it seems that i cannot get the variables outta this file.
So i can not use $username or $userstatus on the pages.
 
I think it has something to do with require not passing the variables?
Off course i can repeat the function script on the top of every page,
but that's stupid i think.
Can i use a include without any problems? Or is there a significant
difference in use and security?

Scope.
http://us4.php.net/manual/en/language.variables.scope.php
--
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


[PHP] $_SERVER['HTTP_REFERER'] does not work

2004-11-04 Thread Michelle Konzack
Hello, 

I have a Host on DynDNS.org with the URL



In the Pages I like to check, whether the URL was called from
inside my Domain or not. For testing I have added 

echo $_SERVER['HTTP_REFERER'];

but it returns every time 

http://onlinestore.tamay-dogan.net/u/controller.php

which is the local Domain. In my 'apache' Include I have

  ( '/home/PUBLIC_HTTP/Configs/vh_/onlinestore.conf' )__
 /
| 
| ServerAdmin  [EMAIL PROTECTED]
| DocumentRoot /home/PUBLIC_HTTP/onlinestore/
| 
| ServerName   onlinestore.tamay-dogan.net
| ServerAlias  onlinestore.tamay-dogan.homelinux.net
...
 \__

But if I look in "Page Info" of Mozilla, it tells me the right Domain. 

Then I have the same problem with

echo $_SERVER['SERVER_NAME'];

which tell me every time the "ServerName" but not the public 
"ServerAlias".

WHY ?

Does anyone have an example, which I can put at the beginning
of my Web-Pages which allow or deny access to the HTML-Page ?

I need to protect my php-Scripts, because I have had already
a DoS by calling my php-scripts several tenthousandth times.

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/ 
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] How to display a 'please wait' message whilst processing?

2004-11-04 Thread raditha dissanayake
Graham Cossey wrote:
On a number of sites a message and/or graphic is displayed asking you to
wait or be patient whilst some processing is being performed to compose the
next page.
 

Usually you need to do this when the data is collected from a POST 
and/or you don't want the user to reload the page. The best solution 
(IMHO) is to use meta refresh.


--
Raditha Dissanayake.

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


RE: [PHP] using require or include?

2004-11-04 Thread Reinhart Viane
That indeed did the trick.

global $username;
global $userstatus;
$username=$row['user_name'];
$userstatus=$row['user_status'];


Thx very much

-Original Message-
From: Graham Cossey [mailto:[EMAIL PROTECTED] 
Sent: vrijdag 5 november 2004 0:47
To: Php-General; [EMAIL PROTECTED]
Subject: RE: [PHP] using require or include?


Have you looked at the GLOBAL keyword?

http://uk.php.net/manual/en/language.variables.scope.php

> -Original Message-
> From: Reinhart Viane [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2004 23:02
> To: [EMAIL PROTECTED]
> Subject: [PHP] using require or include?
> 
> 
> i have made a page (overall.php) in which several elements are 
> defined: the connection with the database a function called 
> session_checker to check if users are logged in and a last 
> function(function getuserinfo()) that substracts values from the 
> database based on the session variables of the logged in user
>  
> Now this last function sets 2 variables eg. 
> $username=$row['user_name']; $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>  
> Now on every page of my site I require this file require(overall.php);
>  
> But it seems that i cannot get the variables outta this file. So i can

> not use $username or $userstatus on the pages.
>  
> I think it has something to do with require not passing the variables?

> Off course i can repeat the function script on the top of every page, 
> but that's stupid i think. Can i use a include without any problems? 
> Or is there a significant difference in use and security?
>  
> Thx in advance
> Reinhart
>  
>  
>   _
> 
> Reinhart Viane
>   [EMAIL PROTECTED] 
> Domos || D-Studio 
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01
--
> fax +32 15 43 25 26 
> 
> 
> STRICTLY PERSONAL AND CONFIDENTIAL
> This message may contain confidential and proprietary material for the
> sole use of the intended 
> recipient.  Any review or distribution by others is strictly
prohibited.
> If you are not the intended 
> recipient please contact the sender and delete all copies.
> 
>  
> 

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

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



[PHP] Session object destruction failed

2004-11-04 Thread Pablo Gosse
Hi folks.

Earlier today I received the following error when I tried to log out of
my CMS:

Session object destruction failed in [blah blah blah file info].

I googled this and took a look on bugs.php.net but couldn't find much
useful info.

Everything worked fine before, and has worked fine since, so I'm not
overly concerned.  I'd just like to know what caused it.

Any ideas?

Cheers and TIA,

Pablo

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



Re: [PHP] Is there any 'strict' and 'warnings' like packages inside PHP ?

2004-11-04 Thread Curt Zirzow
* Thus wrote Greg Donald:
> On Fri, 5 Nov 2004 06:20:11 +0800, Exile <[EMAIL PROTECTED]> wrote:
> > Is there any package like 'strict' or 'warnings' in PHP, like Perl ?
> 
> error_reporting(E_ALL | E_STRICT);
> 
> E_STRICT was added in PHP5.

E_STRICT has a different purpose though.. it will report about
things that have been deprecated.

E_NOTICE is more like perls strict, which will complain that a
variable is being used that hasn't been initialized. But E_NOTICE
happens at runtime not at compile time.


Curt
-- 
Quoth the Raven, "Nevermore."

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



RE: [PHP] using require or include?

2004-11-04 Thread Graham Cossey
Have you looked at the GLOBAL keyword?

http://uk.php.net/manual/en/language.variables.scope.php

> -Original Message-
> From: Reinhart Viane [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2004 23:02
> To: [EMAIL PROTECTED]
> Subject: [PHP] using require or include?
> 
> 
> i have made a page (overall.php) in which several elements are defined:
> the connection with the database
> a function called session_checker to check if users are logged in
> and a last function(function getuserinfo()) that substracts values from
> the database based on the session variables of the logged in user
>  
> Now this last function sets 2 variables eg.
> $username=$row['user_name'];
> $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>  
> Now on every page of my site I require this file
> require(overall.php);
>  
> But it seems that i cannot get the variables outta this file.
> So i can not use $username or $userstatus on the pages.
>  
> I think it has something to do with require not passing the variables?
> Off course i can repeat the function script on the top of every page,
> but that's stupid i think.
> Can i use a include without any problems? Or is there a significant
> difference in use and security?
>  
> Thx in advance
> Reinhart
>  
>  
>   _  
> 
> Reinhart Viane 
>   [EMAIL PROTECTED] 
> Domos || D-Studio 
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
> fax +32 15 43 25 26 
> 
> 
> STRICTLY PERSONAL AND CONFIDENTIAL 
> This message may contain confidential and proprietary material for the
> sole use of the intended 
> recipient.  Any review or distribution by others is strictly prohibited.
> If you are not the intended 
> recipient please contact the sender and delete all copies.
> 
>  
> 

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Curt Zirzow
* Thus wrote Robin Getz:
> Curt Zirzow [EMAIL PROTECTED] wrote:
> >> replaced:
> >>   readfile($name);
> >> with:
> >>   $fp = fopen($name, 'rb');
> >>   fpassthru($fp);
> >
> >The only difference between readfile() and fpassthru() is what parameters 
> >you pass it.
> >
> >Something else is the problem, what version of php are you running?
> 
> I am using php 4.2.2

Thats an awful old version.

> 
> OK - I lied.
> 
> The same problem exists with fpassthru (now that I have let it run a little 
> longer) I now have 5 sleeping httpd processes on my system that are 
> consuming 200Meg each.

Either upgrade to a newer version or you could use this function:

  http://php.net/apache-child-terminate

Curt
-- 
Quoth the Raven, "Nevermore."

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



[PHP] Getting all namespaces of a DOM document.

2004-11-04 Thread David Schlotfeldt
This should work perfectly. Thanks a lot!
David
---
Hello David,
I had the same problem some weeks before and solved it with the use of xpath 
(thus it isn't in the dom documentation of w3c but you'll find it under xpath 
recommendation):



	$xml = "http://anynamespace.tld/\";>nodeValue";
	
	$doc = new DOMDocument();
	$doc->loadXML($xml);
	
	$xpath = new DOMXPath($doc);
	$result = $xpath->query("//namespace::*");
	
	foreach($result as $node) {
		print $node->localName . " = " . $node->nodeValue . "\n";
	}
?> 


The xpath expression "//namespace::*" selects all nodes of the namespace axis, 
the namespaces. Maybe it is a bit heavy for bigger documents to traverse all 
nodes but it does its work...

If this is an acceptable solution to your problem, it would be nice if you 
could post our conversation on php.xml.dev news repository (news.php.net, but 
i think you'll know:). Thanks.

Furhter it would be nice if you would take just a minute to get to know my new 
project called eecoo - if you're interested in oop concepts of php5 and of 
course xml & co. you'll there be quite right!! You can find it under 
http://eecoo.dyndns.info/~brainbug/ (leave out ~brainbug to see the 
developement server, but currently under construction).

Thanks, and nice to meet you. hope i could help.
Bye
vivi
--
ORIGINAL EMAIL 
--

Vivian Steller,
Hi, I saw your documentation of PHP5's DOM at
http://www.eecoo.de/downloads/domdocumentation.txt and was wondering if
you could help me solve a issue. I have been using W3's website to
figure out everything I know about PHP's DOM since they follow it very
closesly. On a project I am working on I need a list of all the
namespaces in the dom document. I find that you can get the namespcace
uri if you have the prefix and the prefix if you have the namespace uri,
but i can not find out how to get a complete list. I do see the NameList
(DOMNodeList in PHP5) but I see no way of getting to it; or even if it
is implemented.
Anyways, my question is if your have learned of a way to get a complete
list of namespace uri's (or namespace prefixes) when using PHP5's DOM?
Thanks a lot for any help you can provide.
David Schlotfeldt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Getting all namespaces of a DOM document.

2004-11-04 Thread David Schlotfeldt
This should work perfectly. Thanks a lot!
David
---
Hello David,
I had the same problem some weeks before and solved it with the use of 
xpath
(thus it isn't in the dom documentation of w3c but you'll find it under 
xpath
recommendation):


http://anynamespace.tld/\";>nodeValue";

$doc = new DOMDocument();
$doc->loadXML($xml);

$xpath = new DOMXPath($doc);
$result = $xpath->query("//namespace::*");

foreach($result as $node) {
print $node->localName . " = " . $node->nodeValue . "\n";
}
?>

The xpath expression "//namespace::*" selects all nodes of the namespace 
axis,
the namespaces. Maybe it is a bit heavy for bigger documents to traverse 
all
nodes but it does its work...

If this is an acceptable solution to your problem, it would be nice if you
could post our conversation on php.xml.dev news repository 
(news.php.net, but
i think you'll know:). Thanks.

Furhter it would be nice if you would take just a minute to get to know 
my new
project called eecoo - if you're interested in oop concepts of php5 and of
course xml & co. you'll there be quite right!! You can find it under
http://eecoo.dyndns.info/~brainbug/ (leave out ~brainbug to see the
developement server, but currently under construction).

Thanks, and nice to meet you. hope i could help.
Bye
vivi
--
ORIGINAL EMAIL
--
Vivian Steller,
Hi, I saw your documentation of PHP5's DOM at
http://www.eecoo.de/downloads/domdocumentation.txt and was wondering if
you could help me solve a issue. I have been using W3's website to
figure out everything I know about PHP's DOM since they follow it very
closesly. On a project I am working on I need a list of all the
namespaces in the dom document. I find that you can get the namespcace
uri if you have the prefix and the prefix if you have the namespace uri,
but i can not find out how to get a complete list. I do see the NameList
(DOMNodeList in PHP5) but I see no way of getting to it; or even if it
is implemented.
Anyways, my question is if your have learned of a way to get a complete
list of namespace uri's (or namespace prefixes) when using PHP5's DOM?
Thanks a lot for any help you can provide.
David Schlotfeldt
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein

--- Ben Ramsey <[EMAIL PROTECTED]> wrote:


> You should also use mysql_real_escape_string() on
> the data from the client.


Even though Magic Quotes GPC is turned on ?


Stuart

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
OK, I checked things out, and based on some private emails, and pointers, 
from Francisco M. Marzoa [EMAIL PROTECTED], I have now

replaced:
   readfile($name);
with:
while(!feof($fp)) {
$buf = fread($fp, 4096);
echo $buf;
$bytesSent+=strlen($buf);/* We know how many bytes were sent 
to the user */
}

I restarted apache (to free all the memory), and we will see how it goes 
overnight.

-Robin
BTW - output buffering is turned OFF. ob_get_level() returns 0, but both 
functions readfile and fpassthru seem to allocate memory (and never 
release) the size of the file.

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


[PHP] using require or include?

2004-11-04 Thread Reinhart Viane
i have made a page (overall.php) in which several elements are defined:
the connection with the database
a function called session_checker to check if users are logged in
and a last function(function getuserinfo()) that substracts values from
the database based on the session variables of the logged in user
 
Now this last function sets 2 variables eg.
$username=$row['user_name'];
$userstatus=$row['user_status'];
like this i do not have to recall this script on every page but i just
can do the function at the top of every page
 
Now on every page of my site I require this file
require(overall.php);
 
But it seems that i cannot get the variables outta this file.
So i can not use $username or $userstatus on the pages.
 
I think it has something to do with require not passing the variables?
Off course i can repeat the function script on the top of every page,
but that's stupid i think.
Can i use a include without any problems? Or is there a significant
difference in use and security?
 
Thx in advance
Reinhart
 
 
  _  

Reinhart Viane 
  [EMAIL PROTECTED] 
Domos || D-Studio 
Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
fax +32 15 43 25 26 


STRICTLY PERSONAL AND CONFIDENTIAL 
This message may contain confidential and proprietary material for the
sole use of the intended 
recipient.  Any review or distribution by others is strictly prohibited.
If you are not the intended 
recipient please contact the sender and delete all copies.

 


Re: [PHP] Is there any 'strict' and 'warnings' like packages inside PHP ?

2004-11-04 Thread Greg Donald
On Fri, 5 Nov 2004 06:20:11 +0800, Exile <[EMAIL PROTECTED]> wrote:
> Is there any package like 'strict' or 'warnings' in PHP, like Perl ?

error_reporting(E_ALL | E_STRICT);

E_STRICT was added in PHP5.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Klaus Reimer
Robin Getz wrote:
The same problem exists with fpassthru (now that I have let it run a 
little longer) I now have 5 sleeping httpd processes on my system that 
are consuming 200Meg each.
Any thoughts?
Ok, so much for the theory. What about the output buffering? Have you 
checked if you have output buffering enabled? What das ob_get_level() 
return?

If it's activated but you can't find where it is activated then this may 
help to disable it in your script:

while (ob_get_level()) ob_end_flush();
--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


[PHP] Is there any 'strict' and 'warnings' like packages inside PHP ?

2004-11-04 Thread Exile
Hi list, 

Is there any package like 'strict' or 'warnings' in PHP, like Perl ?

Thanks in advise,
Exile

RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:

> [snip]
> May I ask why you are suggesting this function ?
> 
> > You can use htmlentities() on the information
> placed
> [/snip]
> 
> Because it will convert things like quotes into
> their HTML counterparts
> before you place them into the table.

I'm still a bit fuzzy on how to write it out.

So if field is labelled f5
Then I'm doing a $_SESSION['f5'] = $_POST['MyText'];
then I think it would be 
$f5 = htmlentities($f5, ENT_QUOTES);

insert $f5 into database ?

Thanks
Stuart

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
Curt Zirzow [EMAIL PROTECTED] wrote:
> replaced:
>   readfile($name);
> with:
>   $fp = fopen($name, 'rb');
>   fpassthru($fp);
The only difference between readfile() and fpassthru() is what parameters 
you pass it.

Something else is the problem, what version of php are you running?
I am using php 4.2.2
OK - I lied.
The same problem exists with fpassthru (now that I have let it run a little 
longer) I now have 5 sleeping httpd processes on my system that are 
consuming 200Meg each.

Any thoughts? 

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


Re: [PHP] Question: Validation on a text field

2004-11-04 Thread Ben Ramsey
Jay Blanchard wrote:
[snip]
May I ask why you are suggesting this function ?
You can use htmlentities() on the information placed
[/snip]
Because it will convert things like quotes into their HTML counterparts
before you place them into the table. If you are reading it back out to
a web interface they get properly displayed without any manipulation.
http://www.php.net/htmlentities explains a little more in depth. It is
one step towards preventing SQL injection and possible other hack
attacks.
You should also use mysql_real_escape_string() on the data from the client.
http://www.php.net/mysql_real_escape_string
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Zip Codes

2004-11-04 Thread Dusty Bin
Brian V Bonini wrote:
On Thu, 2004-11-04 at 12:47, Vail, Warren wrote:

If you can figure out how to make sense of this, you might be able to find
the point that a system is connected to the internet, by tracing back to a
visitors current IP address.

Which may get you close but either way would probably be more indicative
of the service providers location then the actual user and even
narrowing it down to a single city does not mean you have only a single
zip code to deal with.
not to mention DHCP!!!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
May I ask why you are suggesting this function ?

> You can use htmlentities() on the information placed
[/snip]

Because it will convert things like quotes into their HTML counterparts
before you place them into the table. If you are reading it back out to
a web interface they get properly displayed without any manipulation.
http://www.php.net/htmlentities explains a little more in depth. It is
one step towards preventing SQL injection and possible other hack
attacks.

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



Re: [PHP] Re: VOTE TODAY

2004-11-04 Thread Michael Lauzon
6Mb, that's no fair, the highest we have in Canada is 4Mb; although
supposedly there is a 5Mb service somewhere...well there is 7Mb
service but you'll be paying out of your @$$ for it.




On Thu, 4 Nov 2004 04:09:50 +0100, Michelle Konzack
<[EMAIL PROTECTED]> wrote:
> Am 2004-11-02 18:36:08, schrieb Michael Lauzon:
> > I am also Canadian, so don't waste my bandwidth either...Chris
> > bandwidth is cheap in Canada!
> 
> 
> ...and cheaper in France at free.fr
> 
> 30 Euros for ADSL 6MBit/512kBit
> 
> Greetings
> Michelle
> 
> --
> Linux-User #280138 with the Linux Counter, http://counter.li.org/
> Michelle Konzack   Apt. 917  ICQ #328449886
>   50, rue de Soultz MSM LinuxMichi
> 0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)
> 
> 
> 


-- 
Michael Lauzon

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
May I ask why you are suggesting this function ?

Stuart
--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:

> [snip]
> It's a mysql text field.
> [/snip]
> 
> You can use htmlentities() on the information placed
> into the field
> 
> --
> 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] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
It's a mysql text field.
[/snip]

You can use htmlentities() on the information placed into the field

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein

--- "Vail, Warren" <[EMAIL PROTECTED]> wrote:

> I also don't know if MySQL will police things input
> to a text column to make
> sure they are valid ascii text characters.
> 
No Mysql won't do it.  PHP validation would have to be
involved.

Stuart

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
It's a mysql text field.

Stuart
--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:

> [snip]
> Any thoughts ?
> [/snip]
> 
> I thought I'd have lunch today, but I didn't.
> 
> Is it a 'text' data type, or 'BLOB', (you said,
> "actual Mysql Text
> column, aka like a blob") because the distinction is
> needed.
> 
> --
> 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] Question: Validation on a text field

2004-11-04 Thread Vail, Warren
Assuming that the pasting is done into a  on an html
form, I believe the Textarea will limit the past to just "text" characters.


I suppose this could be dependent on the browser.  

I don't know of any html input control that would allow "blob" (binary)
values.

I also don't know if MySQL will police things input to a text column to make
sure they are valid ascii text characters.

Warren Vail


-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 12:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Question: Validation on a text field


I have a field that is an actual Mysql Text column,
aka like a blob.  I'm wondering if doing a standard
validation that checks for characters outside of the alphanumeric range is
enough.  I'm imagining some users will cut and paste from a Word or PDF doc
into the field. I've done it myself and no weird characters are showing up.

Any thoughts ?

Stuart

-- 
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] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
Any thoughts ?
[/snip]

I thought I'd have lunch today, but I didn't.

Is it a 'text' data type, or 'BLOB', (you said, "actual Mysql Text
column, aka like a blob") because the distinction is needed.

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



[PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
I have a field that is an actual Mysql Text column,
aka like a blob.  I'm wondering if doing a standard
validation that checks for characters outside of the
alphanumeric range is enough.  I'm imagining some
users will cut and paste from a Word or PDF doc into
the field. I've done it myself and no weird characters
are showing up.

Any thoughts ?

Stuart

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



Re: [PHP] Strange query

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 13:02:19 -0700, Vail, Warren <[EMAIL PROTECTED]> wrote:
> It is too bad this clause is not supported by some of the other
> databases I have had to use

I think calling a limit a limit and an offset an offset is a good thing.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



RE: [PHP] Strange query

2004-11-04 Thread Ryan A
Hey,

> the second
> specifies the maximum number of rows to return.

Thats where my problem was...thanks. I forget the Limit parameters, i for
some reason though the second parameter was till which record to return...

Loud and clear sign telling me to get some sleep (i guess)
 :-)

Thanks,
Ryan

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



RE: [PHP] Strange query

2004-11-04 Thread Vail, Warren
The second limit parameter is the actual number of rows to limit to, and in
most situations this is usually the same number (i.e. 0,15; 15,15; 30,15;
etc).  It is too bad this clause is not supported by some of the other
databases I have had to use, it makes a convenient way of paging where the
second paging parameter specifies the page size in terms of rows to retrieve
(first parameter is the starting row number starting with zero).

Warren Vail


-Original Message-
From: Ryan A [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 11:49 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Strange query


Hi,
I am running this query from my script:

  $query = "select gallery_url,description from members limit
".$limit[0].",".$limit[1];

the first time: limit 0,15
and the second time: limit 16,30


the problem is the first time I am getting 15 rows returned (as expected)
the second query of select gallery_url,description from members limit 16,30
is returning 17 rows!!

I've even tried it within phpmyadmin and its giving me 17 rowswhat am I
missing here?

Thanks,
Ryan

-- 
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] Strange query

2004-11-04 Thread Jay Blanchard
[snip]
  $query = "select gallery_url,description from members limit
".$limit[0].",".$limit[1];

the first time: limit 0,15
and the second time: limit 16,30
[/snip]

from http://www.mysql.com/select

"The LIMIT clause can be used to constrain the number of rows returned
by the SELECT statement. LIMIT takes one or two numeric arguments, which
must be integer constants. With two arguments, the first argument
specifies the offset of the first row to return, and the second
specifies the maximum number of rows to return. The offset of the
initial row is 0 (not 1): "

My guess is that you have 32 rows in the table, you started at 16 and
asked for 30 records. You got back 17, which is all that was left

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



[PHP] Strange query

2004-11-04 Thread Ryan A
Hi,
I am running this query from my script:

  $query = "select gallery_url,description from members limit
".$limit[0].",".$limit[1];

the first time: limit 0,15
and the second time: limit 16,30


the problem is the first time I am getting 15 rows returned (as expected)
the second query of
select gallery_url,description from members limit 16,30
is returning 17 rows!!

I've even tried it within phpmyadmin and its giving me 17 rowswhat am I
missing here?

Thanks,
Ryan

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



[PHP] How to display a 'please wait' message whilst processing?

2004-11-04 Thread Graham Cossey

On a number of sites a message and/or graphic is displayed asking you to
wait or be patient whilst some processing is being performed to compose the
next page.

How are these done within PHP scripts?
Could output buffering be used for this purpose?
For example is it possible to do something like:



Should I be aware of anything that could trip me up on this?

Any help or pointers much appreciated.

Graham

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



Re: [PHP] Re: Advice on imagecreatefrom

2004-11-04 Thread Jason Wong
On Thursday 04 November 2004 18:33, Daniel Lahey wrote:

> I find it hard to believe, too.  The error is (as I recall) "call to
> undefined function () in  at " with no function name
> given, just the empty parentheses.  It doesn't happen in Firefox,
> Mozilla, or Netscape.

Post some *concise* code that illustrates your problem.

-- 
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
--
/*
Why not go out on a limb?  Isn't that where the fruit is?
*/

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Curt Zirzow
* Thus wrote Robin Getz:
> Klaus Reimer [EMAIL PROTECTED] wrote:
> >If this theory is true, you may try fpassthru().
> 
> replaced:
>   readfile($name);
> with:
>   $fp = fopen($name, 'rb');
>   fpassthru($fp);

The only difference between readfile() and fpassthru() is what
parameters you pass it.

Something else is the problem, what version of php are you running?


Curt
-- 
Quoth the Raven, "Nevermore."

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



RE: [PHP] Zip Codes

2004-11-04 Thread Brian V Bonini
On Thu, 2004-11-04 at 12:47, Vail, Warren wrote:

> If you can figure out how to make sense of this, you might be able to find
> the point that a system is connected to the internet, by tracing back to a
> visitors current IP address.

Which may get you close but either way would probably be more indicative
of the service providers location then the actual user and even
narrowing it down to a single city does not mean you have only a single
zip code to deal with.

-- 

s/:-[(/]/:-)/g


BrianGnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org
aGEhIGJldCB5b3UgdGhpbmsgeW91IHByZXR0eSBzbGljayBmb3IgZmlndXJpbmcgb3V0I
GhvdyB0byBkZWNvZGUgdGhpcy4gVG9vIGJhZCBpdCBoYXMgbm8gc2VjcmV0IGluZm8gaW
4gaXQgaGV5Pwo=

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



RE: [PHP] Zip Codes

2004-11-04 Thread Jay Blanchard
[snip]
> Thanks for the sarcasm, it definitely helps.
>
> Why is it that when people ask a question there is always someone that
has
> a smartass answer?
>

It keeps us on our toes. Someone's gotta do it.
[/snip]

It would be a terrible thing to arrive one day, open the list, and see
that everyone had been civil...no sarcasm, no witjust business. BTW
thanks for the heads up on that USPS API

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



[PHP] Re: Advice on imagecreatefrom

2004-11-04 Thread Daniel Lahey
I find it hard to believe that your choice of browser affects the 
operation of
PHP.
Where is this report?
I may have been mistaken about the "report":  "Windows versions of PHP 
prior to PHP 4.3.0 do not support accessing remote files via this 
function, even if allow_url_fopen is enabled."  (Found at 
http://us2.php.net/manual/en/function.imagecreatefromjpeg.php)  The 
server is running Linux, so it's not Windows PHP, it's the client (IE).

I find it hard to believe, too.  The error is (as I recall) "call to 
undefined function () in  at " with no function name 
given, just the empty parentheses.  It doesn't happen in Firefox, 
Mozilla, or Netscape.

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


Re: [PHP] Zip Codes

2004-11-04 Thread Matthew Sims
> Thanks for the sarcasm, it definitely helps.
>
> Why is it that when people ask a question there is always someone that has
> a smartass answer?
>

It keeps us on our toes. Someone's gotta do it.

-- 
--Matthew Sims
--

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



RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
Because for some of us, that part of our body is the smartest thing we have
going, and the rest of us is not engaged in the question.

Warren Vail

-Original Message-
From: bb9876 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:41 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Zip Codes


Thanks for the sarcasm, it definitely helps.

Why is it that when people ask a question there is always someone that has a
smartass answer?

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thursday 04 November 2004 16:59, bb9876 wrote:
> > Is there any way to use PHP to determine the zip code someone is
visiting
> > from, assuming they are all from the US?
>
> Something like this should work:
>
> -- start
>  
> Please input zipcode  
>  
>
>if (!empty($_POST['zipcode'])) {
> echo "Whoa! your zipcode is {$_POST['zipcode']}";
>   }
> ?>
> -- end
>
> --
> 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
> --
> /*
> Thinking you know something is a sure way to blind yourself.
>   -- Frank Herbert, "Chapterhouse: Dune"
> */

-- 
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] Determining system resources

2004-11-04 Thread Robin Getz
Francisco M. Marzoa Alonso [EMAIL PROTECTED] wrote:
As far as you cannot lock another processes in the system, so this will 
not give you the security that the resources will not change -and probably 
they'll do it- while you're trying to download that file.
Yes, I understand, but not to know even if you are in the right order of 
magnitude, is kind of scary isn't it?

For example on my system, I have 1 Gig of physical memory, and 3Gig of 
swap. If I end up with only 512k free - something is very wrong, and I 
should disallow functions I know that eat up memory. There is a low 
probability that multiple connections will pass the test, and then consume 
the memory, so yes this is not 100% coverage.

Maybe what I am seeing is actually a bug in the way that readfile() handles 
low memory situations. If there is not enough memory for internal functions 
to run, they should error, not crash your system.

I assume that the way the converstation is moved is that there is not a way 
to see what free system memory is, without calling a command line function 
(free or mem).

-Robin 

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


Re: [PHP] Re: PHP Crypt on MacOSX

2004-11-04 Thread Kris
Galen P.Zink wrote:
Kris,
I doubt there's "no way" to do this under OS X. Maybe by default, you 
have a curve ball to deal with. But considering the kernel is open 
source, you could make this OS do anything... literally :)
That is how I feel as well.  Being a long-time *nix/BSD user.. I have 
heard it before and never believe "it cant be done".  I remember back on 
the C64, they said the computer would not support a 9600BAUD modem, then 
one day I am plugging one into my cartridge port and getting "blazing" 
speeds (LOL This was in the eighties obviously)...

A second problem, and why I want to create some PHP to mimic crypt() 
"unix style" passwords without actually using crypt() is due to the fact 
that this box is not my box and so the option of modifying the OS is 
currently not an option.  Consider this thread dead unless someone else 
has a solution.  Thanks for thinking it through.  Your time has been 
greatly appreciated.

A side note; I am amazed that no one else on this list can or is jumping 
into this discussion about using PHP to mimic PHP's crypt() function in 
order to create "unix style" MD5 passwords.  I know it has been done 
before, and can be done probably many different ways.  The idea of using 
system() or exec() to call MD5 is an option I will be looking into, 
however, I know there must be another option.  I have considered 
rewriting my own version of crypt() to not use libmcrypt but the 
information on the C-like Zend language used to write your own embedded 
PHP functions is a bit vague in regards to me "getting over the learning 
curve".  My other option is to just move this to another server and then 
my existing crypt() based code will resume functioning as expected.

I dont except a reply from Rasmus or Zeev, as they are extremely busy 
guys, however, I won't stop them if they are interested in this thread.

Help me Obi Won, you are my only hope. LOL
Take Care,
Kris
[EMAIL PROTECTED]
Where is your PHP package coming from? If you've already been using 
the http://entropy.ch binary, maybe you should try compiling your own. 
Or get (and either compile yourself or just install binaries) it via 
fink (http://fink.sf.net/) which often gives you different options for 
libraries to use and such during install. Or any number of other 
options. I wonder if there is some build option or something setup in 
the configuration process that affects this. I seriously wonder how 
libmcrypt could have this sort of limitation under OS X, but I am not 
that type of programmer.

I would encourage you to play with this and post your results to the 
php-general list as well as letting me know how it goes.

-Galen
On Nov 3, 2004, at 2:31 PM, Kris wrote:
Galen,
Thank you for the response.  I understand where you are coming from; 
your use of MD5 hash.  In short, my goal is to recreate crypt()'s 
method of creating "unix style" passwords without using PHP's 
built-in crypt() function... (as seen in /etc/shadow on a *nix 
server, ie. $1$sed$blaaah instead of standard MD5 hash which 
does not use $1$$ to store a "seed".)

Ultimately, my problem exists related to the server I am using, where 
the server's PHP crypt (using libmcrypt) returns with the fact that
CRYPT_MD5 = 0 .

In researching, I have been told that this is a limitation of Mac OS 
X, that "there is no way to have libmcrypt support both DES and MD5" 
on this OS.. but I know there must be a way because it is easy to 
have a FreeBSD server use both DES and MD5.

I had an old BSD box online for years.. where old account passwords 
in /etc/shadow were encrypted via two character salt DES.  One day, I 
made a simple change to the box's config and then any new accounts 
created would use MD5.  The "coolest" part is that any old passwords 
in DES could remain DES, and BSD's libmcrypt could determine if a 
passwd in /etc/shadow was DES or MD5 and handle accordingly.  
Obviously, this kept me from having to call clients and change their 
password so as to re-encrypt their respective /etc/shadow entry into 
MD5.

I hope this email better explains my situation.   I'll check out man 
md5 on the Mac box and see what I can figure out.  In the meantime, 
if this email helps to generate any ideas which may be helpful in my 
current quest, your input would be most appreciated.

Thanks again,
Kris
Galen P.Zink wrote:
Kris,
I'm not quite sure what you mean here. When I work with md5, I 
always have considered it to work like this:

string -> md5 = hash
On any system, the md5 binary, md5 php function, and MySQL md5 (in 
most cases - though in certain situations you could have problems if 
you have a field of the wrong type or length) all work exactly alike.

This is how I have always thought of md5 and considered it to be 
"standard" and I've never had a problem with it. I've made dozens of 
web and other php/mysql applications.

There have never been seeds or anything else involved in my 
experiences. I do know that in some cases a "salt" is setup

RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
One thing I might be tempted to try would be to execute a trace route
utility and analyze the output, but it is very cryptic;

http://www.traceroute.org/
http://www.tracert.com/cgi-bin/trace.pl

HOSTLOSS  RCVD SENTBEST AVG
WORST
er1.sfo1.speakeasy.net0%20   20   25.70   30.68
89.13
220.ge-0-1-0.cr2.sfo1.speakeasy.net   0%20   20   24.02   26.56
58.23
ge-4-0-440.ipcolo1.SanJose1.Level3.net0%20   20   24.38   25.28
27.09
ae-1-56.bbr2.SanJose1.Level3.net  0%20   20   24.26   31.00
97.58
so-3-0-0.mp1.SanFrancisco1.Level3.net 0%20   20   25.49   28.89
49.58
so-10-0.ipcolo1.SanFranciso1.Level3.net   0%20   20   25.17   25.81
26.73
gw-level3-sfo.internap.com0%20   20   27.32   28.12
29.58
border4.ge3-0-bbnet2.sfo.pnap.net 0%20   20   27.11   28.24
28.93
??? 100% 0   200.000.00
0.00

If you can figure out how to make sense of this, you might be able to find
the point that a system is connected to the internet, by tracing back to a
visitors current IP address.

If you come up with something useful, keep the list informed.

Warren Vail


-Original Message-
From: John Nichel [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:22 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Zip Codes


bb9876 wrote:
> Is there any way to use PHP to determine the zip code someone is 
> visiting from, assuming they are all from the US?
> 

Outside of asking the visitor for it, no.

-- 
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[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] Zip Codes

2004-11-04 Thread bb9876
Thanks for the sarcasm, it definitely helps.

Why is it that when people ask a question there is always someone that has a
smartass answer?

"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thursday 04 November 2004 16:59, bb9876 wrote:
> > Is there any way to use PHP to determine the zip code someone is
visiting
> > from, assuming they are all from the US?
>
> Something like this should work:
>
> -- start
> 
> Please input zipcode 
> 
> 
>
>if (!empty($_POST['zipcode'])) {
> echo "Whoa! your zipcode is {$_POST['zipcode']}";
>   }
> ?>
> -- end
>
> -- 
> 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
> --
> /*
> Thinking you know something is a sure way to blind yourself.
>   -- Frank Herbert, "Chapterhouse: Dune"
> */

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



Re: [PHP] Zip Codes

2004-11-04 Thread Matthew Weier O'Phinney
* Bb9876 <[EMAIL PROTECTED]>:
> "John Nichel" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > bb9876 wrote:
> > > Is there any way to use PHP to determine the zip code someone is
> > > visiting
> > > from, assuming they are all from the US?
> > >
> >
> > Outside of asking the visitor for it, no.
> 
> Okay, I run a movie news site and wanted to use it to make it even
> quicker for users to find movie times in their area whether they were
> logged in or not, but that's the way it goes.

Well, you *could* have a form that displays asking for their zip code;
on submission, it sets a cookie with their zip code, and this allows
them to see their personalized movie times on subsequent visits. (You
could even hide the zipcode form if the cookie is set)

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

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



Re: [PHP] Determining system resources

2004-11-04 Thread Francisco M. Marzoa Alonso
Greetings Robin,
As far as you cannot lock another processes in the system, so this will 
not give you the security that the resources will not change -and 
probably they'll do it- while you're trying to download that file.

Best regards,
Robin Getz wrote:
I have been unable to find a php function to determine available system
memory (physical and swap)?
Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
i = strlen($free);
free = str_replace('  ',' ',$free);   
}
$free = str_replace("\n",'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==

Does anyone have any ideas that could be used on all OSes? i.e. 
Without shell_exec()?

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


Re: [PHP] Zip Codes

2004-11-04 Thread bb9876
Okay, I run a movie news site and wanted to use it to make it even quicker
for users to find movie times in their area whether they were logged in or
not, but that's the way it goes.

Thanks fo rthe replies.


"John Nichel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bb9876 wrote:
> > Is there any way to use PHP to determine the zip code someone is
visiting
> > from, assuming they are all from the US?
> >
>
> Outside of asking the visitor for it, no.
>
> -- 
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]

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



Re: [PHP] Zip Codes

2004-11-04 Thread Jason Wong
On Thursday 04 November 2004 16:59, bb9876 wrote:
> Is there any way to use PHP to determine the zip code someone is visiting
> from, assuming they are all from the US?

Something like this should work:

-- start

Please input zipcode 




-- end

-- 
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
--
/*
Thinking you know something is a sure way to blind yourself.
  -- Frank Herbert, "Chapterhouse: Dune"
*/

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



[PHP] Re: settin mine type while saving files

2004-11-04 Thread M. Sokolewicz
Merlin wrote:
Hi there,
I am creating pdf files inside my application and do save them to the 
server file system. Now I have sent some of the emails by the system via 
email and found that the mine type is not set. So the pdf file apears in 
the attachement, but one has to select the application from a list to 
display it.
Is there a way to save the mime type with the file, so windows does know 
how to handle that file?

Thanx for any help on that,
Merlin
add a correct content-type header in the attachment headers of the email
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Zip Codes

2004-11-04 Thread John Nichel
bb9876 wrote:
Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?
Outside of asking the visitor for it, no.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Zip Codes

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 08:59:50 -0800, bb9876 <[EMAIL PROTECTED]> wrote:
> Is there any way to use PHP to determine the zip code someone is visiting
> from, assuming they are all from the US?

http://www.usps.com/webtools/


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



RE: [PHP] Zip Codes

2004-11-04 Thread Jay Blanchard
[snip]
Is there any way to use PHP to determine the zip code someone is
visiting
from, assuming they are all from the US?
[/snip]

You would have to determine their IP, which, some being dynamically
assigned at log on, would not necessarily indicate the users location.
Then you would have to be able to map the IP to a zip code. The short
answer is no.

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



RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
Do you mean other than asking them, like using their IP address?

Warren Vail

-Original Message-
From: bb9876 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:00 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Zip Codes


Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?

-- 
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] Zip Codes

2004-11-04 Thread bb9876
Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?

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



[PHP] settin mine type while saving files

2004-11-04 Thread Merlin
Hi there,
I am creating pdf files inside my application and do save them to the server 
file system. Now I have sent some of the emails by the system via email and 
found that the mine type is not set. So the pdf file apears in the attachement, 
but one has to select the application from a list to display it.
Is there a way to save the mime type with the file, so windows does know how to 
handle that file?

Thanx for any help on that,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Determining system resources

2004-11-04 Thread Greg Donald
On Thu, 04 Nov 2004 08:25:19 -0800, Robin Getz
<[EMAIL PROTECTED]> wrote:
> I have been unable to find a php function to determine available system
> memory (physical and swap)?

> php -r "system('free -m');"
 total   used   free sharedbuffers cached
Mem:   249246  2  0  4 86
-/+ buffers/cache:154 94
Swap:  486 12473

The system has to support whatever memory command you use.

*nix: free
windoze: mem


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Greg Donald
On Thu, 04 Nov 2004 08:22:18 -0800, Robin Getz
<[EMAIL PROTECTED]> wrote:
> and now I don't loose 250 Meg of memory every time I download a 250Meg
> file. If someone wants to add this to the  readfile() php manual - great.

Anyone can post user comments in the manual.  Give it a shot.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Determining system resources

2004-11-04 Thread Robin Getz
I have been unable to find a php function to determine available system
memory (physical and swap)?
Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
i = strlen($free);
free = str_replace('  ',' ',$free); 
}
$free = str_replace("\n",'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==
Does anyone have any ideas that could be used on all OSes? i.e. Without 
shell_exec()?

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


Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
Klaus Reimer [EMAIL PROTECTED] wrote:
If this theory is true, you may try fpassthru().
replaced:
  readfile($name);
with:
  $fp = fopen($name, 'rb');
  fpassthru($fp);
and now I don't loose 250 Meg of memory every time I download a 250Meg 
file. If someone wants to add this to the  readfile() php manual - great.

Thanks
Robin 

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


Re: [PHP] what am i doing wrong..??

2004-11-04 Thread M. Sokolewicz
well ofcourse it "keeps the get variables" as you put it. PHP_SELF is 
the path and arguments that php was called with. use phpinfo(); to find 
out which variables hold the real path, make sure to add some random 
"get variables" when calling that script so you see the difference

Jack Van Zanen wrote:
 somehow keeps the $_GET variables. If you
change this to the real script name it seems to work
JACK
-Original Message-
From: Aalee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 1:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] what am i doing wrong..??

Hi there please have a look the code below...I dont know wht am doing wrong
here... This code is suppose to show the number of jokes in a mysql database
and allows user to add a joke when the user clicks addjoke link. And when
the joke is added, it suppose to say that "Joke inserted, Thank you" and
list all the jokes below this line. So far am able to view all the jokes and
take the user to add joke page. But the problem is when the user clicks
insert joke button, it does not display the message "Joke inserted, Thank
you" and the jokes are not listed. Infact it does not give any error aswell,
it just stays on the add joke form page. I checked the database and no joke
is added. Working on PHP ver 4.3.8 with register_globals turned OFF and
Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using
registre_globals OFF and all these probs strted coming up. This code was
working fine with globals ON. But my hosting has it off. So need to do so. I
was able to fix all the other issues came coz of this global thing in this
code. But stuck on the issue i just mentioned. Any help would be GREATLY
appreciated.


  Type your joke :
  
   
  

";  echo mysql_error(); } $color1 = "#66CCFF";
$color2 = "#66CC99"; $row_count = 1;
// -- Following lines list the jokes in the
database 
echo " These are the jokes we have got so far"; $db =
mysql_connect("localhost","homesite","test")  or die(mysql_error());
mysql_select_db("jokes",$db); $sql = "SELECT id, JokeText, JokeDate from
jokes"; $query = mysql_query($sql); echo "
   
ID
  Joke Text
  Joke Date";
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echo"".
  "". $myrow["id"]."".
  "". $myrow["JokeText"]. "".
  "". $myrow["JokeDate"]."";
  $row_count++;
 }
echo "";
$current_url = $_SERVER['PHP_SELF'];
echo("" ."Add a Joke!");
} // end main else statement
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] what am i doing wrong..??

2004-11-04 Thread Jack . van . Zanen
 somehow keeps the $_GET variables. If you
change this to the real script name it seems to work

JACK

-Original Message-
From: Aalee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 1:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] what am i doing wrong..??


Hi there please have a look the code below...I dont know wht am doing wrong
here... This code is suppose to show the number of jokes in a mysql database
and allows user to add a joke when the user clicks addjoke link. And when
the joke is added, it suppose to say that "Joke inserted, Thank you" and
list all the jokes below this line. So far am able to view all the jokes and
take the user to add joke page. But the problem is when the user clicks
insert joke button, it does not display the message "Joke inserted, Thank
you" and the jokes are not listed. Infact it does not give any error aswell,
it just stays on the add joke form page. I checked the database and no joke
is added. Working on PHP ver 4.3.8 with register_globals turned OFF and
Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using
registre_globals OFF and all these probs strted coming up. This code was
working fine with globals ON. But my hosting has it off. So need to do so. I
was able to fix all the other issues came coz of this global thing in this
code. But stuck on the issue i just mentioned. Any help would be GREATLY
appreciated.



  Type your joke :
  
   
  



";  echo mysql_error(); } $color1 = "#66CCFF";
$color2 = "#66CC99"; $row_count = 1;

// -- Following lines list the jokes in the
database 
echo " These are the jokes we have got so far"; $db =
mysql_connect("localhost","homesite","test")  or die(mysql_error());
mysql_select_db("jokes",$db); $sql = "SELECT id, JokeText, JokeDate from
jokes"; $query = mysql_query($sql); echo "
   
ID
  Joke Text
  Joke Date";
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echo"".
  "". $myrow["id"]."".
  "". $myrow["JokeText"]. "".
  "". $myrow["JokeDate"]."";
  $row_count++;
 }
echo "";

$current_url = $_SERVER['PHP_SELF'];
echo("" ."Add a Joke!");


} // end main else statement
?>

-- 
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] help in php script

2004-11-04 Thread Klaus Reimer
Klaus Reimer wrote:
This can't work. You browser tries to download an image with the name 
''. 
Ah, I'm talking nonsense. I meant "the browser tries to DISPLAY an image 
with the CONTENT ''." The browser can't do this. 
That's why you don't see anything.

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] help in php script

2004-11-04 Thread Klaus Reimer
Deepak Dhake wrote:
";
?>
did you get what i am saying? please let me know if you have some solution.
thanks
No. I must admit, It don't understand it. Let me try: You have a script 
"a.php" which outputs this static content:


b.php outputs the static content "
This can't work. You browser tries to download an image with the name 
''. I think THAT's your problem and the reason why I 
did not understand you problem. If you use a PHP script inside an img 
src attribute then this PHP-Script must output an image. Complete with 
content-type header and the image as binary data in the body.

Or another solution for a.php:

 
  
 

but I don't see the sense here. You can just do all this in one script:
= 6 and $curr_time[2] <= 17) {
  $img = 'a.jpg';
}
else {
  $img = 'b.jpg';
}
?>

 
  
 

If I still misunderstood your problem then maybe your description was 
not detailed enough.

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] help in php script

2004-11-04 Thread Deepak Dhake
PRINT is nothing but...
TimeRotateImage.php
= 6 and $curr_time[2] <= 17) {
   print "";
 }
else {
   print "";
 }
?>
this script (something like this) should be called from another script like,
";
?>
did you get what i am saying? please let me know if you have some solution.
thanks
Klaus Reimer wrote:
Deepak Dhake wrote:
But i am not getting any output if i follow the above procedure. Can 
you tell me how to do it? I have to have the script 
TimeRotateImage.php which calculates which image to print accoring to 
local time and i want to embed the file name in html tag to print it 
on screen.

It's not clear what your PRINT macros are doing. Maybe you forgot to 
send the content-type-header? Or maybe there is a script error which 
is not displayed when you call the page inside a image tag. Call the 
script directly in your browser to see what's going on. If it outputs 
binary data then everything is working but you forgot the content-type 
header.

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


[PHP] Very wierd issue with pdf's and rotating images

2004-11-04 Thread Brent Clements
I have tried this with pretty much every pdf library available to use with PHP and all 
have the same results.

1. I create a new pdf.
2. I rotate a jpeg using gd's imagerotate 
3. I output the jpeg to a new pdf page
4. I then output the pdf to the browser and/or to a file.

When I view the pdf, the image that was embedded in the pdf page has a large black 
rectangular area taking up the first 1/4 of the image.

If I do not rotate the image, there is no large black rectangular area.

Anybody has an idea what's going on?

Thanks,
Brent



Re: [PHP] Lost session variables still confounding me

2004-11-04 Thread Daniel Kullik
Stuart Felenstein wrote:
--- Jason Wong <[EMAIL PROTECTED]> wrote:

Maybe what you had before was:
   if (count($myarray) > 5)
  $_SESSION['arrayerr'] = "you have selected
too many industries";
  session_write_close();
  header ("Location: Page2.php?".SID);
  exit;
And yes that has a totally different behaviour to
the code with the "endif;" 
construct.

Yep, that is what I had.  So, no parse error, but did
not work  right either.
Stuart
So you just forgot some curly-braces then.
You'd write either
[code]
if (count($myarray) > 5) {
$_SESSION['arrayerr'] = "you have selected too many industries";
session_write_close();
header ("Location: Page2.php?".SID);
exit;
}
[/code]
or
[code]
if (count($myarray) > 5):
$_SESSION['arrayerr'] = "you have selected too many industries";
session_write_close();
header ("Location: Page2.php?".SID);
exit;
endif;
[/code]
HTH, Daniel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] pdf_stringwidth

2004-11-04 Thread blackwater dev
I am using pdf_stringwidth and only passing in the first two
parameters yet I recently updated to php 4.3.9 and it now want all 4. 
According to the manual, these where required with 5...why does 4.3.9
want them?

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



Re: [PHP] ezpublish question -- take 2

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 07:12:12 -0800 (PST), Daniel Guerrier
<[EMAIL PROTECTED]> wrote:
> Has anyone used the latest version of ezpublish?

No I haven't.

> How did you learn how to use it?

I'd read the (free) online docs first:
http://www.ez.no/ez_publish/documentation

It's a CMS system, it can't be _that_ difficult to learn to run. 
Since it's a 'system' you probably don't have to know much about PHP
to use it.

> Do you recommend
> getting the book?

Not unless the docs were insufficient.

Why not download it, install it and find out all these answers for
yourself?  It's is dual-licensed and all.  :)  Did you need some help
with installing it perhaps?


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] help in php script

2004-11-04 Thread Klaus Reimer
Deepak Dhake wrote:
But i am not getting any output if i follow the above procedure. Can you 
tell me how to do it? I have to have the script TimeRotateImage.php 
which calculates which image to print accoring to local time and i want 
to embed the file name in html tag to print it on screen.
It's not clear what your PRINT macros are doing. Maybe you forgot to 
send the content-type-header? Or maybe there is a script error which is 
not displayed when you call the page inside a image tag. Call the script 
directly in your browser to see what's going on. If it outputs binary 
data then everything is working but you forgot the content-type header.

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


[PHP] help in php script

2004-11-04 Thread Deepak Dhake
I have a following PHP file TimeRotateImage.php which prints an image
= 6 and $curr_time[2] <= 17) {
  PRINT IMAGE_1;
}
else {
  PRINT IMAGE_2;
}
?>
I want to use this script in another file to display the image. the tag 
should be


But i am not getting any output if i follow the above procedure. Can you 
tell me how to do it? I have to have the script TimeRotateImage.php 
which calculates which image to print accoring to local time and i want 
to embed the file name in html tag to print it on screen.

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


[PHP] ezpublish question -- take 2

2004-11-04 Thread Daniel Guerrier
Has anyone used the latest version of ezpublish?

How did you learn how to use it?  Do you recommend
getting the book?



__ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 

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



Re: [PHP] Sessions and threading

2004-11-04 Thread Klaus Reimer
Devraj Mukherjee wrote:
The first part of the problem is that I need to be able to at all times 
maintain a readable set of objects in memory, I am planning to achieve 
that using session variables, but I hear that session variables can 
become very inefficient, how true is that?
Very true. In Java (with Tomcat for example) you have a real session 
scope and application scope where you can put objects and directly 
access them. These objects are hold in memory and they are REAL objects 
between the requests. In PHP it's different. If a HTTP request is 
finished then the session (with all data including objects) is 
serialized and stored on the harddisk (or database or whatever the 
session backend is). On the next HTTP request the session is loaded from 
harddisk and unserialized. So new objects are created and filled with 
data from the harddisk at every request.

It would be REALLY REALLY cool to have an application-server-like thingy 
in PHP. But as far as I know there is none. Correct me if I'm wrong.


The other issue is running a thread that enable in some time interval to 
write snapshots from the log files that are being generated. Is it 
possible to have part of the script alive in some sort of a thread even 
after the script is dead. For example with the use of the sesssion 
variable.
You can write a command line PHP script and run it as a separate daemon 
or call it from the crontab.

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Sessions and threading

2004-11-04 Thread Greg Donald
On Fri, 05 Nov 2004 00:26:24 +1100, Devraj Mukherjee
<[EMAIL PROTECTED]> wrote:
> The first part of the problem is that I need to be able to at all times
> maintain a readable set of objects in memory, I am planning to achieve
> that using session variables, but I hear that session variables can
> become very inefficient, how true is that?

If you store huge variable names then it will be slower than if you
store small ones.  Same with the session variable values.

PHP sessions variables are stored as a semi-colon delimited string of
text, with other appropriate seperation characters and descriptions of
the variables included.  I minimize my session variable names to a
single character and document them somewhere for future reference.  I
make sure and store minimum values for each variable, for example the
integer 1 instead of the string 'true' or 'yes', things like that add
up.  Sessions are as efficient as you make them.

Also, PHP doesn't have threads.  You can use some of the execution
functions to simulate them to some extent however: 
http://www.php.net/manual/en/ref.exec.php


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Sessions and threading

2004-11-04 Thread Devraj Mukherjee
Hi everyone,
I am attempting to write an implementation of Prevayler 
(http://sourceforge,net/projects/prevayler), which has originally been 
written for Java and provides a prevalance layer for storing objects 
using incremental log files and taking snapshots of in fixed time intervals.

It seems the Java guys are widely using the implementation even for web 
applications. There are many advantages to using the system, backups and 
restores are very easy and reliable and it is very efficient for small 
sized projects, as the Prevayler guys claim about 9000 times faster than 
Oracle ;-)

I have near worked out everything that has to be done, I think I am 
going to try and write it as a PEAR module for it to be available to 
everyone. I am stuck with a few concepts and I thought I might float the 
ideas here to get some feedback before I start scripting.

The first part of the problem is that I need to be able to at all times 
maintain a readable set of objects in memory, I am planning to achieve 
that using session variables, but I hear that session variables can 
become very inefficient, how true is that?

The other issue is running a thread that enable in some time interval to 
write snapshots from the log files that are being generated. Is it 
possible to have part of the script alive in some sort of a thread even 
after the script is dead. For example with the use of the sesssion variable.

Any feedback is very welcome.
Kind regards,
Devraj
--
--
Devraj Mukherjee, Eternity Technologies Pty. Ltd. Australia
Host: Debian (Sarge) 3.1 Kernel 2.4.27-1-686 / GCC version 3.3.5
Target: LPD7A400 (ARM9) LogicPD eval. board / ARM GCC 3.3 GlibC 2.3.2
LAMP environment specs. Apache: 2.0.52 PHP: 5 MySQL: 4.0.21
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Shorthand functions (was: Code Snippets' you couldn't live without)

2004-11-04 Thread Klaus Reimer
Murray @ PlanetThoughtful wrote:
with exploring include files to find out what a function does or how a class
operates. I doubt half-a-dozen shorthand functions in that include file
would place a measurable strain on the readability or maintainability of a
project. 
I disagree on that. The problem here is not that the functions are 
short. The problem is, that their names gives absolutely no clue about 
what they are doing. mfr() can be mysql_free_result() but it also can be 
mysql_fetch_row(). So it's not only unreadable, it's also error-prone. 
Sure, it's possible to look up what this function is doing. But is it 
necessary? Everybody (even coders not knowing the mysql functions) can 
understand what "mysql_free_result()" is doing, without decyphering it 
first.

But I agree that many PHP functions are named too long. But this is 
because they are non-OO functions living without namespaces. So if you 
don't use OO (where you may write something short like $res->free()" you 
have to live with that, I fear. Or write shorthand functions, nobody can 
keep you from doing so. I just said, that it is problematic for more 
professional projects where new programmers may begin to work on at any 
time).

And I agree that there are even some very short function names in PHP 
like nl2br(). This looks like a bad naming, but it is not really. "nl" 
is a well known shorthand for newline. "2" makes clear that it converts 
something. And "br" is named after the HTML-Tag. So this function name 
GIVES some clues about what it is doing. But for newcomers it may not be 
clear at the beginning what this function is doing. But after a quick 
lookup the newcomer can remember the meaning very well. And I think this 
is different with functions like mfr() and asl() which gives no clue 
about their meaning.


when first viewed by someone new to PHP. Also witness the deprecation of
variables such as $HTTP_GET_VARS in favour of $_GET etc. 
$_GET and $_POST are well named. It's clear what they are doing. Thank 
god their were not named $_HGV and $_HPV.


Or the .=
concatenation assignment operator as a shorthand to $var = $var . ' added
string.' 
"$a .= $b" is not a shorthand of "$a = $a . $b". The result is the same 
but the internal processing is totally different. "$a .= $b" is a lot 
faster then "$a = $a . $b" because $b is directly appended to $a. The 
second form constructs a completely new string and overwrites the old 
value of $a. At least this is the case if no optimizer is used. Maybe 
optimizeres are transforming the second form into the first form, don't 
know.

So you can't compare this to a shorthand function. It was not introduced 
because coders are to lazy to write the long form. It was introduced 
because it is absolutely intuitive to do so if the language already has 
something like "+=". But I can't tell if these operators were introduced 
into the C programming language (or wherever it appeared first) because 
lazy coders. ;-)


Back to the intent rather than the form of my original question: what are
the code snippets you can't live without?
I already posted some. But this thread is interesting, too. So I changed 
the subject ;-)

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] how to create pdf file.

2004-11-04 Thread John Nichel
Roman Duriancik wrote:
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows 
(it dependence by mysql export) in php code.
How can i do it ?
Thank you

roman
You can either read the manual, or pay one of us to write it for you.
http://us4.php.net/pdf
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] how to create pdf file.

2004-11-04 Thread Jay Blanchard
[snip]
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows

(it dependence by mysql export) in php code.
How can i do it ?
[/snip]

http://www.php.net/pdf
http://www.fpdf.org

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



[PHP] how to create pdf file.

2004-11-04 Thread Roman Duriancik
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows 
(it dependence by mysql export) in php code.
How can i do it ?
Thank you

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


Re: [PHP] what am i doing wrong..??

2004-11-04 Thread bbonkosk
Echo out your queries!
$query = "insert into joke values('',".$_POST['joke_text'].",'date')";
---> echo $query;
$result= mysql_query($query);

This will tell you what is going on, perhaps some of the information is not set?  You 
can even copy and paste the output to run against your mysql backend on the command 
line to see if additional information/errors are present.

-B

- Original Message -
From: Aalee <[EMAIL PROTECTED]>
Date: Thursday, November 4, 2004 7:54 am
Subject: [PHP] what am i doing wrong..??

> Hi there please have a look the code below...I dont know wht am 
> doing wrong
> here...
> This code is suppose to show the number of jokes in a mysql 
> database and
> allows user to add a joke when the user clicks addjoke link. And 
> when the
> joke is added, it suppose to say that "Joke inserted, Thank you" 
> and list
> all the jokes below this line. So far am able to view all the 
> jokes and take
> the user to add joke page. But the problem is when the user clicks 
> insertjoke button, it does not display the message "Joke inserted, 
> Thank you" and
> the jokes are not listed. Infact it does not give any error 
> aswell, it just
> stays on the add joke form page. I checked the database and no 
> joke is
> added. Working on PHP ver 4.3.8 with register_globals turned OFF 
> and Apache
> 1.3.31. MySQL ver 4.0.20a on winXP pro SP1.
> Recently i started using registre_globals OFF and all these probs 
> strtedcoming up. This code was working fine with globals ON. But 
> my hosting has it
> off. So need to do so. I was able to fix all the other issues came 
> coz of
> this global thing in this code. But stuck on the issue i just 
> mentioned. Any
> help would be GREATLY appreciated.
> 
>  if (isset($_GET['addjoke'])){
> ?>
> 
>  Type your joke :
>  
>   
>  
> 
> 
> 
>  }
> else { // start main else statement
> if(isset ($_POST['insert'])) {
> $db = mysql_connect("localhost","homesite","test") ;
> mysql_select_db("jokes",$db);
> $query = mysql_query("INSERT INTO jokes SET
> JokeText = '".$_POST['jokeText']."' ,
> JokeDate = CURDATE() ");
> echo " Joke inserted, Thank you ";
> echo mysql_error();
> }
> $color1 = "#66CCFF";
> $color2 = "#66CC99";
> $row_count = 1;
> 
> // -- Following lines list the jokes in the
> database 
> echo " These are the jokes we have got so far";
> $db = mysql_connect("localhost","homesite","test")  or 
> die(mysql_error());mysql_select_db("jokes",$db);
> $sql = "SELECT id, JokeText, JokeDate from jokes";
> $query = mysql_query($sql);
> echo "
>   
>ID
>  Joke Text
>  Joke Date";
> while ($myrow = mysql_fetch_array($query))
> {
> $row_color = ($row_count % 2) ? $color1 : $color2;
>  echo"".
>  "". $myrow["id"]."".
>  "". $myrow["JokeText"]. "".
>  "". $myrow["JokeDate"]."";
>  $row_count++;
> }
> echo "";
> 
> $current_url = $_SERVER['PHP_SELF'];
> echo("" ."Add a Joke!");
> 
> 
> } // end main else statement
> ?>
> 
> -- 
> 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] what am i doing wrong..??

2004-11-04 Thread Aalee
Hi there please have a look the code below...I dont know wht am doing wrong
here...
This code is suppose to show the number of jokes in a mysql database and
allows user to add a joke when the user clicks addjoke link. And when the
joke is added, it suppose to say that "Joke inserted, Thank you" and list
all the jokes below this line. So far am able to view all the jokes and take
the user to add joke page. But the problem is when the user clicks insert
joke button, it does not display the message "Joke inserted, Thank you" and
the jokes are not listed. Infact it does not give any error aswell, it just
stays on the add joke form page. I checked the database and no joke is
added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache
1.3.31. MySQL ver 4.0.20a on winXP pro SP1.
Recently i started using registre_globals OFF and all these probs strted
coming up. This code was working fine with globals ON. But my hosting has it
off. So need to do so. I was able to fix all the other issues came coz of
this global thing in this code. But stuck on the issue i just mentioned. Any
help would be GREATLY appreciated.



  Type your joke :
  
   
  



";
 echo mysql_error();
}
$color1 = "#66CCFF";
$color2 = "#66CC99";
$row_count = 1;

// -- Following lines list the jokes in the
database 
echo " These are the jokes we have got so far";
$db = mysql_connect("localhost","homesite","test")  or die(mysql_error());
mysql_select_db("jokes",$db);
$sql = "SELECT id, JokeText, JokeDate from jokes";
$query = mysql_query($sql);
echo "
   
ID
  Joke Text
  Joke Date";
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echo"".
  "". $myrow["id"]."".
  "". $myrow["JokeText"]. "".
  "". $myrow["JokeDate"]."";
  $row_count++;
 }
echo "";

$current_url = $_SERVER['PHP_SELF'];
echo("" ."Add a Joke!");


} // end main else statement
?>

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



  1   2   >