Re: [PHP] Re: Space in regex

2006-11-17 Thread Dotan Cohen

On 17/11/06, Paul Novitski <[EMAIL PROTECTED]> wrote:

At 11/16/2006 03:19 PM, Dotan Cohen wrote:
>However, this function:
>$text=preg_replace_callback('/\[([A-Za-z0-9\|\'.-:underscore:]+)\]/i'
>, "findLinks", $text);
>Does what I want it to when there is no space, regardless of whether
>or not there is a pipe. It does not replace anything if there is a
>space.


I see your problem -- you're omitting the brackets around your
metacharacters.  I believe you should be using [:underscore:] not
:underscore: -- therefore,

 /\[([A-Za-z0-9\|\'.-[:underscore:]]+)\]/i

I'm not sure why you need those metacharacters, however; I've never
had trouble matching literal space and underscore characters, e.g. [ _]

Also:
- You don't need to escape the vertical pipe.
- You don't need to escape the apostrophe.
- You do need to escape the hyphen unless you mean it to indicate a
range, which I'm sure you don't here.


On other regexp points:

>Thanks, Paul. I've been refining my methods, and I think it's better
>(for me) to just match everything between [ and ], including spaces,
>underscores, apostrophies, and pipes. I'll explode on the pipe inside
>the function.
>
>So I thought that a simple "/\[([.]+)\]/i" should do it.

Oops:  "[.]+" will look for one or more periods.  ".+" means one or
more character of any kind.  So you'd want:

 /\[(.+)\]/i

In a case like this where you're not using any alphabetic letters in
the pattern, the -i pattern modifier is irrelevant, so I'd drop it:

 /\[(.+)\]/

Then your problem is that regexp is 'greedy' and will grab as long a
matching string as it can.  If there's more than one of your link
structures in your text, the regexp above will grab everything from
the beginning of the first link to the end of the last.  That's why I
excluded the close-bracket in my pattern:

 /\[([^]]+)]/

I know [^]] looks funny but the close-bracket doesn't need to be
escaped if it's in the first position, which includes the first
position after the negating circumflex.  I've also omitted the
backslash before the final literal close-bracket which doesn't need
one because there's no open bracket context for it to be confused with.

Regards,
Paul



Thank you Paul. The greedy bit caught me off guard a few hours ago,
but I was able to tame it. I don't remember with texactly what code
(as it's changed about fifty times since then), but I'm now starting
to really get a handle on things. Thank you very much for your
detailed explanation. This is more fun than calculus!

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

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



Re: [PHP] odd behavior of stripos() with === operator *UPDATE*

2006-11-17 Thread Michael
At 12:24 AM 11/17/2006 , Michael wrote:
>HEllo all,
>
>After pulling my hair out for several hours trying to figure out why my code
>wasn't working I built this little test and ran it, the results are interesting
>in the least, and to me, surprising. It is possible that I have done something
>wrong, but I checked and rechecked this in the documentation.
>
>It appears there is either a problem with the === operator (or my brain...)
>If you don't mind, I'd like to see what you all think.
>
>I am running php 5.2.0 on a linux redhat 9 box with Apache 2.2 (the php 5.2.0
>install is brand new, perhaps I set it up wrong?)
>
>anyway here is the code I wrote, and the output from it...
>
> $found = stripos("abcdefg", "abcdefg");
>echo "found = stripos(\"abcdefg\", \"abcdefg\");\n"
>echo "The value of found is = : $found\n"
>
>// 1a) --- needle was found in haystack THIS SHOULD BE 
> if ( $found !== FALSE ) {
>  echo "found does not equal FALSE\n"
> }
>// 1b) --- needle was found in haystack THIS SHOULD ALSO BE
> if ($found === TRUE )  {
>  echo "found is equal to TRUE\n"
> }
>
>//1c) --- needle was NOT found in haystack THIS SHOULD NOT BE
> if ( $found === FALSE )  {
>  echo "found is equal to FALSE\n"
> }
>//1d) --- needle was NOT found in haystack THIS ALSO SHOULD NOT BE
> if ($found !== TRUE )  {
>  echo "found does not equal TRUE\n"
> }
>
> $found = stripos("abcdefg", "tuvwxyz");
>
>echo "\$found = stripos(\"abcdefg\", \"tuvwxyz\");\n"
>echo "The value of found is = : $found\n"
>
>//2a) --- needle was found in haystack  THIS SHOULD NOT BE
> if ( $found !== FALSE ) {
>  echo "found does not equal FALSE\n"
> }
>//2b) --- needle was found in haystack THIS ALSO SHOULD NOT BE
> if ($found === TRUE )  {
>  echo "found is equal to TRUE\n"
> }
>
>//2c) --- needle was NOT found in haystack THIS SHOULD BE
> if ( $found === FALSE )  {
>  echo "found is equal to FALSE\n"
> }
>//2d) --- needle was NOT found in haystack THIS SHOULD ALSO BE
> if ($found !== TRUE )  {
>  echo "found does not equal TRUE\n"
> }
>
>the output:
>
>$found = stripos("abcdefg", "abcdefg");
>The value of found is = : 0 
>
>found does not equal FALSE   //this is from section 1a) of the code
>
>found does not equal TRUE//this is from section 1d) of the code
> // I expected the code from 1b) to be executed
>
>$found = stripos("abcdefg", "tuvwxyz");
>The value of found is = : 
>
>found is equal to FALSE  //this is from section 2c) of the code
>
>found does not equal TRUE//this is from section 2d) of the code
>
>I have underlined the output I am interested in... How can the variable $found
>be both TRUE and FALSE at the same time?
>
>Anyone who can provide me some insight on this, please enlighten me.
>
>If my code is correct, then this behavior of the === operator is
>counter-intuitive, it was my understanding that the === and !== operators were
>supposed to be used with the output of stripos() for just this situation, but
>=== does not appear to recognize that the returned "0" (because the string was
>found at index 0) ; whereas the !== does recognize this...
>
>is === buggy? or am I? heh
>
>thoughts? comments?
>
>Thanks all,
>Michael 
>

Hello again,

I have tested and re-tested this to the point I am confident to update this 
post with my findings...

given:  $haystack="abcdef" and $needle="abc"
any use of " stripos($haystack, $needle) === TRUE " will return a FALSE RESULT.

In other words, if there is ANY chance that $needle will be found at the very 
beginning of $haystack (index = 0), you CANNOT USE "=== TRUE", you must use 
"!== FALSE".

To me this behavior is counter-intuitive. If something is "!== FALSE", then 
"=== TRUE" should also be correct.

I understand why a string found at the beginning of another string returns an 
integer 0 (the index at which the needle was found in the haystack) from 
stripos(), however, my point is that you SHOULD be able to test this for a TRUE 
condition as well as for a FALSE.

I'm not sure why the === operator does not handle this condition, since the 
wonderful people at PHP foresaw the problem and fixed !== to handle it, I would 
like to see the === fixed to handle this as well (if it is even possible, not 
sure about how this is implemented??) 

ANyway, just posting this update for posterity, in case anyone else tries to 
test for === TRUE instead of !== FALSE with stripos() and checks here before 
they spend hours debugging their code.

If anyone sees anything I did wrong that is causing this behavior PLEASE let me 
know, I am no PHP "Guru" and I have no ego, and will humbly retract this post 
if I am wrong. I would just like to know WHY and WHERE I am wrong :)

Thank you for your time.

Regards,
Michael

ps - ok ok. I know I can just use !== FALSE, just want to let others in the 
community know about this :)

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

Re: [PHP] odd behavior of stripos() with === operator

2006-11-17 Thread Stut

Michael wrote:

Ok, picking gnits...
I should have said NOT true and NOT false at the same time.
As for the return of the integer 0..
The documentation indicates that the === and !== operators take this into 
account in fact there is a specific example in the manual.

My point here is that if !== works , why does === not?
  


I think you need to re-read the docs for ===.

   0 !== false

   0 == false

   1 == true

   1 !== true

only...

   false === false

and

   true === true

The === and !== check both value and type, so 0 and false are different.

Hope that helped.

-Stut

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



Re: [PHP] odd behavior of stripos() with === operator *UPDATE*

2006-11-17 Thread Stut

Michael wrote:

I'm not sure why the === operator does not handle this condition, since the 
wonderful people at PHP foresaw the problem and fixed !== to handle it, I would 
like to see the === fixed to handle this as well (if it is even possible, not 
sure about how this is implemented??)
  


This would not be a 'fix', this would be a break. Since !== and === are 
checking type *and* value, the logical truth of one does not necessarily 
mean the other will be false. Once you understand that it should all 
become clear.



If anyone sees anything I did wrong that is causing this behavior PLEASE let me know, I 
am no PHP "Guru" and I have no ego, and will humbly retract this post if I am 
wrong. I would just like to know WHY and WHERE I am wrong :)=
  


You're not doing anything wrong, you're just not quite getting the 
meaning of === and !== as opposed to == and !=.


-Stut

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



[PHP] Update function for content of existing CD?

2006-11-17 Thread Frank Arensmeier

Hello all.

I am looking for some ideas on how to design / structure a script  
which checks for updates on files on a existing CD ROM.


Every week, I generate content for a CD ROM containing a large number  
of html pages and PDF files (the CD is distributed to 20 - 30 dealers  
for ours) . The PHP script which is doing this is outputting a ZIP  
compressed archive. This ZIP file is then unpacked and burned on a  
CD. I am now playing with the idea to provide a "check-for-updates"  
function on the CD. Because the ZIP archives are rather large in size  
(300 MB), I am not able to keep all ZIP files. One or two months back  
is ok. My idea is to have a db table on MySQL containing  checksums  
for all files of the archive and have a script that is able to  
compare those lists. (one ZIP archive has about 400 - 500 files)


My idea is:
On the CD's start page I could have a link like: http://myserver.com/ 
look_for_updates.php?myArchiveName=2006-11-10


The script will then compare checksums for the files included in the  
archive "2006-11-10" and checksums for the recent file list. It then  
outputs a new ZIP file including new and updated files. Do you think  
that there is another (more elegant) way for doing this? Keep in mind  
that a ZIP file contains about 400-500 files which means that the  
table would grow rapidly week by week. In only one year the table  
would contain roughly 25000 rows of data.


/frank

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



Re: [PHP] odd behavior of stripos() with === operator

2006-11-17 Thread Michael
At 02:10 AM 11/17/2006 , Stut wrote:
>Michael wrote:
>> Ok, picking gnits...
>> I should have said NOT true and NOT false at the same time.
>> As for the return of the integer 0..
>> The documentation indicates that the === and !== operators take this into 
>> account in fact there is a specific example in the manual.
>>
>> My point here is that if !== works , why does === not?
>>   
>
>I think you need to re-read the docs for ===.
>
>0 !== false
>
>0 == false
>
>1 == true
>
>1 !== true
>
>only...
>
>false === false
>
>and
>
>true === true
>
>The === and !== check both value and type, so 0 and false are different.
>
>Hope that helped.
>
>-Stut
>
>-- 

Thanks for your reply Stut.

I understand that the integer 0 and FALSE are different and I read the manual 
so many times my head hurts, heh.

There are a few ways to work around this, probably more than I know. (according 
to the documentation for strrpos() you could test the return from stripos() for 
is_bool before using it), or (perhaps, cast the return from stripos() to a 
boolean, although integer 0 probably casts to false :/, I honestly didn't test 
this {see >>>}), or (easiest solution...just suck up and use !== FALSE all the 
time :D )

My point in posting this was threefold,
1) to help others who may not know that stripos() returns an INTEGER 0 when the 
needle is found at the beginning of haystack, and/or don't realize the 
implications of that.
2) My main point is that !== works, so should ===. If !== knows the difference 
between integer 0 and boolean FALSE, why doesn't ===?
3) to get feedback from the community and deepen my understanding of PHP.

So, I thank you very much for your reply :)

Regards,
Michael

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



[PHP] Hide Warnings

2006-11-17 Thread Stein Ivar Johnsen
Hi..

How can I hide Warning messages so they are not shown on screen..:
Warning: Call-time pass-by-reference has been deprecated - argument passed 
by value; If you would like to pass it by reference, modify the declaration 
of [runtime function name](). If you would like to enable call-time 
pass-by-reference, you can set allow_call_time_pass_reference to true in 
your INI file. However, future versions may not support this any longer. in 
/home/users/kivugog/Blog/index.php on line 69

I will appreciate all help on this...

-- 
Regards
sijo
http://www.dyg.no

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



Re: [PHP] odd behavior of stripos() with === operator

2006-11-17 Thread Michael
At 02:33 AM 11/17/2006 , Stut wrote:
>Michael wrote:
>> I understand that the integer 0 and FALSE are different and I read the 
>> manual so many times my head hurts, heh.
>>
>> There are a few ways to work around this, probably more than I know. 
>> (according to the documentation for strrpos() you could test the return from 
>> stripos() for is_bool before using it), or (perhaps, cast the return from 
>> stripos() to a boolean, although integer 0 probably casts to false :/, I 
>> honestly didn't test this {see >>>}), or (easiest solution...just suck up 
>> and use !== FALSE all the time :D )
>>   
>
>I'm not understanding what you need to work around. What's wrong with 
>using !== false?

Nothing at all wrong with using "!== FALSE" :) I am doing so NOW :)
However, I DIDN'T know that (integer) 0 !== FALSE and (integer) 0 === TRUE are 
not the same thing, perhaps someone else will gain from my experience here.

>
>> My point in posting this was threefold,
>> 1) to help others who may not know that stripos() returns an INTEGER 0 when 
>> the needle is found at the beginning of haystack, and/or don't realize the 
>> implications of that.
>>   
>
>The manual page for strpos and any other function that may return 0 or 
>false clearly make this point.
>
>> 2) My main point is that !== works, so should ===. If !== knows the 
>> difference between integer 0 and boolean FALSE, why doesn't ===?
>>   
>
>It does, but it also knows the difference between 1 and true, 2 and 
>true, 3 and true, etc.
>
>> 3) to get feedback from the community and deepen my understanding of PHP.
>
>I'm trying ;)

I appreciate your efforts :) Thanks again!

>
>-Stut
> 

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



Re: [PHP] odd behavior of stripos() with === operator *UPDATE*

2006-11-17 Thread Stut

Please include the list in replies.

Michael wrote:

Why can't === realize that integer 0 means TRUE? whereas "" or a BOOLEAN false 
does not? === evaluates integer 0 to FALSE :(
the !== operator recognizes the difference.

 "(integer) 0 !== FALSE" is TRUE  yet
 "(integer) 0 === TRUE" is FALSE, but it should also be TRUE.

follow? or am I really stupid heh

I value your opinion on this and if you need to take a stick to me to 
straighten me out, feel free :)


A stick? Can do!

You've said it yourself...

"(integer) 0 === TRUE" is FALSE, but it should also be TRUE.


This comparison says... Is the INTEGER 0 equal in both value *and* type 
to the BOOLEAN true? The answer of course is no. In exactly the same way 
that any comparison of different types using === will be false.


Note that this has absolutely nothing to do with the fact that the value 
you are comparing has come from strpos, it is a basic language feature. 
And it's not my opinion, it's a fact.


If that doesn't make it clear then I really don't know what will.

-Stut

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



Re: [PHP] odd behavior of stripos() with === operator

2006-11-17 Thread Stut

Michael wrote:

I understand that the integer 0 and FALSE are different and I read the manual 
so many times my head hurts, heh.

There are a few ways to work around this, probably more than I know. (according to the 
documentation for strrpos() you could test the return from stripos() for is_bool before 
using it), or (perhaps, cast the return from stripos() to a boolean, although integer 0 
probably casts to false :/, I honestly didn't test this {see >>>}), or (easiest 
solution...just suck up and use !== FALSE all the time :D )
  


I'm not understanding what you need to work around. What's wrong with 
using !== false?



My point in posting this was threefold,
1) to help others who may not know that stripos() returns an INTEGER 0 when the 
needle is found at the beginning of haystack, and/or don't realize the 
implications of that.
  


The manual page for strpos and any other function that may return 0 or 
false clearly make this point.



2) My main point is that !== works, so should ===. If !== knows the difference 
between integer 0 and boolean FALSE, why doesn't ===?
  


It does, but it also knows the difference between 1 and true, 2 and 
true, 3 and true, etc.



3) to get feedback from the community and deepen my understanding of PHP.


