Re: [PHP] Re: What's faster using if else or arrays?

2011-04-28 Thread Jim Giner
Arrays - using a  silly construct that probably still takes as much time to 
evaluate machine-wise as anything else.  And as far as readability goes, it 
is even sillier.   IMO.

(remainder deleted for readers' sakes :) ) 



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



[PHP] Re: What's faster using if else or arrays?

2011-04-28 Thread Jim Giner
how many entries are you talking about, ie., how many conditions?  Obviously 
if you have more than 4-5 it's going to be easier to code up as a case 
statement (?) rather than an if/else.

Never in all my days have I ever heard of using an array for such a 
determination though.

(remainder deleted for all reader's sakes :) ) 



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



Re: [PHP] refreshing pages in the cache

2011-04-28 Thread Jim Giner
Yes - that seems to be the trick!  Thank you very much for your tip AND 
your patience.  :)

You've made an old programmer's day! 



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



Re: [PHP] refreshing pages in the cache

2011-04-27 Thread Jim Giner
Must be doing something wrong.  Besides not helping my pages to re-build, it 
actually ruins the presentation of a couple of my pages, even tho they are 
all using the exact same includes with only some dummy content in one div 
different than all the other pages.

I added this line to my existing "starter" page code:



the above lines were added just ahead of the following - which was the 
absolute first line of output generated by my "built page" - line 1 of my 
first included file:

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



Re: [PHP] refreshing pages in the cache

2011-04-27 Thread Jim Giner
So - it's not an html attribute - it's a PHP command that precedes ALL my 
html headers?

"Ross Hansen"  wroteYou need to still put in the 
standard PHP tags as you would normally and it is just another line of code.

e.g





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



Re: [PHP] refreshing pages in the cache

2011-04-27 Thread Jim Giner
ok - I'm lost.  What do I do with this knowledge?

- Original Message - 
From: "Sean Greenslade" 

>>
> Sure. In order to "tell" the browser to not cache a page, you need to set
> the header "Cache-Control: no-cache". This can be done by the PHP command
>
> header("Cache-Control: no-cache");
>



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



Re: [PHP] refreshing pages in the cache

2011-04-27 Thread Jim Giner
thanks for the input but your first link is invalid and the second I don't 
understand why you sent me.
Perhaps you could explain? 



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



[PHP] refreshing pages in the cache

2011-04-27 Thread Jim Giner
I"m trying to make my webpages display random photos on a border.  Got it 
all working now but have a question about the IE cache.  Seems that once the 
page has been displayed, no amount of "refresh" will make the page "rebuild" 
and thus show 'different' pics the second time around.

Can php do something about a page in the cache?  I know that the cache is 
there to speed up performance and all, but I thought this random image thing 
would work if they just hit F5 to see a new array of images.

Can php detect a user-requested 'refresh'? 



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



[PHP] Re: files outside of the web tree

2011-04-27 Thread Jim Giner
I think I see what you mean but I guess if that's the way it's meant to be 
there must not be a great risk to my uploaded files.
Thanks! 



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



[PHP] files outside of the web tree

2011-04-27 Thread Jim Giner
I have managed to build include files and store them above my public folder 
and the called pages manage to find them from the public folder and properly 
include them.  My problem is with the html src= attribute.  I have uploaded 
photos to  be included in my web pages and I didn't want them in the web 
tree so I moved them above it also. I use php to get the root folder's name 
and then I add "../photos/" to the filename's path, but now my tags can't 
find them.  Can I not do this? 



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



Re: [PHP] str_replace

2011-04-25 Thread Jim Lucas
On 4/24/2011 8:44 AM, Ron Piggott wrote:
> 
> I am trying to figure out a syntax that will replace each instance of % with a
> different letter chosen randomly from the string $puzzle_filler. 
> $puzzle_filler
> is populated with the letters of the alphabet, roughly in the same ratio as 
> they
> are used.
> 
> This syntax replaces each instance of % with the same letter:
> 
> $puzzle[$i] = str_replace ( "%" , ( substr ( $puzzle_filler , rand(1,98) , 1 
> ) )
> , $puzzle[$i] );
> 
> Turning this:
> 
> %ECARBME%TIPLUP%%%E%%
> 
> Into:
> 
> uECARBMEuTIPLUPuuuEuu
> 
> Is there a way to tweak my str_replace so it will only do 1 % at a time, so a
> different replacement letter is selected?
> 
> This is the syntax specific to choosing a replacement letter at random:
> 
> substr ( $puzzle_filler , rand(1,98) , 1 );
> 
> Thanks for your help.
> 
> Ron
> 
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info
> 

How about something simple like this?




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



Re: [PHP] trouble using "is_file()"

2011-04-24 Thread Jim Giner
Well, I'll take your word for it.  As well as that of all the examples on 
Google that come up when looking for "php ftp uploads" which are NOT doing 
ftp uploads at all.  Seems that many people are calling the 'move' of their 
file from one host folder to another an 'upload'.  Thanks! 



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



Re: [PHP] trouble using "is_file()"

2011-04-24 Thread Jim Giner
because I've seen many comments in my research that ftp is better for larger 
files. I'm trying to upload photos so I know that they can be big. 



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



Re: [PHP] trouble using "is_file()"

2011-04-24 Thread Jim Giner
Hmmm...  did not realize that.  From all the code I examined I thought it 
was looking at the client.

So how does one do a file upload from the client to the host?  Preferably 
with ftp rather than http. 



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



[PHP] trouble using "is_file()"

2011-04-24 Thread Jim Giner
I've got a d/e screen that collects a path and a file name. My script then 
attempts to verify that the file exists before moving on to do things with 
it.
I've displayed the combined fields and they are showing correctly - ie, 
"c:\temp\emax.pdf"  as well as "c:/temp/emax.pdf" .  But when I use that var 
in "is_file($fname)" I get a false returned.  But I know it exists there.

Never used this function before, so I'm probably doing something stupid. 
btw - running on an XP machine with php 5.2 



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



Re: [PHP] combining PHP with JS

2011-04-20 Thread Jim Giner
Sounds like you need to have the user make a decision before you go to this 
php script that is processing the case statement.  Since the script's 
process is predetermined by this time (when you want the user's input) you 
should be able to have the user make his input before the script begins.

(remainder deleted for everyone's sake :) ) 



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



Re: [PHP] JavaScript Injection ???

2011-04-18 Thread Jim Giner

 wrote in message 
news:005501cbfdeb$457839c0$d068ad40$@com...
> Javascript:alert("Hello World");
> The browsers have had many updates since last I seen this work.
>

?? You're saying that "alert" doesn't work on your browse?  Gee - it works 
on mine. 



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



Re: [PHP] $_POST vars

2011-04-14 Thread Jim Giner
Guys - the problem has been solved.

Give it a rest.

(sent only to the list)

(remainder deleted for the benefit of all :) ) 



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



Re: [PHP] $_POST vars

2011-04-13 Thread Jim Giner
PHP then is Truly an amazing and powerful language.  I can expand the 
contents of the array $_POST by simply assigning a separate arry to it. 
Obviously if I have a duplicate element-name in my array it will override 
the $_POST element but that's my problem.

"Stuart Dallas"  wrote in message 
news:4962044e8a244fc28719d97746759...@3ft9.com...
> On Wednesday, 13 April 2011 at 19:12, Jim Giner wrote:
> When you say "assign that array to $_POST" do you mean
>>
>> $_POST = $qrslt;
>>
>> Not sure about this "assigning an array" thing.
>
 Yup, nothing more complicated than that.

 -Stuart


(remainder deleted for everyone's sake :) ) 



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



Re: [PHP] $_POST vars

2011-04-13 Thread Jim Giner
No need to email me AND send to the list.  Is that the standard practice on 
this forum?  Not encountered it before. 




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



Re: [PHP] $_POST vars

2011-04-13 Thread Jim Giner
When you say "assign that array to $_POST" do you mean

$_POST = $qrslt;

Not sure about this "assigning an array" thing.
- Original Message - 
From: "Stuart Dallas" 
Newsgroups: php.general
To: "Jim Giner" 
Cc: "PHP General" 
Sent: Wednesday, April 13, 2011 1:59 PM
Subject: Re: [PHP] $_POST vars


>
> Not sure what you mean by "the results of a query". If you mean an array 
> that you got from a MySQL query (my best guess), then simply assign that 
> array to $_POST ...
>



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



[PHP] $_POST vars

2011-04-13 Thread Jim Giner
Can one create a set of $_POST vars within a script or is that not do-able? 
My display portion of my script utilizes the POST array to supply values to 
my input screen - this works well for the first display of an empty screen, 
and any following re-displays if there's an error in the user's input.  But 
I want to use this same script/screen to display the results of a query when 
the user wants to update an existing record. 



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



Re: [PHP] the best 1 book for php

2011-04-06 Thread Jim Lucas

+1

1. Always current
2. Usable & evolving examples

On 4/6/2011 9:23 PM, Michael Shadle wrote:

http://www.php.net/


On Wed, Apr 6, 2011 at 9:15 PM, Kirk Bailey  wrote:

If I only had 1 book on php, what would it be?

--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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





--
Jim Lucas
www.cmsws.com

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



[PHP] Re: Newbi Question with calculate

2011-04-06 Thread Jim Giner
I think you want to use the FOR loop to process each record in your table. 
You query (?) the table and then process each row in the result using the 
FOR and all your calculations on each one.  Look up FOR.
"Silvio Siefke"  wrote in message 
news:4d9c6165.5040...@silvio-siefke.de...
> Hello,
>
>
> i have write a script for my Stock portfolio and now im not really find
> something which can me help.
>
> In the table php calculate me the Present Value and the Percent with
> this code:
>
> 
>  //Quantity
> $ABEI = 240;
>
> //Buy Quote
> $KKBEI = 41.31;
>
> //Buy Balance
> $KWBEI = 9914.40;
>
> //calculate
> include("../inc/quote.php"); // Yahoo Quotes
> $BEIERG = $KKBEI*$ABEI; // Buy Balance
> $BEIDW = $BEIQuote['last']*$ABEI; // Present Value
> $BEIAEN1 = $BEIQuote['last']-$KKBEI; // Quote Win
> $BEIAEN = $BEIAEN1*100/$KKBEI; //Percent Win
> ?>
>
>
> Is it possible to apply logic to the whole table? Or do I write for each
> additional item the same source code?
>
>
> It were nice someone has a Tip for me? Thank u.
>
>
> Silvio 



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



Re: [PHP] randomly random

2011-04-05 Thread Jim Lucas
On 4/5/2011 7:07 AM, Kirk Bailey wrote:
> OK gang, to spew a single line from a file of fortune cookies, I want to read 
> it
> and echo one line. While I found a 4 line code which gets it done, I thought
> there was a preexisting command to do exactly that. Any feedback on this?
> 

No, but it can be done in one line:

 0 )
echo array_rand(file($filename), 1);

?>

Jim Lucas

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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
To those who have been so helpful:
I did manage to subscribe to a mysql mailing list.  thanks for the pointers.

As for my orig problem - for those who are intereseted:

The FIELD function apparently doesn't work in 5.0.2, even tho it is in the 
online ref manual.  I was given a suggestion of using INSTR and that worked 
beautifully.  Here's how it looked in my Select statement:

$q = "SELECT race_winner,count(race_date) as wins,
  SUBSTR(race_winner,INSTR(race_winner,' ')+1) as last_name
FROM `trk_races`
WHERE race_winner IS NOT NULL
GROUP BY race_winner
ORDER BY wins DESC,last_name";


It works just as I wanted it to.

Thanks to all.




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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
no - that address came back undeliverable.
>
> To subscribe to the list, send an empty message to
> 
>
> Marc 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
Thanks - will do!
> I found a mailing list that might work for you:
>
> To subscribe to the list, send an empty message to
> 
>
> Marc 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
Actually - I can't seem to find a mysql newsgroup anywhere.  The ones that 
come up in google search are all dead and buried. 



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



Re: [PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
good point.  So wrapped up in making my php script work that I didn't think 
about that.
"Ashley Sheridan"  wrote in message 
news:1301936583.2288.3.camel@localhost...
> On Mon, 2011-04-04 at 11:50 -0400, Jim Giner wrote:
>
>> having a problem posting this message - forgive any duplication please.
>>
>> Hi,
>> I'm trying to use sql to extract the last name from a person's name field 
>> in
>> my table.  Here's my Select:
>>
>> $q = "SELECT race_winner,count(race_date) as wins,
>> substr(race_winner,FIELD(' ',race_winner)) as last_name
>>
>> etc.,,,
>>
>>
>>
>> My result keeps coming up with a 0 for the FIELD portion I assume
>> since my output shows a blank last_name.  From the docs I believe it 
>> should
>> be giving me the right-most portion of the 'race_winner' field beginning
>> where the first space char is found.
>>
>> Am I not using this correctly?  Is there a better way to do this?  I'm
>> trying to have my results sorted by last name and since the table was not
>> built with separate first/last name fields, I'm stuck with figuring
>> somethign out.
>>
>>
>>
>>
>>
>
>
> Where's the PHP question in this, as what you've asked would be better
> asked on a database list, as it's an SQL query.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> 



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



[PHP] Last Name extraction in query

2011-04-04 Thread Jim Giner
having a problem posting this message - forgive any duplication please.

Hi,
I'm trying to use sql to extract the last name from a person's name field in
my table.  Here's my Select:

$q = "SELECT race_winner,count(race_date) as wins,
substr(race_winner,FIELD(' ',race_winner)) as last_name

etc.,,,



My result keeps coming up with a 0 for the FIELD portion I assume
since my output shows a blank last_name.  From the docs I believe it should 
be giving me the right-most portion of the 'race_winner' field beginning 
where the first space char is found.

Am I not using this correctly?  Is there a better way to do this?  I'm
trying to have my results sorted by last name and since the table was not
built with separate first/last name fields, I'm stuck with figuring
somethign out.





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



Re: [PHP] How to check if remote machines are running using PHP and Eclipse-Require Urgent Help

2011-04-01 Thread Jim Giner
your boss is asking you to write something in PHP, but it sounds to me like 
you are not very knowledgable in it, or even in creating a text file.  Why 
is he doing this? 



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



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner
And the way to do this is? 



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



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner

function. Try something like:
...
echo 'heaading contains: getText("h2")';
...

I tried it - no better. 



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



Re: [PHP] newbie - function is undefined

2011-04-01 Thread Jim Giner
Thanks - now I see.  the message means that it can't find a php function 
called getText.  Doh! 



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



[PHP] looking for a newsgroup for JS

2011-03-23 Thread Jim Giner
Anyone know of a working Javascript newsgroup?  I googled and tried adding 
several to my OE newsgroups but couldn't find the servers.

comp.lang.javascript
pl.lang.
mozilla..

All of these (can't remember their names now) came up with the same error 
message.

As part of learning php, I suddenly have a need to learn some js as 
well. 



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



Re: [PHP] Re: echo?

2011-03-23 Thread Jim Giner
Thanks for the pointer.  Had not run across that tidbit before.
"Stuart Dallas"  wrote in message 
news:b43dfd4fa2ac4489aaf538d1bf7a8...@3ft9.com...
> http://php.net/manual/en/language.types.string.php
>
> -Stuart
>
> -- 
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>
> On Wednesday, 23 March 2011 at 12:39, Jim Giner wrote:
>> Very Interesting - '\n' doesn't work, but "\n" does work.
>> "Steve Staples"  wrote in message
>> news:1300883645.5100.973.camel@webdev01...
>> > On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
>> > > I am outputting to a  on an html page. A  doesn't work,
>> > > nor
>> > > does \n, hence the 
. Of course, if I don't need the & then 
>> > > I've
>> > > just saved two keystrokes. :) Also - I do believe I tried ($i+1) and
>> > > that
>> > > didn't work either.
>> > >
>> > > "Paul M Foster"  wrote in message
>> > > news:20110323034621.go1...@quillandmouse.com...
>> > > > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>> > > >
>> > > > > Yes - it is J and I. I tried using $i+1 in the echo originally 
>> > > > > but it
>> > > > > wouldn't run. That's why I created $j.
>> > > >
>> > > > Yes, the substitution creates a syntax error unless surrounded by
>> > > > parentheses or the like.
>> > > >
>> > > > > And just what is wrong with the old cr/lf sequence? How would you
>> > > > > have
>> > > > > done
>> > > > > it?
>> > > >
>> > > > You're using HTML-encoded entities for 0x0d and 0x0a. You can 
>> > > > simply
>> > > > use 0x0d and 0x0a instead. If you're running this in a web context, 
>> > > > you
>> > > > should use "" instead of CRLF. At the command line, I'm not
>> > > > familiar with running PHP on Windows. In *nix environments, it's 
>> > > > enough
>> > > > to use "\n", just as they do in C. It might even work in Windows; I
>> > > > don't know. If not, you should be able to use "\r\n". You can also 
>> > > > try
>> > > > the constant PHP_EOL, which is supposed to handle newlines in a
>> > > > cross-platform way.
>> > > >
>> > > > Paul
>> > > >
>> > > > -- 
>> > > > Paul M. Foster
>> > > > http://noferblatz.com
>> > > > http://quillandmouse.com
>> >
>> > Jim
>> >
>> > with the \n, it does work in a textarea. you must put the \n inside
>> > the "", so:
>> >
>> > $q = 'select * from director_records ';
>> > $qrslt = mysql_query($q);
>> > $rows = mysql_num_rows($qrslt);
>> > for ($i = 0; $i < $rows; $i++)
>> > {
>> >  $row = mysql_fetch_array($qrslt);
>> >  echo ($i + 1) .'-'. $row['userid'];
>> >  if ($row['user_priv'] != "")
>> >  echo ' ('. $row['user_priv'] .')';
>> >  echo "\n";
>> > }
>> >
>> >
>> > give that a try
>>
>>
>>
>> -- 
>> 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] Re: echo?

2011-03-23 Thread Jim Giner
As Richard proved my problem was caused by my use of the archaic cr/lf 
character pair.  Once I found the correct syntax for using \n my output of 
the loop counter worked.

thanks for all the suggestions.  My first experience on a PHP newsgroup and 
it was a postiive one.  I've spent the last 12+ years using newsgroups for 
Paradox development and this group is *just* as supportive and 
knowledgeable.

(no jokes about using paradox for so long.  If your users can manage on a 
desktop solution, pdox can't be beaten for what it could/can do.) 



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



Re: [PHP] Re: echo?

2011-03-23 Thread Jim Giner
Very Interesting - '\n' doesn't work, but "\n" does work.
"Steve Staples"  wrote in message 
news:1300883645.5100.973.camel@webdev01...
> On Wed, 2011-03-23 at 08:28 -0400, Jim Giner wrote:
>> I am outputting to a  on an html page.  A  doesn't work, 
>> nor
>> does \n, hence the 
.  Of course, if I don't need the & then I've
>> just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and 
>> that
>> didn't work either.
>>
>> "Paul M Foster"  wrote in message
>> news:20110323034621.go1...@quillandmouse.com...
>> > On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>> >
>> >> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
>> >> wouldn't run.  That's why I created $j.
>> >
>> > Yes, the substitution creates a syntax error unless surrounded by
>> > parentheses or the like.
>> >
>> >> And just what is wrong with the old cr/lf sequence?  How would you 
>> >> have
>> >> done
>> >> it?
>> >
>> > You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
>> > use 0x0d and 0x0a instead. If you're running this in a web context, you
>> > should use "" instead of CRLF. At the command line, I'm not
>> > familiar with running PHP on Windows. In *nix environments, it's enough
>> > to use "\n", just as they do in C. It might even work in Windows; I
>> > don't know. If not, you should be able to use "\r\n". You can also try
>> > the constant PHP_EOL, which is supposed to handle newlines in a
>> > cross-platform way.
>> >
>> > Paul
>> >
>> > -- 
>> > Paul M. Foster
>> > http://noferblatz.com
>> > http://quillandmouse.com
>>
>>
>>
>
> Jim
>
> with the \n, it does work in a textarea.   you must put the \n inside
> the "", so:
>
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $rows = mysql_num_rows($qrslt);
> for ($i = 0; $i < $rows; $i++)
> {
>$row = mysql_fetch_array($qrslt);
>echo ($i + 1) .'-'. $row['userid'];
>if ($row['user_priv'] != "")
>echo ' ('. $row['user_priv'] .')';
>echo "\n";
> }
>
>
> give that a try
>
> 



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



Re: [PHP] Re: echo?

2011-03-23 Thread Jim Giner
it was as complete as need be to demonstrate my dilemma, as Richard has 
discovered above
"Frank Arensmeier"  wrote in message 
news:7cfb015a-c530-4712-9ebc-fbdf5b0ed...@gmail.com...

23 mar 2011 kl. 02.42 skrev Jim Giner:

> ok - here's the code in question.
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $rows = mysql_num_rows($qrslt);
> for ($i=0; $i<$rows; $i++)
>{
>$j = $i+1;
>$row = mysql_fetch_array($qrslt);
>echo $j.'-'.$row['userid'];
>if ($row['user_priv']<> "")
>echo ' ('.$row['user_priv'].')
';
>else
>echo '
';
>}
>
>
> The output I get is:
>
>
> 1-smith5
> f-ginerjm (M)
> g-smith8
>
> While the alpha parts are valid, the index is only correct for the first 
> one
> (0) obviously.
>
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Why not try some basic debugging strategies and see what you get?

Try:
for ($i=0; $i<$rows; $i++)
   {
   var_dump($i);
   $j = $i+1;
   $row = mysql_fetch_array($qrslt);
   echo $j.'-'.$row['userid'];
   var_dump($j);
   if ($row['user_priv']<> "")
   echo ' ('.$row['user_priv'].')
';
   else
   echo '
';
   }

The output you've posted, that's rendered output, right? What's the raw 
output?

By the way, the code snippet you gave us is not complete. Is there anything 
else? As Dan noticed earlier, judging from that code snippet only, there 
must be something else funky going on.

/frank




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



Re: [PHP] Re: echo?

2011-03-23 Thread Jim Giner
not the concern in this posting
"Richard Quadling"  wrote in message 
news:aanlktindqu7bzeamtcwh6y9f3m9yjxqpt-ime9ysh...@mail.gmail.com...
On 23 March 2011 07:46, Geoff Lane  wrote:
> Hi Jim,
>
> On Wednesday, March 23, 2011, 1:42:18 AM, you wrote:
>
>> ok - here's the code in question.
>> $q = 'select * from director_records ';
>> $qrslt = mysql_query($q);
>> $rows = mysql_num_rows($qrslt);
>> for ($i=0; $i<$rows; $i++)
>> {
>> $j = $i+1;
>> $row = mysql_fetch_array($qrslt);
>> echo $j.'-'.$row['userid'];
>> if ($row['user_priv']<> "")
>> echo ' ('.$row['user_priv'].')
';
>> else
>> echo '
';
>> }
>
>
>> The output I get is:
>
>
>> 1-smith5
>> f-ginerjm (M)
>> g-smith8
>
>> While the alpha parts are valid, the index is only correct for the first 
>> one
>> (0) obviously.
>
>
> I couldn't understand why you're getting characters, so I thought I'd
> have a go myself. First, some DDL and DML to recreate your data:
>
> create table director_records (userid char(16), user_priv char(8));
> insert into director_records (userid, user_priv) values ('smith5', 
> ''),('ginerjm','M'),('smith8','');
>
> Now when I ran your code I got:
>
> 1-smith5
f-ginerjm (M)
g-smith8

>
> That is, all but the first result has 
x in front of it. These are
> HTML entities that display as characters and it so happens that f
> is 'j' and g is 'g'. Strictly, these entities should be terminated
> with a semi-colon (i.e. f and g), but your browser is
> 'obligingly' making sense of the 'bad formatting' and this is why
> you're getting characters.
>
> BTW, an alternative to your for construct would be to use a while loop
> to iterate through a data table. e.g. in your case, I'd have used:
>
> $q = 'select * from director_records ';
> $qrslt = mysql_query($q);
> $i = 1;
> while ($row = mysql_fetch_array($qrslt)){
> echo $i++ . '-' . $row['userid'];
> if ($row['user_priv']<>""){
> echo " (" . $row['user_priv'] . ")";
> }
> echo "\n";
> }
>
> HTH,

I use ...

while(False !== ($row = mysql_fetch_array($qrslt)){
}

just so that if I have a query with 1 cell which is 0, or '', I don't
abort the loop.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY 



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



[PHP] Re: echo?

2011-03-23 Thread Jim Giner
By george - I think you've solved it!

As for my coding choice - that's the beauty of programming - everybody has a 
way of solving a problem/creating a solution.  Unless you are concerned with 
performance(which in this particular case is not a concern), there is no 
'wrong way'.
"Geoff Lane"  wrote in message 
news:1278073104.20110323074...@gjctech.co.uk...
> Hi Jim,
>
> On Wednesday, March 23, 2011, 1:42:18 AM, you wrote:
>
>> ok - here's the code in question.
>> $q = 'select * from director_records ';
>> $qrslt = mysql_query($q);
>> $rows = mysql_num_rows($qrslt);
>> for ($i=0; $i<$rows; $i++)
>> {
>> $j = $i+1;
>> $row = mysql_fetch_array($qrslt);
>> echo $j.'-'.$row['userid'];
>> if ($row['user_priv']<> "")
>> echo ' ('.$row['user_priv'].')
';
>> else
>> echo '
';
>> }
>
>
>> The output I get is:
>
>
>> 1-smith5
>> f-ginerjm (M)
>> g-smith8
>
>> While the alpha parts are valid, the index is only correct for the first 
>> one
>> (0) obviously.
>
>
> I couldn't understand why you're getting characters, so I thought I'd
> have a go myself. First, some DDL and DML to recreate your data:
>
>  create table director_records (userid char(16), user_priv char(8));
>  insert into director_records (userid, user_priv) values ('smith5', 
> ''),('ginerjm','M'),('smith8','');
>
> Now when I ran your code I got:
>
> 1-smith5
f-ginerjm (M)
g-smith8

>
> That is, all but the first result has 
x in front of it. These are
> HTML entities that display as characters and it so happens that f
> is 'j' and g is 'g'. Strictly, these entities should be terminated
> with a semi-colon (i.e. f and g), but your browser is
> 'obligingly' making sense of the 'bad formatting' and  this is why
> you're getting characters.
>
> BTW, an alternative to your for construct would be to use a while loop
> to iterate through a data table. e.g. in your case, I'd have used:
>
>  $q = 'select * from director_records ';
>  $qrslt = mysql_query($q);
>  $i = 1;
>  while ($row = mysql_fetch_array($qrslt)){
>  echo $i++ . '-' . $row['userid'];
>  if ($row['user_priv']<>""){
>  echo " (" . $row['user_priv'] . ")";
>  }
>  echo "\n";
>  }
>
> HTH,
>
> -- 
> Geoff Lane
> Cornwall, UK
> ge...@gjctech.co.uk
> 



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



Re: [PHP] Re: echo?

2011-03-23 Thread Jim Giner
I am outputting to a  on an html page.  A  doesn't work, nor 
does \n, hence the 
.  Of course, if I don't need the & then I've 
just saved two keystrokes.  :)  Also - I do believe I tried ($i+1) and that 
didn't work either.

"Paul M Foster"  wrote in message 
news:20110323034621.go1...@quillandmouse.com...
> On Tue, Mar 22, 2011 at 10:50:54PM -0400, Jim Giner wrote:
>
>> Yes - it is J and I.  I tried using $i+1 in the echo originally but it
>> wouldn't run.  That's why I created $j.
>
> Yes, the substitution creates a syntax error unless surrounded by
> parentheses or the like.
>
>> And just what is wrong with the old cr/lf sequence?  How would you have 
>> done
>> it?
>
> You're using HTML-encoded entities for 0x0d and 0x0a. You can simply
> use 0x0d and 0x0a instead. If you're running this in a web context, you
> should use "" instead of CRLF. At the command line, I'm not
> familiar with running PHP on Windows. In *nix environments, it's enough
> to use "\n", just as they do in C. It might even work in Windows; I
> don't know. If not, you should be able to use "\r\n". You can also try
> the constant PHP_EOL, which is supposed to handle newlines in a
> cross-platform way.
>
> Paul
>
> -- 
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com 



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



Re: [PHP] Re: echo?

2011-03-22 Thread Jim Giner
Yes - it is J and I.  I tried using $i+1 in the echo originally but it 
wouldn't run.  That's why I created $j.
And just what is wrong with the old cr/lf sequence?  How would you have done 
it?
What do you mean 'this alone .'?
"Tamara Temple"  wrote in message 
news:521bdb9d-adbf-45d7-b759-acd315b19...@gmail.com...
>
> On Mar 22, 2011, at 8:42 PM, Jim Giner wrote:
>
>> ok - here's the code in question.
>> $q = 'select * from director_records ';
>> $qrslt = mysql_query($q);
>> $rows = mysql_num_rows($qrslt);
>> for ($i=0; $i<$rows; $i++)
>>{
>>$j = $i+1;
>
> Am i reading this correctly: the first variable is j (jay) the second 
> variable is i (eye) ?
>
> This alone doesn't explain anything...
>
>>$row = mysql_fetch_array($qrslt);
>>echo $j.'-'.$row['userid'];
>
> Since this is the only place $j is used, try subbing in $i+1 and see  what 
> you get.
>
>>if ($row['user_priv']<> "")
>>echo ' ('.$row['user_priv'].')
';
>
> This is really rather a strange way of getting a line break.
>
>>else
>>echo '
';
>>}
>>
>>
>> The output I get is:
>>
>>
>> 1-smith5
>> f-ginerjm (M)
>> g-smith8
>>
>> While the alpha parts are valid, the index is only correct for the  first 
>> one
>> (0) obviously.
>>
>>
>>
>> -- 
>> 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] Re: echo?

2011-03-22 Thread Jim Giner
ok - here's the code in question.
$q = 'select * from director_records ';
$qrslt = mysql_query($q);
$rows = mysql_num_rows($qrslt);
for ($i=0; $i<$rows; $i++)
{
$j = $i+1;
$row = mysql_fetch_array($qrslt);
echo $j.'-'.$row['userid'];
if ($row['user_priv']<> "")
echo ' ('.$row['user_priv'].')
';
else
echo '
';
}


The output I get is:


1-smith5
f-ginerjm (M)
g-smith8

While the alpha parts are valid, the index is only correct for the first one 
(0) obviously.



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



[PHP] echo?

2011-03-22 Thread Jim Giner
Kinda new to this, but I've been puttering/writing for about 3 weeks now and 
have some good working screens up.  Ran into something new while I was 
debuggina script today.

Tried to echo the $i value within a for loop as part of the list of items I 
was building
Something like

for ($i=0;$i<$rows;$i++)
echo $i.' '.$row['itemname'];

I expected to see :

1 item1
2 item2
...
...

but instead I got

1 item1
f item2

Yes - an 'f' and not a 2.

Tried it some more with this:

for ($i=1;$i<10;$i++)
echo $i." item".'';

and got

c item
d item
e item
f item
g item

and so on.

It seems that I can only output the value of $i if I output a string in 
front of it

echo ' '.$i;

works fine but
echo $i;
does not.

Any ideas? 



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



[PHP] problem compiling 5.3 with postgresql

2011-03-19 Thread Jim White

I am having problems compiling 5.3.? with postgresql support.

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' 
'--with-pdo-pgsql=/usr/local/postgresql-9.0.3' 
'--with-pgsql=/usr/local/postgresql-9.0.3'


This configure works with 5.2.?, but 5.3.? gets this

ext/standard/.libs/dns.o: In function `php_parserr':
/usr/local/php-5.3.5/ext/standard/dns.c:418: undefined reference to 
`__dn_expand'


and more lines like the last one.

How can I fix this? I am using Ubuntu 10.10.

JIm



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



Re: [PHP] Deleting elements from the middle of an array

2011-03-15 Thread Jim Lucas
On 3/14/2011 2:02 PM, Jim Lucas wrote:
> On 3/14/2011 1:31 PM, Paul M Foster wrote:
>> Here's what I need to do: I have an indexed array, from which I need to
>> delete elements in the middle. Once completed, the indexes should be
>> numerically in sequence, as they were when I first encountered the
>> array. That is:
>>
>> Before:
>> $arr = array(0 => 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10);
>>
>> After:
>> $arr = array(0 => 5, 1 => 6, 2 => 9, 3 => 10);
>>
>>
>> I've tried:
>>
>> 1) Using for() with unset(). Elements are deleted, but the indexes are
>> no longer sequential.
>>
>> 2) Using for() with array_splice(). Understandably, deletes certain
>> elements but not others.
>>
>> 3) Using foreach() with referenced array elements. Neither unset() nor
>> array_splice() appear to have any effect on the array at all.
>>
>> 4) while() loop using current() and the like. But these array functions
>> return values, not references, so the array isn't actually modified.
>>
>> 5) array_walk() with unset() array_splice(). No effect on the array.
>>
>> Anyone know how to do this, or know of a reference on how to?
>>
>> Paul
>>
> 
>  
> # Setup match array
> $match_these = array(7,8);
> 
> # Setup data array
> $arr = array(0 => 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10);
> 
> # Loop data array
> foreach ( $arr AS $k => $v )
> {
>   # Simple matching this may be, but work yes it does
>   if ( in_array($v, $match_these) )
>   {
> # Remove matched items
> unset($arr[$k]);
>   }
> }
> 
> # Reset array indexes
> $arr = array_values($arr);
> 
> # Print it
> print_r($arr);
> 
> # $arr will now be array(0 => 5, 1 => 6, 2 => 9, 3 => 10);
> 
> ?>