I'm trying ;)

-Stut

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



Re: [PHP] Hide Warnings

2006-11-17 Thread Tom Chubb

Choose one of the following, but if you are getting warnings,
something is wrong and you should address it.



On 16/11/06, Stein Ivar Johnsen <[EMAIL PROTECTED]> wrote:

Hi..

How can I hide Warning messages so they are not shown on screen..:
Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/home/users/kivugog/Blog/index.php on line 69

I will appreciate all help on this...

--
Regards
sijo
http://www.dyg.no

--
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] Hide Warnings

2006-11-17 Thread clive

Stein Ivar Johnsen wrote:

Hi..

How can I hide Warning messages so they are not shown on screen..:


look in your php.ini file and set error_reporting to an appropriate value

or

set display_errors to off

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Michael
This will be my last post on this thread of discussion.

Thanks to all who replied, I have it figured out.

I guess my only problem with the way the !== and === operators work in this 
situation is this:

Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
Regardless of the type, regardless of the species, breed, flavor etc.

if !== evaluates to TRUE then === should also under the same conditions (all 
other things being equal)

if !== evaluates an integer 0 to TRUE, so should ===, it can't be true and 
still return a false value. The !== and === operators work differently, they 
should be complimentary.

Sorry if all this has inconvenienced anyone.

Cheers,
Michael

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



[PHP] Problem with wanting something NOT to round

2006-11-17 Thread George Pitcher
Hi,

As part of a result from a web-service call, I get a price in dollars and
cents as a decimal number eg.160.44 (the example I am working on.  This
price is for permission to re-use some published material and for each
additional separate pagerange, $3 needs to be added afterwards.

So I have the following code in my script:

$range = explode(",",$pr);
$rangecounter = count($range);
$rangecounter = ($rangecounter>1?$rangecounter-1:0);
$ccc_supp =  floatval($rangecounter * 3);
$fee2 = floatval($fee + $ccc_supp);
echo sprintf("%01.2f",$fee2);

$pr is my pagerange which, in this case is 9-24, generates a rangecounter of
1, so does not get any additional $3 added.

My echo produces 160, instead of the 160.44 which I want.

Can anyone point me in the direction of a solution?

MTIA

George

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



Re: [PHP] Hide Warnings

2006-11-17 Thread Stein Ivar Johnsen
I have tried "error_reporting(0);" but this does not help. The program is 
still writing warnings to screen.
My ISP is using PHP Version 4.3.10 if that is any help.
I have no access to the PHP.INI file.

Any more ideas, please?
-- 
Regards
sijo
http://www.dyg.no



""Tom Chubb"" <[EMAIL PROTECTED]> skrev i melding 
news:[EMAIL PROTECTED]
> Choose one of the following, but if you are getting warnings,
> something is wrong and you should address it.
>
> 
> // Turn off all error reporting
> error_reporting(0);
>
> // Report simple running errors
> error_reporting(E_ERROR | E_WARNING | E_PARSE);
>
> // Reporting E_NOTICE can be good too (to report uninitialized
> // variables or catch variable name misspellings ...)
> error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
>
> // Report all errors except E_NOTICE
> // This is the default value set in php.ini
> error_reporting(E_ALL ^ E_NOTICE);
>
> // Report all PHP errors (bitwise 63 may be used in PHP 3)
> error_reporting(E_ALL);
>
> // Same as error_reporting(E_ALL);
> ini_set('error_reporting', E_ALL);
>
> ?>
>
> On 16/11/06, Stein Ivar Johnsen <[EMAIL PROTECTED]> wrote:
>> Hi..
>>
>> How can I hide Warning messages so they are not shown on screen..:
>> Warning: Call-time pass-by-reference has been deprecated - argument 
>> passed
>> by value; If you would like to pass it by reference, modify the 
>> declaration
>> of [runtime function name](). If you would like to enable call-time
>> pass-by-reference, you can set allow_call_time_pass_reference to true in
>> your INI file. However, future versions may not support this any longer. 
>> in
>> /home/users/kivugog/Blog/index.php on line 69
>>
>> I will appreciate all help on this...
>>
>> --
>> Regards
>> sijo
>> http://www.dyg.no
>>
>> --
>> 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] Hide Warnings

2006-11-17 Thread Stein Ivar Johnsen
Sorry, I have no access to my ISP's php.ini file. I need to turn off 
warnings in the php script code?

-- 
Regards
sijo
http://www.dyg.no



"clive" <[EMAIL PROTECTED]> skrev i melding 
news:[EMAIL PROTECTED]
> Stein Ivar Johnsen wrote:
>> Hi..
>>
>> How can I hide Warning messages so they are not shown on screen..:
>
> look in your php.ini file and set error_reporting to an appropriate value
>
> or
>
> set display_errors to off 

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



Re: [PHP] Problem with wanting something NOT to round

2006-11-17 Thread Stut

George Pitcher wrote:

As part of a result from a web-service call, I get a price in dollars and
cents as a decimal number eg.160.44 (the example I am working on.  This
price is for permission to re-use some published material and for each
additional separate pagerange, $3 needs to be added afterwards.

So I have the following code in my script:

$range = explode(",",$pr);
$rangecounter = count($range);
$rangecounter = ($rangecounter>1?$rangecounter-1:0);
$ccc_supp =  floatval($rangecounter * 3);
$fee2 = floatval($fee + $ccc_supp);
echo sprintf("%01.2f",$fee2);

$pr is my pagerange which, in this case is 9-24, generates a rangecounter of
1, so does not get any additional $3 added.

My echo produces 160, instead of the 160.44 which I want.

Can anyone point me in the direction of a solution?
  


Are you sure the web service is giving you 160.44? I get it displayed as 
expected...


   http://dev.stut.net/php/pitcher.php

-Stut

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



Re: [PHP] Problem with wanting something NOT to round

2006-11-17 Thread Stut

George Pitcher wrote:

Are you sure the web service is giving you 160.44? I get it displayed as
expected...

http://dev.stut.net/php/pitcher.php


Yes, I am echoing the 160.44 ok. I'm just not getting the 44c in my display
price. I'm on Windows NT - could that be a factor?


I'm not sure what you mean by "in my display price". Please elaborate?

-Stut

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



RE: [PHP] Problem with wanting something NOT to round

2006-11-17 Thread George Pitcher
> George Pitcher wrote:
> > As part of a result from a web-service call, I get a price in
> dollars and
> > cents as a decimal number eg.160.44 (the example I am working on.  This
> > price is for permission to re-use some published material and for each
> > additional separate pagerange, $3 needs to be added afterwards.
> >
> > So I have the following code in my script:
> >
> > $range = explode(",",$pr);
> > $rangecounter = count($range);
> > $rangecounter = ($rangecounter>1?$rangecounter-1:0);
> > $ccc_supp =  floatval($rangecounter * 3);
> > $fee2 = floatval($fee + $ccc_supp);
> > echo sprintf("%01.2f",$fee2);
> >
> > $pr is my pagerange which, in this case is 9-24, generates a
> rangecounter of
> > 1, so does not get any additional $3 added.
> >
> > My echo produces 160, instead of the 160.44 which I want.
> >
> > Can anyone point me in the direction of a solution?
> >
>
> Are you sure the web service is giving you 160.44? I get it displayed as
> expected...
>
> http://dev.stut.net/php/pitcher.php
>
Hi,

Yes, I am echoing the 160.44 ok. I'm just not getting the 44c in my display
price. I'm on Windows NT - could that be a factor?

George

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



Re: [PHP] Hide Warnings

2006-11-17 Thread clive

Stein Ivar Johnsen wrote:
I have tried "error_reporting(0);" but this does not help. The program is 
still writing warnings to screen.

My ISP is using PHP Version 4.3.10 if that is any help.
I have no access to the PHP.INI file.

Any more ideas, please?

fix the code thats generating the errors?

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



Re: [PHP] Hide Warnings

2006-11-17 Thread Kevin Waterson
This one time, at band camp, "Stein Ivar Johnsen" <[EMAIL PROTECTED]> wrote:

> Hi..
> 
> How can I hide Warning messages so they are not shown on screen..:

code properly...


-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

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



RE: [PHP] Problem with wanting something NOT to round

2006-11-17 Thread George Pitcher
> George Pitcher wrote:
> >> Are you sure the web service is giving you 160.44? I get it
> displayed as
> >> expected...
> >>
> >> http://dev.stut.net/php/pitcher.php
> >>
> > Yes, I am echoing the 160.44 ok. I'm just not getting the 44c
> in my display
> > price. I'm on Windows NT - could that be a factor?
>
> I'm not sure what you mean by "in my display price". Please elaborate?
>
If I paste your code (from your web-page example), into a new php file, I
get 160.44. However, replacing my existing code with the example code into
the page that is to  do the work, I get 160.00.

To simplify things, I've now done the following in the new php file and then
on my page:

$fee = 160.44;
echo "fee: ".$fee."";
$fee2 = $fee + 0.00;
echo "fee2: ".$fee2."";

I get 160.44 on the standalone page and 160.00 on my web page.

I am using PHP5.1 with Smarty templates on my page (but not on the
standalone page).

Smarty doesn't offer anything other than the sprintf() options for string
formatting of decimal numbers, and I'm already doing that.

Do you think Smarty could be so unsmart as to undo the formatting?

As another test, I did settype($fee2, "float")then the gettype($fee2) and
got 'float' on the standalone page and NULL on my Smarty page.

Truly stumped!

George

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



Re: [PHP] file_get_contents

2006-11-17 Thread Jochem Maas
Tom Chubb wrote:
> Confused!
> I'm now getting:
> file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php)
> [function.file-get-contents]: failed to open stream: Connection
> refused in
> /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php
> on line 75
> How come you can access it and I can't?!?

no php script can withstand me. ;-) seriously I don't know

> Permissions are 755.
> Obviously I was getting it when using file_get_contents('player.php')
> but when using the URL I get connection refused.
> 
> (Don't think that it makes any difference, but allow_url_fopen is on)

it makes a difference, and it sounds likes it's off - another possibility
is that safe_mode is on (and that safe_mode blocks allow_url_fopen), but I don't
know about that - you'll have to test it.

you can double check that you can reach your site from the box itself by doing a
very simple 'wget' check from the commandline (assuming you have ssh access):

wget http://www.tnhosting.co.uk/scripts/gclub/player.php

if that downloads a page then the problem is very like to be php.

> 


...

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



Re: [PHP] file_get_contents

2006-11-17 Thread Stut

Tom Chubb wrote:

Confused!
I'm now getting:
file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php)
[function.file-get-contents]: failed to open stream: Connection
refused in 
/home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php

on line 75
How come you can access it and I can't?!?
Permissions are 755.
Obviously I was getting it when using file_get_contents('player.php')
but when using the URL I get connection refused.


The domain www.tnhosting.co.uk is probably not resolving to the right IP 
when used from that box. Can't think of any other reason that would work 
remotely but not locally.


-Stut

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



Re: [PHP] Problem with wanting something NOT to round

2006-11-17 Thread Stut

George Pitcher wrote:

I am using PHP5.1 with Smarty templates on my page (but not on the
standalone page).

Smarty doesn't offer anything other than the sprintf() options for string
formatting of decimal numbers, and I'm already doing that.

Do you think Smarty could be so unsmart as to undo the formatting?

As another test, I did settype($fee2, "float")then the gettype($fee2) and
got 'float' on the standalone page and NULL on my Smarty page.
  


Sounds like a question for the Smarty mailing list.

-Stut

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



Re: [PHP] file_get_contents

2006-11-17 Thread Tom Chubb

On 17/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote:

Tom Chubb wrote:
> Confused!
> I'm now getting:
> file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php)
> [function.file-get-contents]: failed to open stream: Connection
> refused in
> /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php
> on line 75
> How come you can access it and I can't?!?

no php script can withstand me. ;-) seriously I don't know


I don't doubt it! ;-)



> Permissions are 755.
> Obviously I was getting it when using file_get_contents('player.php')
> but when using the URL I get connection refused.
>
> (Don't think that it makes any difference, but allow_url_fopen is on)

it makes a difference, and it sounds likes it's off - another possibility
is that safe_mode is on (and that safe_mode blocks allow_url_fopen), but I don't
know about that - you'll have to test it.



phpinfo() says that allow_url_fopen is on and safe mode is off


you can double check that you can reach your site from the box itself by doing a
very simple 'wget' check from the commandline (assuming you have ssh access):

   wget http://www.tnhosting.co.uk/scripts/gclub/player.php

if that downloads a page then the problem is very like to be php.

>


Don't have shell access on my shared server



...



Did manage to get it working though using

$player = file_get_contents('player.php');
//Strip out unnecessary HTML
if(preg_match('/(.*)/s', $player, $matches)) {
$content = $matches[1];
}

function phpWrapper($content) {
ob_start();
$content = str_replace('<'.'?php','<'.'?',$content);
eval('?'.'>'.trim($content).'<'.'?');
$content = ob_get_contents();
ob_end_clean();
return $content;
}

echo "" .
phpWrapper($content) . "";


Bit messy, but it works at least. :D
Thanks for your help though.

T

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



Re: [PHP] Update function for content of existing CD?

2006-11-17 Thread Jochem Maas
Frank Arensmeier wrote:
> Hello all.
> 
> I am looking for some ideas on how to design / structure a script which
> checks for updates on files on a existing CD ROM.
> 
> Every week, I generate content for a CD ROM containing a large number of
> html pages and PDF files (the CD is distributed to 20 - 30 dealers for
> ours) . The PHP script which is doing this is outputting a ZIP
> compressed archive. This ZIP file is then unpacked and burned on a CD. I
> am now playing with the idea to provide a "check-for-updates" function
> on the CD. Because the ZIP archives are rather large in size (300 MB), I
> am not able to keep all ZIP files. One or two months back is ok. My idea
> is to have a db table on MySQL containing  checksums for all files of
> the archive and have a script that is able to compare those lists. (one
> ZIP archive has about 400 - 500 files)
> 
> My idea is:
> On the CD's start page I could have a link like:
> http://myserver.com/look_for_updates.php?myArchiveName=2006-11-10

this implies an internet connection - why not just give them a website
in the first place? then all they have to do is hit refresh.

> 
> The script will then compare checksums for the files included in the
> archive "2006-11-10" and checksums for the recent file list. It then
> outputs a new ZIP file including new and updated files. Do you think
> that there is another (more elegant) way for doing this? Keep in mind
> that a ZIP file contains about 400-500 files which means that the table
> would grow rapidly week by week. In only one year the table would
> contain roughly 25000 rows of data.
> 
> /frank
> 
> --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] file_get_contents

2006-11-17 Thread Tom Chubb

Very interesting!
I have a reseller account and on another site, the DNS entries were
messed up by the host. Could be a similar problem.
Thanks

On 17/11/06, Stut <[EMAIL PROTECTED]> wrote:

Tom Chubb wrote:
> Confused!
> I'm now getting:
> file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php)
> [function.file-get-contents]: failed to open stream: Connection
> refused in
> /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php
> on line 75
> How come you can access it and I can't?!?
> Permissions are 755.
> Obviously I was getting it when using file_get_contents('player.php')
> but when using the URL I get connection refused.

The domain www.tnhosting.co.uk is probably not resolving to the right IP
when used from that box. Can't think of any other reason that would work
remotely but not locally.

-Stut



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



RE: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Ford, Mike
On 17 November 2006 09:55, Michael wrote:

> This will be my last post on this thread of discussion.
> 
> Thanks to all who replied, I have it figured out.
> 
> I guess my only problem with the way the !== and ===
> operators work in this situation is this:
> 
> Logic dictates that if something evaluates to NOT FALSE it
> must be TRUE.

Um, yes, but it's the *test* that's evaluating to NOT FALSE (and obeys this 
rule), which says nothing about the actual values involved in the test.  Even 
with the != operator you can demonstrate this point:

   $x = "yes";
   if ($x!=FALSE) { echo "\$x must be TRUE" }

will display the message, even though $x contains the string "yes" (because the 
string "yes" in a Boolean context evaluates to TRUE).

> if !== evaluates to TRUE then === should also under the same
> conditions (all other things being equal)

I don't think that's quite what you meant, but I think I understand the point 
you were getting at, and it's not valid.  If something !==FALSE, then TRUE is 
one of the values it may be === to -- but so are all the integers, all the 
floating numbers, all the strings, all possible objects, 