Or you can do the long and more memory intense way.

 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10);

# Setup new array()
$new_arr = array();

# Loop data array
foreach ( $arr AS $k => $v )
{
  # Simple matching this may be, but work yes it does
  if ( ! in_array($v, $match_these) ) # notice the ! (NOT)
  {
# Remove matched items
$new_arr[] = $arr[$k];
  }
}

# Print it
print_r($new_arr);

# $arr will now be array(0 => 5, 1 => 6, 2 => 9, 3 => 10);

?>

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



Re: [PHP] Deleting elements from the middle of an array

2011-03-14 Thread Jim Lucas
On 3/14/2011 1:31 PM, Paul M Foster wrote:
> Here's what I need to do: I have an indexed array, from which I need to
> delete elements in the middle. Once completed, the indexes should be
> numerically in sequence, as they were when I first encountered the
> array. That is:
> 
> Before:
> $arr = array(0 => 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10);
> 
> After:
> $arr = array(0 => 5, 1 => 6, 2 => 9, 3 => 10);
> 
> 
> I've tried:
> 
> 1) Using for() with unset(). Elements are deleted, but the indexes are
> no longer sequential.
> 
> 2) Using for() with array_splice(). Understandably, deletes certain
> elements but not others.
> 
> 3) Using foreach() with referenced array elements. Neither unset() nor
> array_splice() appear to have any effect on the array at all.
> 
> 4) while() loop using current() and the like. But these array functions
> return values, not references, so the array isn't actually modified.
> 
> 5) array_walk() with unset() array_splice(). No effect on the array.
> 
> Anyone know how to do this, or know of a reference on how to?
> 
> Paul
> 

 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10);