In other words, if $x!==FALSE, it *might* be ===TRUE, but it *might* also be 
===0, ===1, ===1.0 (not the same as 1!), ==="hello world", etc.

The *test* *itself*, however, would obey that rule -- that the *test* returns a 
Boolean value says nothing about the types of its operands.

> if !== evaluates an integer 0 to TRUE, so should ===

Neither of them can evaluate an integer 0 to TRUE, as 0 and TRUE are different 
types. You're confusing how these operators evaluate their operands with the 
resulting value of the test: the === and !== operators will both evaluate an 
integer 0 as 0 -- it's the result of the test that will be strictly either TRUE 
or FALSE. (As it happens, 0 and FALSE also give different values when evaluated 
by ==/!=, so you'd have the same conceptual problem with those operators).

> , it
> can't be true and still return a false value. The !== and ===
> operators work differently, they should be complimentary.

No, they work exactly the same.  Both of them *first* look at the types of the 
two values, and *if and only if* the types are the same are the values compared.

So: 0!==FALSE will succeed immediately, returning TRUE, because the types differ
and: 0===FALSE will fail immediately, returning FALSE, because the types differ

which are as you expected the complementary Boolean values.

*However*:

1!==FALSE returns TRUE by the same logic, and
1===TRUE returns the complementary FALSE

Immediately, then, you can see that we have two values that are both !==FALSE, 
and yet neither of them is the value TRUE.

I'm afraid I've gone on at some length here, but I felt throughout this thread 
that you really hadn't grasped the underlying conceptual point, and I hope some 
of my examples may have helped illuminate it for you.

Cheers!

Mike

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


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] file_get_contents

2006-11-17 Thread Tom Chubb

The host support team told me that:
Our servers do not allows a HTTP connection onto itself. This is a
security precaution to stop recursive code. You can try to reference
the code by path rather than HTTP
...which works fine!



On 17/11/06, Tom Chubb <[EMAIL PROTECTED]> wrote:

Very interesting!
I have a reseller account and on another site, the DNS entries were
messed up by the host. Could be a similar problem.
Thanks

On 17/11/06, Stut <[EMAIL PROTECTED]> wrote:
> Tom Chubb wrote:
> > Confused!
> > I'm now getting:
> > file_get_contents(http://www.tnhosting.co.uk/scripts/gclub/player.php)
> > [function.file-get-contents]: failed to open stream: Connection
> > refused in
> > /home/sites/tnhosting.co.uk/public_html/scripts/gclub/updateplaylist.php
> > on line 75
> > How come you can access it and I can't?!?
> > Permissions are 755.
> > Obviously I was getting it when using file_get_contents('player.php')
> > but when using the URL I get connection refused.
>
> The domain www.tnhosting.co.uk is probably not resolving to the right IP
> when used from that box. Can't think of any other reason that would work
> remotely but not locally.
>
> -Stut
>




--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



Re: [PHP] file_get_contents

2006-11-17 Thread Stut

Tom Chubb wrote:

The host support team told me that:
Our servers do not allows a HTTP connection onto itself. This is a
security precaution to stop recursive code. You can try to reference
the code by path rather than HTTP
...which works fine!


Won't something like this work...

ob_start();
// If needed you can set up vars used by player.php here
include('player.php');
$code = ob_get_contents();
ob_end_clean();

That will capture any output from player.php and stuff it into $code. 
Much nicer than anything else suggested so far.


-Stut

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



Re: [PHP] file_get_contents

2006-11-17 Thread Jochem Maas
Stut wrote:
> Tom Chubb wrote:
>> The host support team told me that:
>> Our servers do not allows a HTTP connection onto itself. This is a
>> security precaution to stop recursive code. 

morons

';
teachTheIdiotSysAdmin();
}

?>

>> You can try to reference
>> the code by path rather than HTTP
>> ...which works fine!
> 
> Won't something like this work...
> 
> ob_start();
> // If needed you can set up vars used by player.php here
> include('player.php');
> $code = ob_get_contents();
> ob_end_clean();
> 
> That will capture any output from player.php and stuff it into $code.
> Much nicer than anything else suggested so far.

yes indeed - actually this is the best solution - no eval, no extra
request. good catch Stut

> 
> -Stut
> 

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



RE: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Brad Fuller
> > Logic dictates that if something evaluates to NOT FALSE it
> > must be TRUE.

In a situation where you are only dealing with boolean values, that above
statement would be correct.  In this case it is not.

int stripos ( string haystack, string needle [, int offset] )

What you are missing here is the fact that this function is designed to tell
you the position of the needle in your haystack, thus it returns an integer
value unless the string is not found.

Since 0 is a valid position and 0 does not evaluate to TRUE, you cannot
check for a TRUE condition.  You must check for "NOT FALSE".

I think the way you are using this function is to simply see if the needle
is contained within the haystack.


function found_in_string($haystack, $needle) {
$retval = FALSE;
if (stripos($haystack, $needle) !== FALSE) {
$retval = TRUE;
}
return $retval;
}

This function would return only TRUE or FALSE, thus you could conclude that
if the return value is NOT FALSE it _must_ be TRUE.


I hope that helps clarify a bit.

-B


> -Original Message-
> From: Ford, Mike [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 17, 2006 7:15 AM
> To: Michael
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] odd behavior of stripos() with === operator *LAST POST*
> 
> On 17 November 2006 09:55, Michael wrote:
> 
> > This will be my last post on this thread of discussion.
> >
> > Thanks to all who replied, I have it figured out.
> >
> > I guess my only problem with the way the !== and ===
> > operators work in this situation is this:
> >
> > Logic dictates that if something evaluates to NOT FALSE it
> > must be TRUE.
> 
> Um, yes, but it's the *test* that's evaluating to NOT FALSE (and obeys
> this rule), which says nothing about the actual values involved in the
> test.  Even with the != operator you can demonstrate this point:
> 
>$x = "yes";
>if ($x!=FALSE) { echo "\$x must be TRUE" }
> 
> will display the message, even though $x contains the string "yes"
> (because the string "yes" in a Boolean context evaluates to TRUE).
> 
> > if !== evaluates to TRUE then === should also under the same
> > conditions (all other things being equal)
> 
> I don't think that's quite what you meant, but I think I understand the
> point you were getting at, and it's not valid.  If something !==FALSE,
> then TRUE is one of the values it may be === to -- but so are all the
> integers, all the floating numbers, all the strings, all possible objects,
> 
> 
> In other words, if $x!==FALSE, it *might* be ===TRUE, but it *might* also
> be ===0, ===1, ===1.0 (not the same as 1!), ==="hello world", etc.
> 
> The *test* *itself*, however, would obey that rule -- that the *test*
> returns a Boolean value says nothing about the types of its operands.
> 
> > if !== evaluates an integer 0 to TRUE, so should ===
> 
> Neither of them can evaluate an integer 0 to TRUE, as 0 and TRUE are
> different types. You're confusing how these operators evaluate their
> operands with the resulting value of the test: the === and !== operators
> will both evaluate an integer 0 as 0 -- it's the result of the test that
> will be strictly either TRUE or FALSE. (As it happens, 0 and FALSE also
> give different values when evaluated by ==/!=, so you'd have the same
> conceptual problem with those operators).
> 
> > , it
> > can't be true and still return a false value. The !== and ===
> > operators work differently, they should be complimentary.
> 
> No, they work exactly the same.  Both of them *first* look at the types of
> the two values, and *if and only if* the types are the same are the values
> compared.
> 
> So: 0!==FALSE will succeed immediately, returning TRUE, because the types
> differ
> and: 0===FALSE will fail immediately, returning FALSE, because the types
> differ
> 
> which are as you expected the complementary Boolean values.
> 
> *However*:
> 
> 1!==FALSE returns TRUE by the same logic, and
> 1===TRUE returns the complementary FALSE
> 
> Immediately, then, you can see that we have two values that are both
> !==FALSE, and yet neither of them is the value TRUE.
> 
> I'm afraid I've gone on at some length here, but I felt throughout this
> thread that you really hadn't grasped the underlying conceptual point, and
> I hope some of my examples may have helped illuminate it for you.
> 
> Cheers!
> 
> Mike
> 
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211
> 
> 
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: h

Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Robert Cummings
On Fri, 2006-11-17 at 02:54 -0700, Michael wrote:
> This will be my last post on this thread of discussion.
> 
> Thanks to all who replied, I have it figured out.
> 
> I guess my only problem with the way the !== and === operators work in this 
> situation is this:
> 
> Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
> Regardless of the type, regardless of the species, breed, flavor etc.

Sure logic dictates that if a return type is confined to the boolean set
then if it is not false it must be true; however, strpos() may return a
value from the set of booleans or a value from the set of integers. As
such, it can have many more return values than only 2.

> if !== evaluates to TRUE then === should also under the same conditions (all 
> other things being equal)

Nope. There are two conditions checkeck when using !== and ===. One
check is the type, the other check is the value. This leaves 4 possible
scenarios:

true  - if an only if the type an the value are the same
false - if the type is not the same
false - if the value is not the same
false - if the type and value are not the same

> if !== evaluates an integer 0 to TRUE, so should ===, it can't be true and 
> still return a false value.

An integer 0 is not evaluated to true, a comparison to see if an value
is exactly equal to the integer 0 may return true.

>  The !== and === operators work differently, they should be
> complimentary.

Actually they work the same... I'll demonstrate:



So there you have it. The implementation of not_equals_equals() uses
the ! operator on the equals_equals_equals() function and this will give
you the same behaviour as your currently experiencing and having trouble
swallowing.

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

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



[PHP] Converting array keys to variables?

2006-11-17 Thread Ashley M. Kirchner


   I have an array that looks like this:

   [hours] => Array
   (
   [0] => Array
   (
   [file] => capture.0400.jpg
   [path] => spool/.2006/11/17/04
   [year] => 2006
   [month] => 11
   [day] => 17
   [hhmm] => 0400
   )

   [1] => Array
   (
   [file] => capture.0500.jpg
   [path] => spool/.2006/11/17/05
   [year] => 2006
   [month] => 11
   [day] => 17
   [hhmm] => 0500
   )
   )

   Is there a way that I can simply loop through each array and convert 
the keys into variables?  I want to avoid having to write lines of:


   $file = $array[0][file];
   $path = $array[0][path];
   $year = $array[0][year];
   $month = $array[0][month];
   $day = $array[0][day];
   $hhmm = $array[0][hhmm];

   -- A

--
W | It's not a bug - it's an undocumented feature.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / Websmith . 800.441.3873 x130
 Photo Craft Imaging   . 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.

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



Re: [PHP] Converting array keys to variables?

2006-11-17 Thread Chris Boget
   Is there a way that I can simply loop through each array and convert 
the keys into variables?  I want to avoid having to write lines of:


Look into extract().
http://us3.php.net/manual/en/function.extract.php

thnx,
Chris

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Jochem Maas
Robert Cummings wrote:
> On Fri, 2006-11-17 at 02:54 -0700, Michael wrote:
>> This will be my last post on this thread of discussion.
>>
>> Thanks to all who replied, I have it figured out.
>>
>> I guess my only problem with the way the !== and === operators work in this 
>> situation is this:
>>
>> Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
>> Regardless of the type, regardless of the species, breed, flavor etc.
> 
> Sure logic dictates that if a return type is confined to the boolean set
> then if it is not false it must be true; however, strpos() may return a
> value from the set of booleans or a value from the set of integers. As


liar liar pants on fire. just to confuse matters (the OP deserves it given the 
length of the thread):
strpos() may return a boolean false or a value from the set of integers - it 
will never
ever return true (unless you hack the php source)

friday afternoon nitpicking - which is sometimes referred to as 'ant-***ing' 
where I come from ;-)

> such, it can have many more return values than only 2.
> 
>> if !== evaluates to TRUE then === should also under the same conditions (all 
>> other things being equal)
> 
> Nope. There are two conditions checkeck when using !== and ===. One
> check is the type, the other check is the value. This leaves 4 possible
> scenarios:
> 
> true  - if an only if the type an the value are the same
> false - if the type is not the same
> false - if the value is not the same
> false - if the type and value are not the same
> 
>> if !== evaluates an integer 0 to TRUE, so should ===, it can't be true and 
>> still return a false value.
> 
> An integer 0 is not evaluated to true, a comparison to see if an value
> is exactly equal to the integer 0 may return true.
> 
>>  The !== and === operators work differently, they should be
>> complimentary.
> 
> Actually they work the same... I'll demonstrate:
> 
>  
> function equals_equals_equals( $value1, $value2 )
> {
> if( get_type( $value1 ) == get_type( $value2 )
> &&
> $value1 == $value2 )
> {
> return true;
> }
> 
> return false;
> }
> 
> function not_equals_equals( $value1, $value2 )
> {
> return !equals_equals_equals( $value1, $value2 );
> }
> 
> ?>
> 
> So there you have it. The implementation of not_equals_equals() uses
> the ! operator on the equals_equals_equals() function and this will give
> you the same behaviour as your currently experiencing and having trouble
> swallowing.
> 
> Cheers,
> Rob.

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



Re: [PHP] Converting array keys to variables?

2006-11-17 Thread Robert Cummings
On Fri, 2006-11-17 at 09:23 -0700, Ashley M. Kirchner wrote:
> I have an array that looks like this:
> 
> [hours] => Array
> (
> [0] => Array
> (
> [file] => capture.0400.jpg
> [path] => spool/.2006/11/17/04
> [year] => 2006
> [month] => 11
> [day] => 17
> [hhmm] => 0400
> )
> 
> [1] => Array
> (
> [file] => capture.0500.jpg
> [path] => spool/.2006/11/17/05
> [year] => 2006
> [month] => 11
> [day] => 17
> [hhmm] => 0500
> )
> )
> 
> Is there a way that I can simply loop through each array and convert 
> the keys into variables?  I want to avoid having to write lines of:
> 
> $file = $array[0][file];
> $path = $array[0][path];
> $year = $array[0][year];
> $month = $array[0][month];
> $day = $array[0][day];
> $hhmm = $array[0][hhmm];



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

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Robert Cummings
On Fri, 2006-11-17 at 17:29 +0100, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Fri, 2006-11-17 at 02:54 -0700, Michael wrote:
> >> This will be my last post on this thread of discussion.
> >>
> >> Thanks to all who replied, I have it figured out.
> >>
> >> I guess my only problem with the way the !== and === operators work in 
> >> this situation is this:
> >>
> >> Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
> >> Regardless of the type, regardless of the species, breed, flavor etc.
> > 
> > Sure logic dictates that if a return type is confined to the boolean set
> > then if it is not false it must be true; however, strpos() may return a
> > value from the set of booleans or a value from the set of integers. As
> 
> 
> liar liar pants on fire. just to confuse matters (the OP deserves it given 
> the length of the thread):
> strpos() may return a boolean false or a value from the set of integers - it 
> will never
> ever return true (unless you hack the php source)

Where's my baseball bat... ;) Anyways, if you re-read
the above I wrote "strpos() may return a value from the set of booleans
or a value from the set of integers" I didn't say WHICH value it would
return from the set of booleans *PTTHTHTHTHTTHTT* *nyah nyah* :D

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

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



Re: [PHP] Converting array keys to variables?

2006-11-17 Thread Jochem Maas
Ashley M. Kirchner wrote:
> 
>I have an array that looks like this:
> 
>[hours] => Array
>(
>[0] => Array
>(
>[file] => capture.0400.jpg
>[path] => spool/.2006/11/17/04
>[year] => 2006
>[month] => 11
>[day] => 17
>[hhmm] => 0400
>)
> 
>[1] => Array
>(
>[file] => capture.0500.jpg
>[path] => spool/.2006/11/17/05
>[year] => 2006
>[month] => 11
>[day] => 17
>[hhmm] => 0500
>)
>)\


foreach ($yourArr['hours'] as $data) {
/* now just reference the values in the array $data e.g. */

$img = file_get_contents($data['path'].'/'.$data['file']);
echo $data['hhmm'],' 
',$data['day'],'-',$data['month'],'-',$data['year'];
}

the idea is to avoid copying data into variables when it's not needed ...

> 
>Is there a way that I can simply loop through each array and convert
> the keys into variables?  I want to avoid having to write lines of:
> 
>$file = $array[0][file];
>$path = $array[0][path];
>$year = $array[0][year];
>$month = $array[0][month];
>$day = $array[0][day];
>$hhmm = $array[0][hhmm];