# Loop data array
foreach ( $arr AS $k => $v )
{
  # Simple matching this may be, but work yes it does
  if ( in_array($v, $match_these) )
  {
# Remove matched items
unset($arr[$k]);
  }
}

# Reset array indexes
$arr = array_values($arr);

# Print it
print_r($arr);

# $arr will now be array(0 => 5, 1 => 6, 2 => 9, 3 => 10);

?>

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



Re: [PHP] Re: $_POST variable

2011-03-11 Thread Jim Lucas
On 3/11/2011 12:03 PM, Shawn McKenzie wrote:
> On 03/11/2011 01:28 PM, Danny wrote:
>> Hi guys,
>>
>> I have a form that has a long list of radio-bottons inside of it. The
>> radio-buttons are dynamically created via php and MySQL.
>>
>> Here is an example of one of the radio buttons:
>>
>> " 
>> value="0">
>> " 
>> value="1">
>>
>> Now, when I submit this form to another page for processing, how would I 
>> "catch"
>> the above radio-button's $_POST name since I do not know the name, only that 
>> it
>> starts with "radio_" ?
>>
>> Thank You
>>
>> Danny
> 
> The most common and flexible way to do this sort of thing is to use
> arrays instead:
> 
>  value="0">
>  value="1">
> 
> 
> Then:
> 
> foreach($_POST['radio'] as $key => $value) {
>echo "radio for $key is $value";
> }

Your example would be good if the OP wanted checkbox'es.  But with radio
buttons, the whole point (most of the time) is to have the form only allow you
to have one of the radio input fields selected at any given time.  How you
showed it, it would not see the uniqueness of the radio button names, and
therefor allow more than one of the radio input fields to be selected at a time.

I would try something like this:

As long as this is correct:

Zero
One

Then I would do the following:

foreach ($_POST as $k => $v) {
  if ( strpos(trim($k), 'radio_') === 0 ) {
echo $k.' is a match, and it\'s value is '.$v.'.'.PHP_EOL;
  }
}

Jim Lucas

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



Re: [PHP] Can´t upload files bigger than 50KB

2011-03-09 Thread Jim Lucas
On 3/9/2011 6:28 AM, Gotzon Astondoa wrote:
>  Hi all:
> 
> On my website I have an Ajax form. From this form user can upload files.

My guess would be that you have an HTML form.  Not AJAX

> Server side is a PHP script.
> This form works properly on my development server.

Is this on localhost or is it remote too?

> But when I uploaded my application to the definitive server I discovered
> that I can only upload files less than 50KB (It works perfectly with 1 to 20
> KB images).

Silly question, how long does it take for these 1 to 20 KB files to upload?

> These are the data from the server configuration that I believe can affect:
> 
>  post_max_size 8M
>  upload_max_filesize 2M
>  memory_limit 128M
>  safe_mode off
>  SELinux disabled
>  open_basedir none
> 
> I´m now making tests with 52KB image: image.jpg
> I discovered that the uploaded file is uploaded to /tmp. This file name is
> php10tfTp.

how much space is free on the partition that contains /tmp  ?

> But the file is not completely uploaded! So, my PHP script is not fired!
> The original image size is 52KB and the new file size is 35KB . I download
> the tmp file and rename it to php10tfTp.jpg. I can see that half frame is
> the same as the original and the other half is gray.
> 
> Any idea what is happening?
> 
> Thanks in advance.
> 


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



Re: [PHP] Help translating PHP5 code to PHP4.

2011-03-08 Thread Jim Lucas
On 3/7/2011 8:16 AM, Marc Guay wrote:
> Hi folks,
> 
> I've stumbled into a project involving a server running PHP4 without
> cURL.  The script fetches data from an XML webservice and deals with
> it.  Is http://ca2.php.net/xml_parser_create the place to start?  Any
> tips (besides updating PHP)?
> 
> Here's an example of the PHP5 code:
> 
> $url = "http://www.domain.com/webservice.php?var=foo";;
> $ch = curl_init($url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> $val = curl_exec($ch);
> curl_close($ch);
> libxml_use_internal_errors(true);
> $xml = simplexml_load_string($val);
> $errors = libxml_get_errors();
> 
> if (!($errors)){
>   $myvariable = $xml->attributes()->value;
> }
> else{
>   // deal with errors 
> }
> 

Here is an example that is in the PHP manual

http://us.php.net/manual/en/function.xml-parser-create.php#38739

The only modification that you will probably have to make is to set the
following in your php.ini file.

allow_url_include = On
and/or
allow_url_fopen = On

This would allow fopen to open the external URL and grab the data returned.

Jim Lucas

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



Re: [PHP] Re: Possible bug in PHP 5.3.5 with OAuth extension?

2011-03-04 Thread Jim Lucas
On 3/4/2011 5:18 PM, Daniel Hong wrote:
> Correction:
> 
> I stated the incorrect version of PHP that does not seem to have this issue.
> The version of PHP that works correctly is 5.3.2, not 5.3.3.

Can you give us an example of what you are doing?

Jim Lucas

> 
> Thanks,
> daniel
> 
> On Fri, Mar 4, 2011 at 11:40 AM, Daniel Hong  wrote:
> 
>> Hello,
>>
>> I'm using the PHP OAuth extension and running into a strange issue. I'm not
>> sure if it's a bug in PHP 5.3.5, or if it's a bug in the OAuth extension
>> when installed on a system with PHP 5.3.5.
>>
>> On a machine with PHP 5.3.5, when I call OAuth::fetch() with http method of
>> POST, the debug info is showing that it is sending as a GET request. As a
>> result, the resource that I'm fetching returns with failure since it will
>> only respond to a POST request. I tested this out on two different machines,
>> and getting the same result on both. One machine is Ubuntu 10.04 with nginx
>> 0.8.54 and PHP 5.3.5. The other is CentOS 5.5 with apache 2.2 and PHP 5.3.5.
>>
>> I have another Ubuntu 10.04 machine with PHP 5.3.3, and I am not having
>> this issue on that machine. The OAuth debug info is correctly showing http
>> method of POST.
>>
>> I guess I'll need to use PHP 5.3.3 in the mean time, but it would be great
>> to know what the problem is.
>>
>> Thanks,
>> daniel
>>
> 


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



Re: [PHP] Help needed with mysql import

2011-03-02 Thread Jim Lucas
On 3/2/2011 9:48 AM, Ashley Sheridan wrote:
> "Jim Lucas"  wrote:
> 
>> On 3/2/2011 4:25 AM, Alex wrote:
>>> You shouldn't have a default value in an auto increment field. You
>> can 
>>> set AUTO_INCREMENT to 0 and start with 1, but as auto increment is a
>>> unique field and its automagically incremented, you should not set a
>>> default value on it...
>>
>> This is fine and dandy until you want to do a restore of your data.
>>
>> With a restore, you will probably want to retain your auto-increment
>> IDs since
>> they are probably used else where in your DB.
>>
>> Jim
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> Restoring data wouldn't need default values though, would it. You can just 
> perform a regular insert statement and update the next id value to be used if 
> necessary.
> 
> Also, I'm not 100% sure on this one, but I thought that some versions of 
> Mysql had problems with a 0 in an auto_inc field?
> 
> 
> Thanks
> Ash

Ash,

Sorry, I didn't mean to imply that the AUTO_INCREMENT set to 0 is fine.

Doing an export of the table structure for one of my smaller tables (that is
empty), I see that the AUTO_INCREMENT value is set to 1 by default.


CREATE TABLE IF NOT EXISTS `ajax_products` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(64) NOT NULL default '',
  `version` tinytext NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

It doesn't show a default value, but rather a default starting point for the
AUTO_INCREMENT

OP: Show us an export of your db table structure.

Jim

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



Re: [PHP] Help needed with mysql import

2011-03-02 Thread Jim Lucas
On 3/2/2011 4:25 AM, Alex wrote:
> You shouldn't have a default value in an auto increment field. You can 
> set AUTO_INCREMENT to 0 and start with 1, but as auto increment is a
> unique field and its automagically incremented, you should not set a
> default value on it...

This is fine and dandy until you want to do a restore of your data.

With a restore, you will probably want to retain your auto-increment IDs since
they are probably used else where in your DB.

Jim

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



Re: [PHP] Sorting an array

2011-03-01 Thread Jim Lucas
On 2/28/2011 7:52 PM, Ron Piggott wrote:
> 
> I need help to know how to sort the words / phrases in my array.
> 
> Variable name: $words_used
> print_r( $words_used ); Current output: Array ( [187] => Sin [249] => 
> Punished [98] => Sanctuary [596] => Sing [362] => Anointing Oil )
> Desired result: Alphabetical sort: Array ( [362] => Anointing Oil [249] => 
> Punished [98] => Sanctuary [187] => Sin [596] => Sing ) 
> 
> The #’s are the auto_increment value of the word in the mySQL database.  The 
> number is not representative of alphabetical order, but the order it was 
> added to the database.
> 
> Thank you for your assistance.
> 
> Ron
> 
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info  
> 

Besides the answer others have pointed you to, I would recommend doing it in 
mysql?

SELECT * FROM  ORDER BY ;

Check out the syntax for it here.

http://dev.mysql.com/doc/refman/5.0/en/select.html
and
http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html

Jim Lucas

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



Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread Jim Lucas
On 2/24/2011 3:01 AM, Dave M G wrote:
> PHP users,
> 
> I obviously don't understand what array_walk_recursive does.
> 
> Can someone break down in simple terms why the following doesn't work?
> 
> - - -
> 
> $karamohOutput['test'] = "";
> 
> function test_print($item, $key)
> {
> return "$key holds $item\n";
> }
> $karamohOutput['test'] .= array_walk_recursive($karamohArray, 'test_print');
> 
> - - -
> 
> Any advice would be much appreciated.
> 

if you read the following page description of the function, you will see that
the function returns a bool value.  Not the return statement of your custom
function call.

http://us.php.net/array_walk_recursive

If you read the Note under the funcname section, you will see that when you call
the function, it will pass the value as a reference, so, change around your
function like this.

$karamohOutput['test'] = "";

# notice this .>|
function test_print(&$item, $key)
{
    $item = "$key holds $item\n";
}
array_walk_recursive($karamohArray, 'test_print');

print_r($karamohArray);

Give this a try and let us know.

Jim Lucas

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



Re: [PHP] Manipulating variables

2011-02-23 Thread Jim Lucas

On 2/23/2011 8:48 PM, Ron Piggott wrote:


Is there a way to make this syntax:

$checking_answer = $answer_reference_2;

Equal to:

$checking_answer = $answer_reference_ . ($i + 1);

(where $i = 1)

making $checking_answer take on the value of $answer_reference_2 ?

I am trying to develop a web app quiz and I need to test the users answers.

Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info



Give this a try


--
Jim Lucas
http://www.cmsws.com

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



Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-23 Thread Jim Lucas
On 2/23/2011 4:35 AM, Gary wrote:
> "Pete Ford"  wrote in message 
> news:62.c1.32612.d49d4...@pb1.pair.com...
>> This bit?
>>
>> On 22/02/11 22:06, Gary wrote:
>>> for($i=1; $i<=$_POST['counties']; $i++) {
>>> if ( isset($_POST["county{$i}"] ) ) {
>>
>> You loop over $_POST['counties'] and look for $_POST["county$i"]
>>
>> I suspect that there is no field 'counties' in your form, so the server is 
>> complaining about the missing index - seems likely that the production 
>> server
>> is not showing the error, but instead just giving up on the page.
>>
>> I think the IE7/Firefox browser difference is a red herring: it wasn't 
>> actually working in any browser, or the code changed between tests. 
>> Remember, PHP is server side and generates HTML (or whatever). Unless you 
>> tell the PHP what browser you are using and write PHP code to take account 
>> of that (not generally recommended) then the server output is the same 
>> regardless of browser.
>>
>> -- 
>> Peter Ford, Developer phone: 01580 89 fax: 01580 
>> 893399
>> Justcroft International Ltd. 
>> www.justcroft.com
>> Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United 
>> Kingdom
>> Registered in England and Wales: 2297906
>> Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 
>> 1XS
> 
> 
> Pete
> 
> Once again, thank you for your help.
> 
> I was able to get it to work, I did not understand the browser differences 
> either, but on my testing server on IE, it worked as I wanted but not on 
> anything else.  I chopped out most of the code and ended up with this:
> 
> if ( isset($_POST['submit']) ) {} else {
> print "\n";
> if ($Recordset1) {
> print "\n";
> print "  \n";
> print " State \n"; //2 fields in Counties table, State and County
> print " County \n";
> print "\n";
> //create table
> $i = 0;
> while ( $row = mysql_fetch_array($Recordset1) ) {
> $i++;
> print "\n";
> print " value=\"$row[name]\">\n";
> echo "{$row['state_id']}\n";
> echo "{$row['name']}\n";
> echo "\n";
> }//end while
> print "\n";
> } else {
> echo("Error performing query: " .
> mysql_error() . "");
> }
> print "\n";
> print "\n";
> }
> ?>
> 
> Again, thank you.
> 
> Gary 
> 
> __ Information from ESET Smart Security, version of virus signature 
> database 5899 (20110223) __
> 
> The message was checked by ESET Smart Security.
> 
> http://www.eset.com
> 

If you would allow me to show you a little easier way of doing this.

if ( !isset($_POST['submit']) ) {
  echo '';
  if ($Recordset1) {
echo <<
      State  County 
HEADER;
while ( $row = mysql_fetch_array($Recordset1) ) {
  echo <<

{$row['state_id']}
{$row['name']}
  
ROW;
  }//end while
  echo '';
} else {
  echo 'Error performing query: '.mysql_error().'';
}
  echo '';
}

Now, the main thing I want you to see is the line for the country checkbox'es

The county[] turns the submitted values into an array.  So, in the processing
script, you would do this.

 $name )
echo "{$id} {$name}\n";

...
?>

Hope this clears things up for you a little.

Enjoy.

Jim

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



Re: [PHP] code quest

2011-02-14 Thread Jim Lucas
On 2/14/2011 4:53 PM, Kirk Bailey wrote:
> Now I have a situation. I need to take the code from my former home page and
> modify it to lay out a table (let's say 5 cells wide) and as many rows deep to
> contain all the items. Each item is the name of the directory, under which is 
> an
> icon image from that directory, under which is a description file read from 
> that
> directory. Here is my code thus far:
> 
>  # The next several lines declare an array of directories which are NOT to be
> listed!#
> $excludes[] = 'attachments'; #20
> $excludes[] = 'data';
> $excludes[] = 'include';
> $excludes[] = 'resources';
> $excludes[] = 'stats';
> $excludes[] = '_private';
> $excludes[] = '_vti_bin';
> $excludes[] = '_vti_cnf';
> $excludes[] = '_vti_log';
> $excludes[] = '_vti_pvt';
> $excludes[] = '_vti_txt'; #30
> $excludes[] = '_vxi_txt';
> $excludes[] = 'css';
> $excludes[] = 'img';
> $excludes[] = 'images';
> $excludes[] = 'js';
> $excludes[] = 'cgi';
> $excludes[] = 'cgi-bin';
> $excludes[] = 'ssfm';
> $ls = scandir(dirname(__FILE__));
> echo ' align="center">'; #40
> foreach ($ls as $d) {  if (is_dir($d) && !preg_match('/^\./',basename($d))
> &&!in_array(basename($d),$excludes))
>  {
>   echo ''.$d.' border="5">';
>   include($d."/desc.txt");
>   echo '';
>   };
> };
> echo '';
> ?>
> 
> Now I am stymied on changing this to add  at the right points in the
> structure. I am new to php, and welcome all suggestions and gainful comments.
> 

You want modulo math...

Check out this page

http://www.cmsws.com/examples/php/modulo_array_output.php

If you like the output, here is the source

http://www.cmsws.com/examples/php/modulo_array_output.phps

The bottom two examples show how you can use other HTML tags to present data.

Jim Lucas

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



Re: [PHP] Simplifying MySql queries

2011-02-12 Thread Jim Lucas

On 2/12/2011 12:40 PM, Andre Polykanine wrote:

Hi all,
I'm using in my PHP script the following four MySql queries:
$q1=mysql_query("SELECT *FROM`CandidateQuestions`WHERE
`Category`='1' ORDER BY RAND() LIMIT 1");
$q2=mysql_query("SELECT *FROM`CandidateQuestions`WHERE
`Category`='2' ORDER BY RAND() LIMIT 1");
$q3=mysql_query("SELECT *FROM`CandidateQuestions`WHERE
`Category`='3' ORDER BY RAND() LIMIT 1");
$q4=mysql_query("SELECT *FROM`CandidateQuestions`WHERE
`Category`='4' ORDER BY RAND() LIMIT 1");

and  here  goes the question: is there a way to make these four in one
so  strictly  one  random  question  is  selected from all of the four
categories?
Thanks!



I think you will need something like this:

SELECT  *
FROM`CandidateQuestions`
WHERE   `Category` IN (1,2,3,4)
GROUP BY `Category`
ORDER BY RAND()
LIMIT 4

Now, what I'm not sure about, nor have I tested, is will mysql do the 
ORDER BY RAND() before or after the GROUP BY.


If that doesn't work, then I would try this instead:

SELECT  DISTINCT `Category`,

FROM`CandidateQuestions`
WHERE   `Category` IN (1,2,3,4)
ORDER BY RAND()
LIMIT 4

This will probably do the distinct after the ORDER BY RAND(), but again, 
completely untested.  YMMV


Give them a whirl and let us know how it works out.

Jim Lucas

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



Re: [PHP] using BOTH GET and POST in the same page.

2011-02-12 Thread Jim Lucas

On 2/11/2011 9:23 PM, Ashim Kapoor wrote:

Dear All,

I am reading "PHP5 and MySQL Bible". Chapter 7 of the book says that PHP can
use GET and POST in the SAME page! Also it says that we can use the SAME
variables in GET and POST variable sets and that conflict resolution is done
by variable_order option in php.ini Can some one write a small program to
illustrate the previous ideas?  It is not clear to me as to how to implement
this.

Many thanks,
Ashim.




But basically, the short of it is this.


  
  

  

  Name:

  
  
  

  
  
  

  


When submitted with data to this:



Will result in this:

Array
(
[page_id] => 22
[action] => AddUser
)
Array
(
[action] => DelUser
    [FullName] => Jim Lucas
)
Array
(
[page_id] => 22
[action] => DelUser
[FullName] => Jim Lucas
)

Check out the example that I wrote here http://www.cmsws.com/?page_id=5

Jim Lucas

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



Re: [PHP] file upload utility ?

2011-02-07 Thread Jim Lucas
On 2/7/2011 8:03 AM, Frank Bonnet wrote:
> On 02/07/2011 05:01 PM, Daniel Brown wrote:
>> On Mon, Feb 7, 2011 at 10:56, Frank Bonnet  wrote:
>>> Hello
>>>
>>> I'm searching for a utility that let our users upload a file
>>> on a server , then generate a temporary link that point
>>> to the real file.
>>>
>>> As this is for internal use we don't need security, the file
>>> can be read by anyone.
>>>
>>> The goal is to distribute the file to our users by sending
>>> them an email containing the address of the http temporary
>>> link instead of sending it as an email attachement X 1000 ...
>>  Sounds great.  Good luck in your Google search.
>>
> I found nothing that's why I wrote this !!!
> 
> 
> 

Frank,

Not sure what words you used, here was mine

php file upload examples

Those words resulted in these two at the top of the list

http://www.tizag.com/phpT/fileupload.php
http://www.w3schools.com/PHP/php_file_upload.asp

I briefly read each of them and they are sufficient for what you are trying to
do.  All you have to do is tie in the email portion and that's that.

So, again, to google, I typed these wonderful words of wisdom.

php email example

The first result was this

http://www.w3schools.com/PHP/php_mail.asp

This will get you a very simple email script working.  Personally, I would not
do it this way, but since you mention that this will be all internal, it will
probably do just fine.  If you want a little more control over the email or plan
to use this to send email to outside recipients, I would recommend doing it
differently.

phpmailer

Download that package, then follow its tutorials on how to set it up and send
emails.

phpmailer examples

The first result is this

http://phpmailer.worxware.com/index.php?pg=examples

It has a variety of examples that should cover almost any scenario you can
possibly think of.

Just one thing, do not try and be a cut/paste god here.  Actually take time to
read the examples and understand what they do before you put them into 
production.

This will now end my "How to use Google" segment for the day.

Jim Lucas

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



Re: [PHP] override built-in mail()

2011-02-04 Thread Jim Lucas
On 2/4/2011 5:37 AM, Steve Staples wrote:
> Hello Guys/Gals,
> 
> it's friday (at least where I am it is) and I have an issue with a
> script that I just started using again.  The problem is, is that it uses
> the built in PHP mail() function, and on my testing server, mail()
> doesn't work. The other issue, is that I use SMTP Auth to connect to my
> mail server, so that when mail sends out, it comes from my mail server
> so that there is less of a chance for being marked as SPAM.
> 
> So, what I am looking to do, is use either the trust old Pear::Mail or
> PHPMailer scripts (I am sure there are other ones out there, but those
> are the 2 I am most familiar with).
> 
> So now to my actual question.  How can I override the built-in PHP
> mail() function, to let either of those 2 (or something else someone may
> suggest) to act in the same manner as the mail() function?
> 
> Is this easy?  I've googled, but haven't seen any reference to doing
> what I am looking to do (maybe I just can't google)
> 
> Steve
> 
> 

You cannot "override" a function.  You will have to write a new function,
"my_mail" or some such.  Have it take the same arguments as the built in mail
function, but internally it uses phpmailer or the likes.  Then, do a search and
replace for " mail(" with " my_mail("

One other possible option, which I had not contemplated until now, would be to
actually specify a replacement sendmail executable when setting up the sendmail
option in the php.ini.  You could specify a php script that can run as though it
was sendmail, accept the same arguments, etc... but do all the phpmailer stuff
inside.

Jim Lucas

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



Re: [PHP] PEAR & PHP

2011-01-30 Thread Jim Lucas

On 1/30/2011 2:34 PM, Ethan Rosenberg wrote:


I make more mistakes reading emails than you do!!

Would you [or anyone else on this list] please help me with my questions

1] How do I install it? [msql NOT mysql] apt-get install does not find
the package.


http://www.google.com

Enter " apt-get install msql" ...

I entered "linux apt-get install msql"

and the second result I get is this

http://ubuntuforums.org/archive/index.php/t-350269.html

If your distro is not ubuntu, I'm sorry, but you haven't said what you 
are running yet.




2] Excuse my ignorance, what is a dynamic extension?


Again, http://www.google.com

Enter "what is a dynamic extension" ...

Here is a good result from the list returned

http://www.atnf.csiro.au/computing/software/karma/programmer-manual/node17.html



Thanks.

Ethan





I hope this gets you headed down the right path.

Jim Lucas

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



Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 11:23 AM, David Harkness wrote:
> On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay  wrote:
> 
>> If COUNTing is the heavy part, why not create a 'users_logged_in'
>> field somewhere and increment it when someone logs in and decrement it
>> when someone logs out?  Then your query is just a straight SELECT.
> 
> 
> If this is like most web sites, users don't usually log out--they just stop
> requesting pages. With no logout event to decrement the count you need some
> other way to stop counting a particular user such as 30 minutes after they
> logged in. This is easily handled in a query on the users table, but it
> causes performance issues.
> 
> David
> 

cron it.

Setup a cron script that runs every 5 minutes.

A seconds work every 5 minutes isn't too much is it?

Jim Lucas

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



Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 9:57 AM, AmirBehzad Eslami wrote:
> Dear list,
> 
> The common solution for counting online users is to store sessions in a Table.
> I've created a Table in MySQL to acheive the result, but it seems this 
> solution
> is a little heavy for such a simple task.
> 
> Is there a better alternative? Can I use SqlLite to make COUNT(*) queries 
> based
> on a where statement?
> 
> Is there any better solution? Do you know any way to store sessions in Memory?
> 
> Does Memcache support counting sessions?
> 
> I'm looking for a high-performance solution to count online users.
> What do you think?
> 

The simple way that we do it is to have users table have a boolean field that
gets updated when a person logs in, then a time field showing when they last
visited.  These together should give you the information that you are looking 
for.

This gives you the idea...

SELECT  COUNT(*)
FROMusers_table
WHERE   logged_in = 't'
AND last_activity > FROM_UNIXTIME( UNIX_TIMESTAMP() - 1800 )

Jim Lucas

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



Re: [PHP] Formatting

2011-01-25 Thread Jim Lucas

On 1/25/2011 9:05 PM, Ethan Rosenberg wrote:

Dear list -

I have a program with the following statement: $out = system('ls -l',
$retval); The output is a string. How do I format the output to be in
the Linux format, that is in columns. I cannot think of a way to use
explode to do it.

Advice and comments, please.

Thanks

Ethan

MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]




Well, depends, are you running this in a browser or at the console?

If you are displaying this in a browser, you are probably seeing that 
browsers do not like \n (newlines)


If in a browser, you could:
1) Wrap your output in a  HTML tag
2) Use PHP's nl2br() to replace all newlines with "" tags
3) Use PHP's header() function to tell the browser to display the output 
as plaintext.  i.e. header('Content-Type: text/plain'); [1,2]


1 - Google "php header plain text"
2 - http://www.php.net/manual/en/function.header.php#92620

If in cli...  well, you wouldn't be having this problem... :)

Jim Lucas

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



Re: [PHP] preg_replace question

2011-01-24 Thread Jim Lucas
On 1/24/2011 8:00 AM, Merlin Morgenstern wrote:
> Hi there,
> 
> I am trying to replace certain words inside a text with php. Unfortunatelly my
> function is creating invalid html as output.
> 
> For example the words "beagle" and "welpen" have to be replaced inside this
> text: "süße knuffige Beagle Welpen ab sofort"
> 
> My result looks like this:
> zwei süße knuffige Beagle  href="/bsp/hunde">Welpen
> 
> The problem is, that my function is not closing the href tag before it starts 
> to
> replace the next item.
> 
> Here is the code:
> 
> 
> // create internal links
> function internal_links($str, $links, $limit) {
> foreach($links AS $link){
> $pattern[$k] = "~\b($link[phrase])\b~i";
> $replace[$k] = '\\1';
> $k++;
> }
> return preg_replace($pattern,$replace,$str, $limit);
> }
> 
> I
> 
> 
> I could not find a way to fix this and I would be happy for some help. Thank 
> you
> in advance!
> 
> Merlin
> 

Do you have control over the building of the initial "phrase" => "link" assoc?

If so, reverse the order of these two items.

Jim Lucas

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



Re: [PHP] Script mysteriously restarting

2011-01-21 Thread Jim Lucas
On 1/21/2011 12:37 PM, Richard S. Crawford wrote:
> I've got a massive PHP script which takes nearly an hour to run. Sometimes,
> when it comes close to the end, it mysterious restarts itself and I have to
> wait for another hour for it to complete.
> 
> Is there any reason why a PHP script would restart itself like this?
> 
> FWIW, I'm running PHP5 with Apache 2 on a Linux server.
> 

Clarification please.

Is this cli or browser based?

Jim

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



Re: [PHP] [PHP]: permission problem www-data

2011-01-18 Thread Jim Lucas
On 1/18/2011 2:19 AM, a...@ashleysheridan.co.uk wrote:
> Because the web server is what runs php as a module, and the web server has 
> its own user for security reasons. You could try chmod but that is generally 
> a last resort.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> - Reply message -
> From: "Moses" 
> Date: Tue, Jan 18, 2011 10:17
> Subject: [PHP] [PHP]: permission problem www-data
> To: "a...@ashleysheridan.co.uk" 
> Cc: 
> 
> 

You could run PHP in FastCGI mode and start it as your user.  Then have your web
server use that PHP instance for your web site to process all PHP requests.

This is how we have our servers at the office setup.  Works great.

Jim Lucas

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



Re: [PHP] [PHP]: permission problem www-data

2011-01-18 Thread Jim Lucas
On 1/18/2011 1:44 AM, Moses wrote:
> Hi Everyone,
> 
> I am creating a file in PHP script which takes a value from a form and
> writes it
> to a file. However, i don't have the mode permission for the file instead it
> is owned
> by www-data.What can i do to ensure that the file is owned by me.
> 
> 
> drwxr-xr-x 2 www-data www-data 4096 2011-01-17 22:01 18757170111.0
> -rw-r--r-- 1 www-data www-data   40 2011-01-17 23:39 32238.hydro
> 
> Thanks.
> 

Have the PHP process run as your user.

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



Re: [PHP] [security] PHP has DoS vuln with large decimal points

2011-01-16 Thread Jim Lucas
On 1/16/2011 4:18 PM, Tommy Pham wrote:
>> -Original Message-
>> From: Tommy Pham [mailto:tommy...@gmail.com]
>> Sent: Thursday, January 06, 2011 5:49 PM
>> To: 'Daevid Vincent'
>> Cc: 'php-general@lists.php.net'
>> Subject: RE: [PHP] [security] PHP has DoS vuln with large decimal points
>>
>>> -Original Message-
>>> From: Daevid Vincent [mailto:dae...@daevid.com]
>>> Sent: Wednesday, January 05, 2011 11:36 AM
>>> To: php-general@lists.php.net
>>> Subject: [PHP] [security] PHP has DoS vuln with large decimal points
>>>
>>> The error in the way floating-point and double-precision numbers are
>>> handled sends 32-bit systems running Linux, Windows, and FreeBSD into
>>> an infinite loop that consumes 100 percent of their CPU's resources.
>>> Developers are still investigating, but they say the bug appears to
>>> affect versions 5.2 and 5.3 of PHP. They say it could be trivially
>>> exploited on many websites to cause them to crash by adding long
>> numbers to certain URLs.
>>>
>>> 
>>>
>>> The crash is also triggered when the number is expressed without
>>> scientific notation, with 324 decimal places.
>>>
>>> Read on...
>>>
>>> http://www.theregister.co.uk/2011/01/04/weird_php_dos_vuln/
>>>
>>> --
>>> Daevid Vincent
>>> http://daevid.com
>>>
>>> There are only 11 types of people in this world. Those that think
>>> binary jokes are funny, those that don't, and those that don't know
> binary.
>>>
>>
>> "The size of a float is platform-dependent, although a maximum of ~1.8e308
>> with a precision of roughly 14 decimal digits is a common value (the 64
> bit
>> IEEE format)."  From [1].  The example given is clearly over the limit
> within
>> the PHP core.
>>
>> This sounds like what I was mentioning before, in a different thread,
> about
>> URL hacking to induce buffer overflow.
>>
>> Regards,
>> Tommy
>>
>> [1] http://www.php.net/manual/en/language.types.float.php
> 
> I found something really weird while coding a validator for floating
> protection protection.
> 
> Case 1 - known DoS / PHP hangs in infinite loop:
> 
>   $value = '2.2250738585072011e-308';
>   var_dump(floatval($value));
> 
> Case 2 - works fine:
> 
>   $value = '2.2250738585072011e-307';
> or
>   $value = '2.2250738585072011e-309';
> or
>   $value = '2.225073858507201e-308';
> 
>   var_dump(floatval($value));
> 
> I'd expect the '2.2250738585072011e-309' to hang also on my Win x64 with PHP
> FastCGI.  I haven't test it on *nix platform yet.   Could someone please
> confirm this?
> 
> Thanks,
> Tommy
> 
> 

Seems to work fine for me.

$ cat float.php

$ php -f float.php
Example 1
float(2.2250738585072E-307)
float(2.2250738585072E-307)
Example 2
float(2.2250738585072E-308)
float(2.2250738585072E-308)
Example 3
float(2.2250738585072E-309)
float(2.2250738585072E-309)
Example 4
float(2.2250738585072E-308)
float(2.2250738585072E-308)

$ uname -a
OpenBSD serv0.cmsws.com 4.3 GENERIC#698 i386
$ php -v
PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Mar 11 2008 13:08:50)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Suhosin v0.9.20, Copyright (c) 2002-2006, by Hardened-PHP Project

No infinite loop.  I like my system... :)