where the  are your quotes for the array keys? have an E_NOTICE or six.

> 
>-- A
> 

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Jochem Maas
Robert Cummings wrote:
> On Fri, 2006-11-17 at 17:29 +0100, Jochem Maas wrote:
>> Robert Cummings wrote:
>>> On Fri, 2006-11-17 at 02:54 -0700, Michael wrote:
 This will be my last post on this thread of discussion.

 Thanks to all who replied, I have it figured out.

 I guess my only problem with the way the !== and === operators work in 
 this situation is this:

 Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
 Regardless of the type, regardless of the species, breed, flavor etc.
>>> Sure logic dictates that if a return type is confined to the boolean set
>>> then if it is not false it must be true; however, strpos() may return a
>>> value from the set of booleans or a value from the set of integers. As
>>
>> liar liar pants on fire. just to confuse matters (the OP deserves it given 
>> the length of the thread):
>> strpos() may return a boolean false or a value from the set of integers - it 
>> will never
>> ever return true (unless you hack the php source)
> 
> Where's my baseball bat... ;) Anyways, if you re-read
> the above I wrote "strpos() may return a value from the set of booleans
> or a value from the set of integers" I didn't say WHICH value it would
> return from the set of booleans *PTTHTHTHTHTTHTT* *nyah nyah* :D

indeeed you didn't say which - thereby implying (or at least allowing for 
people to
assume) that any value in the set of booleans could be returned. which is not 
true.

but then this is the friday freakshow and you and I both know what we're 
talking about so
no harm done ;-)

have a good weekend!

PS - you swing like a five year old ... girl :-P

> 
> Cheers,
> Rob.

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread tedd

At 2:54 AM -0700 11/17/06, Michael wrote:

Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
Regardless of the type, regardless of the species, breed, flavor etc.


Not true -- it depends upon your reference/environment.

For example, NULL is neither true nor false in MySQL. So, the result 
in a MySQL test could be both NOT FALSE and NOT TRUE.


tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Stut
Ok, just to shut you all up, I managed to convince the OP earlier today, 
but it never made it to the list...


Michael wrote:

At 02:58 AM 11/17/2006 , Stut wrote:
  

Michael wrote:


This will be my last post on this thread of discussion.

Thanks to all who replied, I have it figured out.

I guess my only problem with the way the !== and === operators work in this 
situation is this:

Logic dictates that if something evaluates to NOT FALSE it must be TRUE.
Regardless of the type, regardless of the species, breed, flavor etc.

if !== evaluates to TRUE then === should also under the same conditions (all 
other things being equal)

if !== evaluates an integer 0 to TRUE, so should ===, it can't be true and 
still return a false value. The !== and === operators work differently, they 
should be complimentary.

Sorry if all this has inconvenienced anyone.
  
  

Ok, off-list because it will start to annoy people.

Your basic misunderstanding is that === is the opposite of !== which 
it's not.


As I've said in previous emails...

   (INTEGER === true) will always be false because the types don't match
   (INTEGER !== true) will always be true because the types don't match
   (INTEGER === false) will always be false because the types don't match
   (INTEGER === true) will always be false because the types don't match

The actual value of the INTEGER does not matter.

But the basic thing to get clear in your head is that === and !== are 
not opposites in the same way that == and != are.


Does that make it clearer?

-Stut




 OK I lied, that wasn't my last post , sorry.

*lightbulb*

Stut, thanks for your help, my thinking that !== and === are opposites is 
exactly the problem :)

I WAS thinking of them as being like != and ==.

the stick worked I think :)
I finally get it.

Thanks again.

Cheers,
Michael


-Stut

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



Re: [PHP] Converting array keys to variables?

2006-11-17 Thread Ashley M. Kirchner

Jochem Maas wrote:

   $file = $array[0][file];
   $path = $array[0][path];
   $year = $array[0][year];
   $month = $array[0][month];
   $day = $array[0][day];
   $hhmm = $array[0][hhmm];



where the  are your quotes for the array keys? have an E_NOTICE or six.
  
   I was typing fast and didn't bother to put them in when I was 
composing my e-mail.  They did exist in the actual code, though it's now 
a moot point as I'm not doing it that way anymore. :)


   Thanks for bringing it up though.

--
W | It's not a bug - it's an undocumented feature.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / Websmith . 800.441.3873 x130
 Photo Craft Imaging   . 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.

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



RE: [PHP] odd behavior of stripos() with === operator *LAST POST*

2006-11-17 Thread Ford, Mike
On 17 November 2006 16:50, Stut wrote:

> > > Your basic misunderstanding is that === is the opposite of !==
> > > which it's not.

Complete rubbish -- it so absolutely is!

If $a===$b, then !($a===$b) is the same as $a!==$b, QED.

 
> > >(INTEGER === true) will always be false because the types
> > >don't match
> > >(INTEGER !== true) will always be true because the types
> > >don't match
> > >(INTEGER === false) will always be false because the types
> > >don't match
> > >(INTEGER === true) will always be false because the types
> > >don't match 

Well, you haven't covered all bases there, you've got INTEGER===true in twice!

Try this:

(integer)===TRUE  -- is always FALSE
(integer)!==TRUE  -- is always TRUE

(integer)===FALSE -- is always FALSE
(integer)!==FALSE -- is always TRUE

Looks seriously like two sets of complementary results there to me.


> > > The actual value of the INTEGER does not matter.

True.

> > > But the basic thing to get clear in your head is that === and !==
> > > are not opposites in the same way that == and != are.

False, false, false, and a thousand times false.  If $a===$b returns TRUE, then 
$a!==$b returns FALSE; and if $a===$b returns FALSE, then $a!==$b returns TRUE. 
 I don't know how much more opposite you can get.

Cheers!

Mike

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



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] count string within a string

2006-11-17 Thread Børge Holen
I've figured out I need the substr_count function.
However, counting strings like this: [1] [2] [3] ... [215] ... 
inside a large string element. damn. 
The string got quite a few different numbers and keys but the main key is 
alway within [] and is numeric.
I imagine I could use a $counter++.
I just dont see how I should aproach this.

Anyone got an Idea?

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] Hide Warnings

2006-11-17 Thread Eric Butera

On 11/17/06, Stein Ivar Johnsen <[EMAIL PROTECTED]> wrote:

Sorry, I have no access to my ISP's php.ini file. I need to turn off
warnings in the php script code?

--
Regards
sijo
http://www.dyg.no



"clive" <[EMAIL PROTECTED]> skrev i melding
news:[EMAIL PROTECTED]
> Stein Ivar Johnsen wrote:
>> Hi..
>>
>> How can I hide Warning messages so they are not shown on screen..:
>
> look in your php.ini file and set error_reporting to an appropriate value
>
> or
>
> set display_errors to off

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




Maybe you know this because you want warnings off, but I'll say it
anyways.  Your host is doing a disservice to you with display_warnings
on.  When you have an error in your script it shows potential bad
people the complete path to your script and all sorts of other data
allowing them to tamper more easily.

Another great example is the mysql_query() or die(here is my complete
sql statement please tamper with it).  I would encourage you to plead
with your host to turn off display_errors and allow logging them.
This way you can handle your errors gracefully with
set_error_handler() without showing the world errors that can be
exploited.

I'm not sure if it is possible but maybe it can be turned off in a
htaccess file or within the virtual itself?

Also you should listen to everyone else on fixing your code.  My rant
above is based on the fact that just because you wrote and tested
something to work properly today doesn't mean a change tomorrow that
could potentially cause errors throwing more sensitive data to the end
user.  Maybe if you don't know how to fix the warning you received you
could post the code that is giving you a problem.

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



Re: [PHP] count string within a string

2006-11-17 Thread Eric Butera

On 11/17/06, Børge Holen <[EMAIL PROTECTED]> wrote:

I've figured out I need the substr_count function.
However, counting strings like this: [1] [2] [3] ... [215] ...
inside a large string element. damn.
The string got quite a few different numbers and keys but the main key is
alway within [] and is numeric.
I imagine I could use a $counter++.
I just dont see how I should aproach this.

Anyone got an Idea?

--
---
Børge
Kennel Arivene
http://www.arivene.net
---

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




Apologies if I missed what you were after.. but maybe you might try this:

http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Additional query for number of records in table

2006-11-17 Thread afan
hi,
I have query to select products for specific category from DB, something
like:
SELECT prod_id, prod_name,...
FROM products
LIMIT $From, $To

where $From and $To values depend of on what page you are. let say there
are 100 products and I'm listing 25 products per page. for page 1 $From=0,
$To=24. for page 2 $From=25 and$To=49, etc.

works fine.

though, to calculate how many pages I have I need total number of records.
do I have to run first a query (something like SELECT COUNT(*) as
NoOfRecords FROM products) and then query above or there is solution to
have both info using one query?

as a solution, I can run a query to grab all records and then list just 25
products but I think it's not so smart idea :)

thanks for any help.

-afan

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



Re: [PHP] Additional query for number of records in table

2006-11-17 Thread Brad Bonkoski

[EMAIL PROTECTED] wrote:

hi,
I have query to select products for specific category from DB, something
like:
SELECT prod_id, prod_name,...
FROM products
LIMIT $From, $To

where $From and $To values depend of on what page you are. let say there
are 100 products and I'm listing 25 products per page. for page 1 $From=0,
$To=24. for page 2 $From=25 and$To=49, etc.

works fine.

though, to calculate how many pages I have I need total number of records.
do I have to run first a query (something like SELECT COUNT(*) as
NoOfRecords FROM products) and then query above or there is solution to
have both info using one query?

as a solution, I can run a query to grab all records and then list just 25
products but I think it's not so smart idea :)

thanks for any help.

-afan

  
I would say the select count(*) from ... query would be a fairly low 
cost query.
Perhaps you could store off the number of rows in a session variable so 
you don't have to execute the count query when you move to the next page.

-B

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



Re: [PHP] Additional query for number of records in table

2006-11-17 Thread afan
> [EMAIL PROTECTED] wrote:
>> hi,
>> I have query to select products for specific category from DB, something
>> like:
>> SELECT prod_id, prod_name,...
>> FROM products
>> LIMIT $From, $To
>>
>> where $From and $To values depend of on what page you are. let say there
>> are 100 products and I'm listing 25 products per page. for page 1
>> $From=0,
>> $To=24. for page 2 $From=25 and$To=49, etc.
>>
>> works fine.
>>
>> though, to calculate how many pages I have I need total number of
>> records.
>> do I have to run first a query (something like SELECT COUNT(*) as
>> NoOfRecords FROM products) and then query above or there is solution to
>> have both info using one query?
>>
>> as a solution, I can run a query to grab all records and then list just
>> 25
>> products but I think it's not so smart idea :)
>>
>> thanks for any help.
>>
>> -afan
>>
>>
> I would say the select count(*) from ... query would be a fairly low
> cost query.
> Perhaps you could store off the number of rows in a session variable so
> you don't have to execute the count query when you move to the next page.
> -B
>

not bad idea at all.
:)

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



RE: [PHP] Additional query for number of records in table

2006-11-17 Thread Ray Hauge
I've run into this before, and if you use MySQL you can do something
like this:

SELECT SQL_CALC_FOUND_ROWS * FROM Products LIMIT $From, $To

SELECT FOUND_ROWS()

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html

The second query will give you the number of rows that would have been
returned without the LIMIT clause.  There's no way to do it with one
query though... at least easily or quickly.

Ray

-Original Message-
From: Brad Bonkoski [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 17, 2006 1:57 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] Additional query for number of records in table

[EMAIL PROTECTED] wrote:
> hi,
> I have query to select products for specific category from DB,
something
> like:
> SELECT prod_id, prod_name,...
> FROM products
> LIMIT $From, $To
>
> where $From and $To values depend of on what page you are. let say
there
> are 100 products and I'm listing 25 products per page. for page 1
$From=0,
> $To=24. for page 2 $From=25 and$To=49, etc.
>
> works fine.
>
> though, to calculate how many pages I have I need total number of
records.
> do I have to run first a query (something like SELECT COUNT(*) as
> NoOfRecords FROM products) and then query above or there is solution
to
> have both info using one query?
>
> as a solution, I can run a query to grab all records and then list
just 25
> products but I think it's not so smart idea :)
>
> thanks for any help.
>
> -afan
>
>   
I would say the select count(*) from ... query would be a fairly low 
cost query.
Perhaps you could store off the number of rows in a session variable so 
you don't have to execute the count query when you move to the next
page.
-B

-- 
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] Additional query for number of records in table

2006-11-17 Thread afan
> I've run into this before, and if you use MySQL you can do something
> like this:
>
> SELECT SQL_CALC_FOUND_ROWS * FROM Products LIMIT $From, $To
>
> SELECT FOUND_ROWS()
>
> http://dev.mysql.com/doc/refman/5.0/en/information-functions.html
>
> The second query will give you the number of rows that would have been
> returned without the LIMIT clause.  There's no way to do it with one
> query though... at least easily or quickly.
>
I have to test it because I use 4 tables in the query. But, I think is
worth trying. At least will learn something new.
:)

Thanks Ray


-afan





> Ray
>
> -Original Message-
> From: Brad Bonkoski [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 17, 2006 1:57 PM
> To: [EMAIL PROTECTED]
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Additional query for number of records in table
>
> [EMAIL PROTECTED] wrote:
>> hi,
>> I have query to select products for specific category from DB,
> something
>> like:
>> SELECT prod_id, prod_name,...
>> FROM products
>> LIMIT $From, $To
>>
>> where $From and $To values depend of on what page you are. let say
> there
>> are 100 products and I'm listing 25 products per page. for page 1
> $From=0,
>> $To=24. for page 2 $From=25 and$To=49, etc.
>>
>> works fine.
>>
>> though, to calculate how many pages I have I need total number of
> records.
>> do I have to run first a query (something like SELECT COUNT(*) as
>> NoOfRecords FROM products) and then query above or there is solution
> to
>> have both info using one query?
>>
>> as a solution, I can run a query to grab all records and then list
> just 25
>> products but I think it's not so smart idea :)
>>
>> thanks for any help.
>>
>> -afan
>>
>>
> I would say the select count(*) from ... query would be a fairly low
> cost query.
> Perhaps you could store off the number of rows in a session variable so
> you don't have to execute the count query when you move to the next
> page.
> -B
>
> --
> 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] extracting the file name from the referrer

2006-11-17 Thread John
I need to extract just the filename from the referring url, stripping it of
the path and any post vars on the end. there's got to be an easier way than
this eh?

 

$referrer = trim(strrchr(substr($_SERVER['HTTP_REFERER'],0,
strpos($_SERVER['HTTP_REFERER'],"?")), "/"), "/")

 

Thanks!

 

-JP

 

 

 



RE: [PHP] extracting the file name from the referrer

2006-11-17 Thread John
R> you may want to look at the parse_url and explode functions.

Thanks, I'll look into that

R> you do realize that the referer, should it exist <...>

Good point, thanks for pointing that out.  Yes, I was aware of that it
didn't come to mind.  The security isn't so much an issue as that's already
handled, though if someone has their referrers turned off, it would be a
problem.

I'm trying to establish three things before I do a block of processing

a) a form was submitted
b) a processing flag was previously set to process
c) the form/data being submitted/processed is from the correct page - which
was where the referring url came in.

Any other suggestions or alternatives for c?






-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Friday, November 17, 2006 5:41 PM
To: John
Subject: Re: [PHP] extracting the file name from the referrer

you may want to look at the parse_url and explode functions.

you do realize that the referer, should it exist, is of questionable
value? with various browsers the user can set it to a value of their
liking or simply turn it off. also various firewall products strip it
out for privacy reasons.


  - Rick

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



Re: [PHP] Smart Quotes not so smart

2006-11-17 Thread Larry Garfield
On Thursday 16 November 2006 14:07, Chris Shiflett wrote:
> Larry Garfield wrote:
> > I've run into this sort of issue a few times before, and never
> > found a good solution.
>
> Not sure if this is the solution you're looking for, but you can convert
> them to regular quotes:
>
> http://shiflett.org/archive/165

OK, let's see if the list will let me send now...

Thanks, Chris.  Converting them would be fine, but a replace doesn't seem to 
be working.  I'm trying to filter straight out of the $_POST array for it, 
and have tried both strtr() and str_replace().  No luck with either one.  

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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