Jim Lucas

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



Re: [PHP] email list 101

2011-01-16 Thread Jim Lucas

On 1/16/2011 7:09 AM, Kirk Bailey wrote:

So, in php, I want a program to handle sending out a mail list. All this
is going to do is be a filter to exclude non subscribers, and send a
copy to every person in the subscriber file. This is pretty simple in
python, but this is not my mother tounge we speak here, so let's talk in
php instead.

If the submission does not come from a member, the script simply aborts.
So the script should read the subscriber file, and if the source From:
does not appear there, DIE. If it is there, walk the array and send a
copy there, then end.

Now how to do this in php? Is there an off the shelf solution?




Is this something that you plan on executing with your SMTP server or 
through a web script?

Do you care how the subscribers file is managed?  If at all...
How is the subscriber file formatted?

With the above questions unanswered, I would do something along the 
lines of the following.


form.php:


INPUT:fromname:value (display name)
INPUT:fromaddr:value (email address)
INPUT:subject:Something special
INPUT:message:the message goes here




process.php:
IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.example.com";  // specify mail server host name
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "";  // SMTP username
$mail->Password = ""; // SMTP password

$mail->From = $clean_post['fromaddr'];
if ( !empty($clean_post['fromname']) )
{
  $mail->FromName = $clean_post['fromname'];
  $mail->AddReplyTo($clean_post['fromaddr'], $clean_post['fromname']);
} else {
  $mail->AddReplyTo($clean_post['fromaddr']);
}
$mail->Subject = $clean_post['subject'];
$mail->Body= $clean_post['message'];
$mail->AltBody = strip_tags($clean_post['message']);

# add each person
foreach ( $subscribers AS $addr )
{
  $mail->AddAddress($addr);
  # if you have a name associated to that address, do this instead
  # assuming line format as: em...@address.com,My Name
  list($addr, $name) = explode(',', $addr, 2)
  $mail->AddAddress($addr, $name);
}

if(!$mail->Send())
{
  echo "Message could not be sent. ";
  echo "Mailer Error: " . $mail->ErrorInfo;
  exit;
}

if ( ! headers_sent() )
  header('Location: http://www.example.com/done.php');

?>

--
Jim Lucas

DISCLAIMER: Unless otherwise noted, all code is untested!

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



Re: [PHP] which php file is sending emails?

2011-01-15 Thread Jim Lucas
On 1/15/2011 10:51 AM, Nilesh Govindarajan wrote:
> On 01/15/2011 11:13 PM, Daniel Brown wrote:
>> On Sat, Jan 15, 2011 at 12:21, Nilesh Govindarajan  wrote:
>>> On 01/15/2011 10:22 PM, Jim Lucas wrote:
>>>>
>>>> Um, I use OpenBSD and that command gives me an error or two...
>>>>
>>>> $ grep -l mail $(find -name *.php)
>>>> find: unknown option -- n
>>>> find: unknown option -- a
>>>> find: unknown option -- m
>>>> find: unknown option -- e
>>>> formmail.php
>>>>
>>>> $ grep -l mail $(find ./ -name "*.php")
>>>> Output a big long list of files...
>>>
>>> So the second one is right.
>>
>>  His point was in the irony --- you sent a rather insulting message
>> to the OP suggesting he needs to "revise [his] sysadmin skills,"
>> whereas your own example was broken.  Probably just a typo, but
>> something worth a second thought for next time.
>>
> 
> hahaha, that command wasn't broken. It works on Linux. But certain commands 
> have
> to be changed to work on *BSD.
> 
> For example, chmod u=rwx,g=rwx,o= directory -R will work on linux, but will 
> not
> on FreeBSD. It has to be changed to chmod -R u=rwx,g=rwx,o= directory.
> 

Ok, are you trying to pull our chain here???  Which version of Linux?  I have
tried your example on CentOS release 4.2 (Final), and CentOS release 5.5
(Final), and it gives me this

# grep -l mail $(find -name *.php)
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

and it just sits there waiting for input, just like grep would if I did this

# grep -l mail

I have to surround the name value in quotes to make it work.  Like so...

# grep -l mail $(find -name "*.php")

So, please, within what version of Linux does your example work?

If you are going to give advice and want to contribute good working example code
to the archives of this mailing list, please, for everybody's benefit make sure
the code example works as expected.  Or, if it is to used as a guide to get the
person thinking, say that.

Jim Lucas

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



Re: [PHP] which php file is sending emails?

2011-01-15 Thread Jim Lucas
On 1/14/2011 9:53 PM, Nilesh Govindarajan wrote:
> On 01/15/2011 06:21 AM, Mesut GULNAZ wrote:
>> is it possible to see which php file(s) is/are sending emails on my server
>> by php.ini or with any other way?
>>
>> coz i have a server and i have many domains and subdomains. on my smtp
>> systems i saw that many random mails are being sent from www server which
>> has RELAY permission. I know i must not give RELAY (i can use SMTP-AUTH) but
>> some kind of issues i have to give it.
>>
>> so i have to find the domain or subdomain and the file or files which send
>> this emails.
>>
>> how can i solve this issue?
>>
>> my system ise freebsd.
>>
>> thanks...
>>
> 
> grep -l mail $(find -name *.php)
> There can be nothing more simpler than this!!!
> Seriously man, you need to revise your sysadmin skills!
> 

Um, I use OpenBSD and that command gives me an error or two...

$ grep -l mail $(find -name *.php)
find: unknown option -- n
find: unknown option -- a
find: unknown option -- m
find: unknown option -- e
formmail.php

$ grep -l mail $(find ./ -name "*.php")
Output a big long list of files...


Jim Lucas

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



Re: [PHP] HTML errors

2011-01-11 Thread Jim Lucas

On 1/11/2011 7:35 PM, David McGlone wrote:

Hi Everyone, I'm having a problem validating some links I have in a foreach.
Here is my code:
  http://www.w3.org/TR/html4/loose.dtd";>

my PHP code:
$categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us',
'testimonials');
foreach($categorys as $category){
$replace = str_replace("_", " ", $category);
echo "$replace";


Try this instead

echo '',$replace,'';

Jim Lucas


}

Validator Error:
an attribute value must be a literal unless it contains only name characters

…ome>homeservices


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



Re: [PHP] Stripping carriage returns

2011-01-11 Thread Jim Lucas
On 1/11/2011 11:13 AM, Richard S. Crawford wrote:
> I'm retrieving CLOB data from an Oracle database, and cleaning up the HTML
> in it. I'm using the following commands:
> 
> $content =
> strip_tags($description->fields['CONTENT'],'');
> $content = preg_replace("//","",$content);
> 
> The second line is necessary because the  tag frequently comes with class
> or style descriptions that must be eliminated.
> 
> This works on the whole except where the  tag with the style definition
> is broken up over two or more lines. In other words, something like:
> 
> 
> 
> In this case, the second line of my code does not strip the class or style
> definitions from the paragraph tag. I've tried:
> 
> $content = nl2br($content)
> 
> and
> 
> $content = str_replace(chr(13),$content)
> 
> and
> 
> $content = preg_replace("/[".chr(10)."|".chr(13)."]/","",$content)
> (I've read that Oracle uses chr(10) or chr(13) to represent line breaks
> internally, so I decided to give those a try as well.)
> 
> and
> 
> $content = str_replace(array('\n','\r','\r\n'),$content)
> 
> all to no avail; these all leave the line break intact, which means my
> preg_replace('//','',$content) line still breaks.
> 
> Anyone have any ideas?
> 

Richard,

Looks like you need to read up on the modifiers for preg_* functions.  Start
here:  http://us3.php.net/manual/en/reference.pcre.pattern.modifiers.php

I would change your "second line" regex to the following.

$content = preg_replace("//is", "", $content);

The modifiers after the second / are

i = case-insensitive
s = include new lines in your '.' character match.
New lines are excluded by default.

Can't remember right now, nor do I have the time to test, you might need to
invert the greediness of the match using a 'U' after the second / also.

So...

$content = preg_replace("//isU", "", $content);

YMMV

Let us know how this works out for you.

Jim Lucas

PS: you might want to swap the order of these two statements.

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



Re: [PHP] Two forms on one page

2011-01-04 Thread Jim Lucas
On 1/4/2011 12:53 PM, Paul M Foster wrote:
> On Tue, Jan 04, 2011 at 10:08:47AM -0800, Jim Lucas wrote:
> 
> [snip]
>  
>> If this isn't it, I think you should explain (in sudo code) exactly the steps
>> you are expecting things to.
>>
>> Example sudo code
>>
> 
> [snip]
> 
> Normally I wouldn't comment on this (sorry, Jim), but for the foreigners
> on the list, "sudo" is a command under Unix/Linux which allows one to
> function as the root user. I suspect what Jim meant to write was
> "pseudo" (pronounced the same way as "sudo" in English), which means
> "fake" or "pretend". 
> 
> English is one of those languages which is afflicted by lots of
> homonyms-- words which sound the same but are spelled differently and
> mean different things, even though they sound the same.
> 
> Paul
> 

Paul,

Thanks for pointing that out.  I sometimes write too fast...

Jim

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



Re: [PHP] Two forms on one page

2011-01-04 Thread Jim Lucas
Sorry for top posting!

FYI: You might want to check the math in your calculations.  It says that I am
41 when my birthday is tomorrow and I will be 36...

On 1/4/2011 10:08 AM, Jim Lucas wrote:
> On 1/4/2011 7:53 AM, Ethan Rosenberg wrote:
>> At 03:45 AM 1/4/2011, you wrote:
>>> Ethan,
>>>
>>> Ok, I would do this with what I would call wizard steps...
>>>
>>> On 1/3/2011 3:17 PM, Ethan Rosenberg wrote:
>>>> Oooops - left out the text that was supposed to be in the quotes.
>>>>
>>>> Dear List -
>>>>
>>>> I would like to have two(2) forms in one PHP script. I would like to
>>>> have the forms appear sequentially; ie, that the first form would
>>>> appear, the data would be entered, and then the second form would
>>>> appear, the data would be entered, and the script would exit.
>>>>
>>>> The code below displays both forms simultaneously. After the data is
>>>> entered for the first form, the second form appears again. After the
>>>> data is entered for the second form, the script displays the statement
>>>> "Enter your date of birth, in mm/dd/ format: " from the first form.
>>>>
>>>> Would you please help me correct the script so that it will perform as
>>>> required.
>>>>
>>>> Thanks.
>>>>
>>>> Here is the code:
>>>> 
>>>
> 
> To go back to what I originally wrote.  I found 1 error in the second form.
> Here is the corrected form.
> 
> 
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> 
>  
> switch ( @$_POST['next_step'] )
> {
> case 'step3':
> 
> if ( empty($_SESSION['dob']) )
> die('DOB was not set in session...');
> 
> $dateArr = explode('/', @$_SESSION['dob']);
> 
> // calculate timestamp corresponding to date value
> $dateTs = strtotime($_POST['dob']);
> 
> // calculate timestamp corresponding to 'today'
> $now = strtotime('today');
> 
> // check that the value entered is in the correct format
> if ( sizeof($dateArr) != 3 )
> die('ERROR: Please enter a valid date of birth');
> 
> // check that the value entered is a valid date
> if ( !checkdate($dateArr[0], $dateArr[1], $dateArr[2]) )
> die('ERROR: Please enter a valid date of birth');
> 
> // check that the date entered is earlier than 'today'
> if ( $dateTs >= $now )
> die('ERROR: Please enter a date of birth earlier than today');
> // calculate difference between date of birth and today in days
> // convert to years
> // convert remaining days to months
> // print output
> $ageDays = floor(($now - $dateTs) / 86400);
> $ageYears = floor($ageDays / 365);
> $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
> echo "You are approximately $ageYears years and $ageMonths months old.";
> 
> break;
> case 'step2':
> $_SESSION['dob'] = @$_POST['dob'];
> echo << 
> 
> Enter your kitten's name: 
> 
> 
> 
> FORM;
> 
> break;
> case 'step1':
> default:
> 
> echo << 
> 
> Enter your date of birth, in mm/dd/ format: 
> 
> 
> 
> FORM;
> }
> ?>
> 
> 
> If this isn't it, I think you should explain (in sudo code) exactly the steps
> you are expecting things to.
> 
> Example sudo code
> 
> 1.  display form 'A'
> 2.  Person enters dob and presses submit
> 3.  processing script stores dob submitted
> 4.  display form 'B'
> 5.  person enters name of kitten and presses submit
> 6.  processing script retrieves dob previously stored
> 7.  calculate age
> 8.  display age
> ...
> 10. What happen to the kitten???
> 
> Form 'A':
> 
> 
> Enter your date of birth, in mm/dd/ format: 
> 
> 
> 
> 
> Form 'B':
> 
> 
> Enter your kitten's name: 
> 
> 
> 
> 
> 
> Anyways, that is the idea.
> 
> Let us know.
> 
> Jim
> 
>> Please correct my errors.
>>
>> Thanks again.
>>
>> Ethan
>> +++
>>
>>> 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] Two forms on one page

2011-01-04 Thread Jim Lucas
On 1/4/2011 7:53 AM, Ethan Rosenberg wrote:
> At 03:45 AM 1/4/2011, you wrote:
>> Ethan,
>>
>> Ok, I would do this with what I would call wizard steps...
>>
>> On 1/3/2011 3:17 PM, Ethan Rosenberg wrote:
>>> Oooops - left out the text that was supposed to be in the quotes.
>>>
>>> Dear List -
>>>
>>> I would like to have two(2) forms in one PHP script. I would like to
>>> have the forms appear sequentially; ie, that the first form would
>>> appear, the data would be entered, and then the second form would
>>> appear, the data would be entered, and the script would exit.
>>>
>>> The code below displays both forms simultaneously. After the data is
>>> entered for the first form, the second form appears again. After the
>>> data is entered for the second form, the script displays the statement
>>> "Enter your date of birth, in mm/dd/ format: " from the first form.
>>>
>>> Would you please help me correct the script so that it will perform as
>>> required.
>>>
>>> Thanks.
>>>
>>> Here is the code:
>>> 
>>

To go back to what I originally wrote.  I found 1 error in the second form.
Here is the corrected form.


http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

= $now )
die('ERROR: Please enter a date of birth earlier than today');
// calculate difference between date of birth and today in days
// convert to years
// convert remaining days to months
// print output
$ageDays = floor(($now - $dateTs) / 86400);
$ageYears = floor($ageDays / 365);
$ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
echo "You are approximately $ageYears years and $ageMonths months old.";

break;
case 'step2':
$_SESSION['dob'] = @$_POST['dob'];
echo <<

Enter your kitten's name: 



FORM;

break;
case 'step1':
default:

echo <<

Enter your date of birth, in mm/dd/ format: 



FORM;
}
?>


If this isn't it, I think you should explain (in sudo code) exactly the steps
you are expecting things to.

Example sudo code

1.  display form 'A'
2.  Person enters dob and presses submit
3.  processing script stores dob submitted
4.  display form 'B'
5.  person enters name of kitten and presses submit
6.  processing script retrieves dob previously stored
7.  calculate age
8.  display age
...
10. What happen to the kitten???

Form 'A':


Enter your date of birth, in mm/dd/ format: 




Form 'B':


Enter your kitten's name: 





Anyways, that is the idea.

Let us know.

Jim

> Please correct my errors.
> 
> Thanks again.
> 
> Ethan
> +++
> 
>> 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] Two forms on one page

2011-01-04 Thread Jim Lucas

Ethan,

Ok, I would do this with what I would call wizard steps...

On 1/3/2011 3:17 PM, Ethan Rosenberg wrote:

Oooops - left out the text that was supposed to be in the quotes.

Dear List -

I would like to have two(2) forms in one PHP script. I would like to
have the forms appear sequentially; ie, that the first form would
appear, the data would be entered, and then the second form would
appear, the data would be entered, and the script would exit.

The code below displays both forms simultaneously. After the data is
entered for the first form, the second form appears again. After the
data is entered for the second form, the script displays the statement
"Enter your date of birth, in mm/dd/ format: " from the first form.

Would you please help me correct the script so that it will perform as
required.

Thanks.

Here is the code:




http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

= $now )
die('ERROR: Please enter a date of birth earlier than today');
// calculate difference between date of birth and today in days
// convert to years
// convert remaining days to months
// print output
$ageDays = floor(($now - $dateTs) / 86400);
$ageYears = floor($ageDays / 365);
$ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
echo "You are approximately $ageYears years and $ageMonths months old.";

break;
case 'step2':

$_SESSION['dob'] = @$_POST['dob'];

echo <<

Enter your kitten's name: 



FORM;

break;
case 'step1':
default:

echo <<

Enter your date of birth, in mm/dd/ format: 




FORM;

}

?>




This is completely untested, typed directly in the email client.  Most 
of the code is cut/paste from your examples.  But, it should give you a 
good starting point for a multi-step form type.


Jim

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



Re: [PHP] Regex for telephone numbers

2010-12-31 Thread Jim Lucas
On 12/29/2010 4:35 PM, Daniel P. Brown wrote:
> On Wed, Dec 29, 2010 at 19:12, Ethan Rosenberg  wrote:
>> Dear List -
>>
>> Thank you for all your help in the past.
>>
>> Here is another one
>>
>> I would like to have a regex  which would validate that a telephone number
>> is in the format xxx-xxx-.
> 
> Congrats.  People in Hell would like ice water.  Now we all know
> that everyone wants something.  ;-P
> 
> Really, this isn't a PHP question, but rather one of regular
> expressions.  That said, something like this (untested) should work:
> 
>  
> $numbers = array(
> '123-456-7890',
> '2-654-06547',
> 'sf34-asdf-',
> 'abc-def-ghij',
> '555_555_',
> '000-000-',
> '8007396325',
> '241-555-2091',
> '800-555-0129',
> '900-976-739',
> '5352-342=452',
> '200-200-2000',
> );
> 
> foreach ($numbers as $n) {
> echo $n.(validate_phone($n) ? ' is ' : ' is not ').'a valid
> US/Canadian telephone number.'.PHP_EOL;
> }
> 
> 
> function validate_phone($number) {
> 
> if 
> (preg_match('/^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$/',trim($number)))
> {
> return true;
> }
> 
> return false;
> }
> ?>
> 
> 

Actually...

Specified here [1] it says that the {1,} is the same as '+'.  I think you should
drop the comma.  If you don't this would be valid 844-2345-123456

^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$

should be

^[2-9]{1}[0-9]{2}\-[2-9]{1}[0-9]{2}\-[0-9]{4}$


1  http://us.php.net/manual/en/regexp.reference.repetition.php

Jim Lucas

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



Re: Fwd: Fwd: Re: [PHP] goto - My comments

2010-12-27 Thread Jim Lucas
On 12/27/2010 10:42 AM, Ethan Rosenberg wrote:
> Jim -
> 
> Thank you ever so much.
> 
> At 01:58 PM 12/24/2010, you wrote:
> 
>> Here you are using two different arrays.  Yes, I know, they are basically the
>> same, but they are truly not the same.  In your case, use $_POST
>>
>> >>>> This is what I used.  As per your suggestion, I changed the == to ===.
>>> if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )
>>> {
>>> if ($_REQUEST['Sex'] == "0")
>>> {
>>> $sex = 'Male';
>>> }
>>> else
>>> {
>>> $sex = 'Female';
>>> }
>>> }
>>
>> >>>> This defaults to Male.  I do not always search the Sex field.
>> if ( empty($_POST['Sex']) )
>> {
>> $_POST['Sex'] = 'Male';
>> } else {
>> $_POST['Sex'] = 'Female';
>> }
>>
>> +++
> 
> 
> Now, here is the real puzzler
> 
> The purpose of this routine is to be able to have two(2) forms on one 
> page,but 
> not simultaneously.Additionally, l do not wish to call a separate program 
> every
> time a new form is used.  The assumption is that the second form depends on 
> the
> entries in the first form.  I realize this is not the case here.
> 
> The age request and the kitten form both appear on the page together.  How do 
> I
> accomplish having them appear separately?  If it requires Java Script or 
> jQuery,
> what is the code to be used?
> 
> Here is the code
> ==
> "DTD/xhtml1-transitional.dtd">
> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
>   
> Project 4-5: Age Calculator
>   
>   
> Project 4-5: Age Calculator
>  // if form not yet submitted
> // display form
> 
> 
> if (!isset($_POST['dob']))
> {
> 
> echo "  ";
> echo "  Enter your date of birth, in mm/dd/ format: ";
> echo "  ";
> echo "  ";
> echo "  ";
> echo "  ";
> 
> }
> else
> {
> // if form submitted
> // process form input
> 
> 
>   // split date value into components
>   $dateArr = explode('/', $_POST['dob']);
> 
>   // calculate timestamp corresponding to date value
>   $dateTs = strtotime($_POST['dob']);
> 
>   // calculate timestamp corresponding to 'today'
>   $now = strtotime('today');
> 
>   // check that the value entered is in the correct format
>   if (sizeof($dateArr) != 3) {
> die('ERROR: Please enter a valid date of birth');
>   }
> 
>   // check that the value entered is a valid date
>   if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
> die('ERROR: Please enter a valid date of birth');
>   }
> 
>   // check that the date entered is earlier than 'today'
>   if ($dateTs >= $now) {
> die('ERROR: Please enter a date of birth earlier than today');
>   }
> 
>   // calculate difference between date of birth and today in days
>   // convert to years
>   // convert remaining days to months
>   // print output
>   $ageDays = floor(($now - $dateTs) / 86400);
>   $ageYears = floor($ageDays / 365);
>   $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
>   echo "You are approximately $ageYears years and $ageMonths months old.";
>  }
> 
> // SECOND FORM
> 
>  if (!isset($_POST['cat']))
>  {
> 
> echo "  ";
> echo "  Enter your kitten's name: ";
> echo "  ";
> echo "  ";
> echo "   Kitten\" />";
> echo "";
> }
> else
> {
> $name_cat = $_POST['cat'];
> 
> echo "Your Kitten is $name_cat";
> }
> ?>
> 
>   
> 
> ===
> Thanks again.
> 
> Ethan
> 
> 
> 

The key is to look at the value of the submit button.  This needs to be unique.

Change around your logic a little and you will have it.

= $now ) {
die('ERROR: Please enter a date of birth earlier than today');
  }

  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo "You are approximately $ageYears years and $ageMonths months old.";

} else if ( isset($_POST['submit']) && $_POST['submit'] === 'Submit Kitten' ) {

$name_cat = $_POST['cat'];
echo "Your Kitten is $name_cat";

} else {

echo <<
Enter your date of birth, in mm/dd/ format: 





Enter your kitten's name: 




HTML;

}

?>

Jim Lucas

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



Re: Fwd: Fwd: Re: [PHP] goto - My comments

2010-12-24 Thread Jim Lucas

On 12/23/2010 10:39 AM, Ethan Rosenberg, PhD wrote:

Jim -

Thanks ever so much!

Here is the code I used, as you suggested.

==
$query = "select * from Intake3 where ";


Maybe I missed it, but you need to have a 1 after the where part in your 
select.  So...


$query = "SELECT * FROM Intake3 WHERE 1 ";



$allowed_fields = array('Site', 'MedRec', 'Fname', 'Lname',
'Phone', 'Sex', 'Height');



Here you are using two different arrays.  Yes, I know, they are 
basically the same, but they are truly not the same.  In your case, use 
$_POST




if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )
{
if ($_REQUEST['Sex'] == "0")
{
$sex = 'Male';
}
else
{
$sex = 'Female';
}
}


Looking again at what I sent you before, it would have given you a few 
errors if ran like that.  Here is a better version of it.  For the 
above, you can change the logic and get rid of the isset and trim. 
Also, make sure when you do a comparison against "0" that it is type 
strict using === and not ==.  I could pass FALSE or NULL as the value 
and it would get by your test.  If you look at the definition of empty() 
it tells you that if empty is passed: "", 0, "0", NULL, FALSE, array(), 
or var $var; in a class that the return of empty will be false.  So, 
this tells me that I can replace the multiple if/else statements above 
with a single as below.


if ( empty($_POST['Sex']) )
{
$_POST['Sex'] = 'Male';
} else {
$_POST['Sex'] = 'Female';
}

The above does the same but without the extra work involved.  Once you 
have that, the following will work fine.





foreach ( $allowed_fields AS $field )
{
if ( ! empty( $_POST[$field] ) )
{
$value = mysql_real_escape_string( $_POST[$field] );
$query .= " AND `{$field}` = '{$value}' ";
}
}

printf($query);


This is the result I get for the query:

select * from Intake3 where AND `Site` = 'AA'

I can't figure out what is happening.

Would you please help.

Thanks again.

Ethan
+++




Date: Tue, 21 Dec 2010 22:33:17 -0800
From: Jim Lucas
To: Ethan Rosenberg
CC: "php-db-lists.php.net",
php-general@lists.php.net
Subject: Re: [PHP] goto - My comments

On 12/18/2010 9:17 PM, Ethan Rosenberg wrote:

Dear List -

Thanks to all for your EXCELLENT comments. I definitly agree that goto
is a command to be avoided at all costs. In this case, I could not
figure out how to acheive the desired result without the goto. So
being a newbie, I humbly request that you show [and at the same time
teach] me how to rewrite the code to eleiminate the goto.

Additionally, would you please do the same for the code I list below.
This code runs perfectly.
==
This is the form:


Site:
Record Number:
First Name:
Last Name:
Phone:
Height:
Male
Female





Not sure if you can change the values for the Sex field to 'Male'&
'Female' respectively, but it would simplify the following example.


Here is my rendition of how I would do it.



==
THANK YOU EVER SO MUCH FOR YOUR HELP.

Ethan








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



Re: [PHP] goto - My comments

2010-12-21 Thread Jim Lucas

On 12/18/2010 9:17 PM, Ethan Rosenberg wrote:

Dear List -

Thanks to all for your EXCELLENT comments. I definitly agree that goto
is a command to be avoided at all costs. In this case, I could not
figure out how to acheive the desired result without the goto. So
being a newbie, I humbly request that you show [and at the same time
teach] me how to rewrite the code to eleiminate the goto.

Additionally, would you please do the same for the code I list below.
This code runs perfectly.
==
This is the form:


Site: 
Record Number: 
First Name: 
Last Name: 
Phone: 
Height: 
Male
Female






Not sure if you can change the values for the Sex field to 'Male' & 
'Female' respectively, but it would simplify the following example.



Here is my rendition of how I would do it.

I would suggest cleaning up the output code some and use *_assoc() 
instead of the *_array() function call.  It gives you back the array 
version of the output.  This way instead of calling $row[0], $row[...] 
you would call $row['Fname'] or $row['Lname'] instead.


Get rid of all those commented out sections and you will have a good 
script to play with.


Let us know what comes of it...



==
THANK YOU EVER SO MUCH FOR YOUR HELP.

Ethan





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



Re: [PHP] array question

2010-12-18 Thread Jim Lucas

On 12/17/2010 12:52 PM, Sorin Buturugeanu wrote:

Hello all!

I have a question regarding arrays and the way I can use a value.

Let's say I have this string:

$s = 'banana,apple,mellon,grape,nut,orange'

I want to explode it, and get the third value. For this I would normally do:

$a = explode(',', $s);
echo $s[2];

That's all fine, but is there a way to get the value directly, without
having to write another line in my script. I mean something like this:

echo explode(',', $s)[2];

or

echo {explode(',', $s)}[2];

I couldn't find out this answer anywhere, that's why I posted here.

Cheers and thanks!



Sure it CAN be done.  Nobody laugh too loud here... But...


Outputs: grape

The {3} part is equivalent to the array position.  Change that number, 
and you change which word will get displayed.


Jim Lucas

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



Re: [PHP] HTML id attribute and arrays

2010-12-18 Thread Jim Lucas

What are you trying to accomplish?

What do you think it wrong with the code below?

On 12/17/2010 8:19 AM, Martin C wrote:

Hi,

PHP converts x[a]=b parameter of the HTTP request as an array named x
with its item named a set to value b. So, it seems possible to have the
following (X)HTML code:

Unfortunatelly, HTML specification does not allow neither "[" nor "]"
inside the id attribute. Specifically:
* Must begin with a letter A-Z or a-z
* Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".")
* Values are case-sensitive

How should I follow the HTML specification while having the passed
parameters automatically converted to arrays in PHP?

Thank you for any tips,

Martin




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



Re: [PHP] array_multisort into Natural order?

2010-12-13 Thread Jim Lucas
On 12/13/2010 11:59 AM, George Langley wrote:
> Hi all. Can use natsort($array1) to sort a single array of filenames into a 
> "natural "alphanumeric order - 1.php, 2.php, 5.php, 10.php, 20.php, etc.
> But using array_multisort($array1, $array2, $array3) doesn't offer a natsort 
> option, so I end up with 1.php, 10.php, 2.php, 20.php, 5.php, etc.
> 
> Anyone have a solution to this limitation already? Nothing found in the 
> archives or Googling.
>   Thanks.

assuming that you are not using other options of array_multisort(), why not do
something like this.

$ar = array_merge($array1, $array2, $array3);
natsort($ar);

> 
> 
> George LangleyMultimedia DeveloperAudio/Video EditorMusician, 
> Arranger, Composer www.georgelangley.ca
> 
> 
> 



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



Re: [PHP] new keyword combined with other things...

2010-12-07 Thread Jim Lucas
On 12/7/2010 7:40 AM, Alexandru Patranescu wrote:
> In many other languages this will work:
> 
> *$result = new Object() -> method();*
> 
> But in php, it fails at parsing.
> I've tried with parenthesis around new but nothing. Anyhow, as I saw later,
> *new* operator has precedence over others so this couldn't be a solution.
> I know a static function can be defined and the above statement can
> transform into
> 
> *$result = Object::getNewInstance() -> method()*
> 
> but is there any way to write it directly? and if not, why isn't this
> implemented yet and when will it be?
> 
> best regards,
> Patranescu Alexandru
> 


Here is what I do if I want to make it a one liner...

PrintString();

echo myNew('CustomClass')->ReturnString('Something Else');

$var = myNew('CustomClass')->ReturnString('And again...');

echo $var;

?>

I also use the following if I want to use the Singleton method of getting my 
data.

PrintString();

echo myClass::run()->ReturnString();

$var = myClass::run()->ReturnString();

echo $var;

?>

YMMV

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



Re: [PHP] code quest

2010-12-01 Thread Jim Lucas
On 11/26/2010 4:03 PM, Kirk Bailey wrote:
> Hello all, my name is Kirk Bailey, and I am new to php, so please be 
> forbearing.
> I code in python, and am trying to learn this language as our new client runs 
> a
> web business based in it.
> 
> I need a routine that will return a list of every directory immediately under
> the current directory- but nothing else, just a list of directories, 1 level
> deep, NO FILES, no listing of current dir or prior dir either.
> 
> Now in python, I would use os.walk, and use the list of dirs and throw the 
> other
> 2 lists away, but this ain't Kansas anymore. Does php even DO lists?
> 
> Um, a list is a 1 dimenional array, if have a list ALIST and you plug in 3, 
> you
> get back the contents of cell 3 in the list, whaqtever that content is. so if
> cell 3 in a 6 celled list was "Ruby" then ALIST[3] would return the string 
> "ruby".
> 
> It's easy to iterate lists. For instance:
> 
>print ''
>for dir in ALIST:
>print '",dir,'
>print '
> 
> This would let me produce an ordered list of directories, each a link to that
> directory.
> This way, when a client installs a new product, the home page area listing
> products offered automatically updates.
> 
> Further embellishment would let me replace the dir name with a BRIEF 
> description
> from a descriptor file read from that dir. Now how to do this in php?
> 

This should do.

The only problem that I foresee would be an empty "" if you have no
directories returned by glob().

print('');
foreach ( glob('./*', GLOB_ONLYDIR) AS $dir )
  print(''.$dir.'');
print('');


Jim Lucas

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



Re: [PHP] How to code in PHP an onchange event in a ?

2010-11-05 Thread Jim Lucas
On 11/4/2010 1:23 PM, Tomás Corrales Lemoine wrote:
> Hi, List,
> 
> I have this two files (“index.php” and “include.php”). They both work fine,
> but I want to substitute the code for de onchange event in the  tag.
> Can I use PHP to code this event? How?

Looks to me that you are looking for "chained select boxes".  Doing a G search
for that and the first result is this:

http://www.dhtmlgoodies.com/index.html?whichScript=ajax_chained_select

It has a very good example that shows the concept that you are trying to have
happen in your code below.

> 
> Thanks.
> 
> index.php:
>  echo '';
> include_once 'include.php';
> $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password');
> tcl_MySQL_OpenDataBase($mysql_link, 'production');
> $query = 'SELECT DISTINCT recipe.product_id, product.description FROM
> recipe, product WHERE recipe.product_id = product.product_id ORDER BY
> product.description';
> $result = tcl_MySQL_DataQuery($mysql_link, $query);
> tcl_FillComboBox($result, 'Product', 'product_id', 'description',
> 'alert(\'Alert Message\')');
> tcl_MySQL_CloseConnection($mysql_link);
> echo '';
> ?>
> 
> include.php:
>  function tcl_MySQL_CloseConnection($link) {
>   mysql_close($link);
> }
> function tcl_MySQL_ConnectToServer($host, $user, $password) {
>   $link = mysql_connect($host, $user, $password);
>   if (!$link) {
> die('No se pudo conectar: '.mysql_error());
>   }
>   echo 'User '.strtoupper($user).' connected to MySQL server.';
>   return $link;
> }
> function tcl_MySQL_DataQuery($link, $query) {
>   return mysql_query($query, $link);
> }
> function tcl_MySQL_OpenDataBase($link, $database) {
>   mysql_select_db($database, $link);
> }
> function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) {
>   echo ''.$label.' 
> onchange="'.$onchange.'">';
>   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> echo ''.$line[$col2];
>   }
>   echo '';
> }
> ?>
>  


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



Re: [PHP] Apache mod_pagespeed

2010-11-03 Thread Jim Jagielski
They are doing a preso about it @ ApacheCon.

On Wed, Nov 03, 2010 at 03:34:01PM -0400, Daniel P. Brown wrote:
> On Wed, Nov 3, 2010 at 14:48, Shreyas Agasthya  wrote:
> > Thiago,
> >
> > I would like to join this. Let me know how I can help you with this. Please
> > be explicit with your requests so that we can totally test it ?and see if it
> > could pose any risk to acceleration services provided by CDNs.
> 
> I've yet to read the specs behind it (I was out of the office),
> but from the overview I did see, it should not only be of no detriment
> to CDNs.  In fact, Google is working with an existing company,
> Cotendo, to integrate the core into their CDN.
> 
> -- 
> 
> Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
> (866-) 725-4321
> http://www.parasane.net/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
===
   Jim Jagielski   [|]   j...@jagunet.com   [|]   http://www.jaguNET.com/
"Great is the guilt of an unnecessary war"  ~ John Adams

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



Re: [PHP] PHP Question

2010-10-28 Thread Jim Lucas
Paulo Work wrote:
> Hello my name is Paulo Carvalho and I am struggling with the following:
> 
> I am building a website with basic CMS functionality.
> My problem is that in one of the pages I am using Easyslider to display
> small comments about the clients.
> 
> These comments are divided in 3 per slide.
> ex:(
> comment 1/p>
> comment 1/p>
> comment 1/p>
> )
> 
> Now I am struggling with the following:
> I am pulling the comments from the db and I would like to know if i can
> split that array in 3's (array_slice) perhaps?
> 
> My goal is to within a foreach loop output 3 comments within a
> slide(wrapped in ), so first 3 would output:
> 
> (
> comment 1/p>
> comment 2/p>
> comment 3/p>
> )
> Then another 3
> 
> (
> comment 4/p>
> comment 5/p>
> comment 6/p>
> )
> Thank in advance for all the replies.
> Paulo carvalho
> 

This looks like a job for modulo man.

I was hoping to simply give you a list of examples from google, but I couldn't
find any that showed exactly what you were trying to do, so... I wrote this
article for my site.  Let me know if you have any questions.

http://www.bendsource.com/phpModulo


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



Re: [PHP] Returning results

2010-10-21 Thread Jim Lucas
Daniel P. Brown wrote:
> On Wed, Oct 20, 2010 at 21:04, Bastien  wrote:
>> Yeah, it's got a few downsides!
> 
> The next app for the iPhone should be a modification to the
> spell-check to verify PHP functions in emails.
> 

+1

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



Re: [PHP] require_once

2010-10-19 Thread jim
 I am following an example. Also, doesn't that require the class name 
to be something like models_members?


Jim

On 10/19/2010 09:40 AM, chris h wrote:


 I'm having a problem including files using Zend Framework. I have
in a controller file this


Jim why not use the Zend autoloader?


Chris.




[PHP] require_once

2010-10-18 Thread jim
 I'm having a problem including files using Zend Framework. I have in a 
controller file this


require_once "models/Member.php"; and it doesn't work ,nor does

require_once "../models/Member.php";

Anyone know what's going on with this?

Jim W.



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



Re: [PHP] open .zip from memory...

2010-10-04 Thread Jim Lucas
Steve Staples wrote:
> Not sure if my subject is misleading or not, but anyway, here it goes...
> 
> I am trying to download a file using file_get_contents($url) which
> happens to be a .zip file.
> 
> I have no issues downloading the file, saving it to the harddrive,
> opening it, and getting what i need from it... but what I am trying to
> do, is not save it to disk, but to just grab the .zip file, and open it
> in memory, grab the file i need from it, and then discard the .zip file,
> and parse out the file i grabbed (this would prevent having a folder
> with R/W access that could possibly be set wrong, or using the /tmp
> folder)
> 
> Again, I dont have any issues doing it where i save it first, but when I
> try to use the file from memory, i get errors saying that it can't open
> the zip file becuase it has no valid resource id#.
> 
> The zip commands i am using, are the php ones zip_open, zip_read,
> zip_entry_read, zip_entry_name, zip_entry_filesize and obviously
> zip_close.
> 
> Can this be done, or should I just forget it, and use the /tmp dir?
> 
> Steve.
> 
> 
> 
> 

Might see if this page will glean you any information

http://us3.php.net/manual/en/wrappers.php.php

I think the php://temp or php://memory will work for you instead of a file on
the file system.

Jim

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



Re: [PHP] version_compare

2010-09-30 Thread Jim Lucas
Brian Smither wrote:
>> Personally, I would change that to be
>> if ( function_exists('filter_var') ) {
> 
> So would I:
> *But it's not my code.
> *I wish to learn and understand the cause of the problem - not walk around it.
> 
>> It means condition (PHP_VERSION >= 5.2.0)
> 
> I understand that. There was a second, more relevant, part to my question.
> 
> I have found the version of PHP used as reported in the HTTP header responses.
> 
> filter_var() is undefined in PHP/5.2.4_p20070914-pl2-gentoo
> 

As Paul pointed out, maybe your version of PHP was built without the filter_var
function compiled in.

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



Re: [PHP] version_compare

2010-09-30 Thread Jim Lucas
Brian Smither wrote:
> I found this code...
> if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
>  $text=filter_var($text, FILTER_SANITIZE_URL);
> }
> 
> ...to be questionable.
> 
> Under what conditions would version_compare() return true, yet the 
> filter_var() be undefined? Because that's what is happening.
> 
> Thank you.
> 
> 
> 
> 

Personally, I would change that to be

if ( function_exists('filter_var') ) {
$text = filter_var($text, FILTER_SANITIZE_URL);
}

Jim

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



<    2   3   4   5   6   7   8   9   10   11   >