[PHP] How do I use a Javascript variable in PHP?

2002-09-23 Thread Tom

Hi all,



I hope this is the right place to pose my question, so here goes: -



I have a javascript function called calcMonth() and given a number it will
return a date i.e. month = calcMonth( 57 )   -  month will be 'sept 2002'



The problem I`m having is at the beginning of my PHP file I`m calling this
calcMonth() then doing a load of php stuff and then trying to use the
javascript month variable, but to no avail: -



print "";



The result is, the browser displays the words 'javascript:month;' - not a
month number



I`ve looked everywhere for an answer from persistent javascript data to
using framesets to hold the variable but to no avail.



I know its quite a bit of javascript, but its mixed in  with PHP too so I
thought it`d be the right place.



Anyways, I hope someone can provide the answer to my problem.



Thanks in advance,

Tom




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




[PHP] How do i assign Integers only and not real numbers?

2002-09-23 Thread Tom

Hi all,

I have a line of code that assigns a new year number: -

$years = $years + ( $themonth / 12 );

but sometimes $years == 1998.08

or

$year == 2002.75

etc...

I cant find anything like a round() or floor() function in PHP so that year
would be 1998 or 2002 only.

Does anyone know what function would do this?  Sorry if I`m wasting your
time if its a really obvious one!

thanks in advance,
Tom



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




RE: [PHP] Randomizing 3 different numbers.

2003-10-27 Thread Tom
Just to give you something to chew on, try the code below.



It is slightly more generic, and you can change things a little
without having to modify a whole bunch of if() statements.

-Original Message-
From: Ian Gray [mailto:[EMAIL PROTECTED] 
Sent: 27 October 2003 12:26
To: [EMAIL PROTECTED]
Subject: [PHP] Randomizing 3 different numbers.

I am tring to output 3 different random numbers between 1
and 20 into 3 different strings.  Using Rand() for each
string isn't sufficient as I may get the same number
repeated for one of the other strings- eg 1,1,3 or 5,3,3 .
It's important that I get three different numbers outputted
into for example $one, $two, $three.

Can anyone help?

Ian

=

-
Ian A. Gray
Manchester, UK
Telephone: +44 (0) 161 224 1635 - Fax: +44 (0) 870 135 0061 - Mobile:
+44 (0) 7900 996 328
Business Enquiries:  +44(0)870 770 8832
E-mail: [EMAIL PROTECTED]: www.baritone.uk.com
(Performance) www.vocalstudio.co.uk   (Vocal
Tuition)www.selectperformers.com   (Web design for professional
musicians)
-

-- 
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] Best way to split a string of numbers into segments.

2003-12-02 Thread Tom
Hi.

Is there an easy, non expensive way to do the perl-equivalent of:
$date=20031202;
($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/;
I looked through the preg_* functions online, but couldn't see anything
to help me. Am I stuck with substr() :P ?
Thanks.

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


Re: [PHP] Best way to split a string of numbers into segments.

2003-12-02 Thread Tom
I agree that preg_match generates an array, but I cannot assign to it 
directly,
and in your example I have 4 elements in the array, not three.
Array
(
   [0] => 20031202
   [1] => 2003
   [2] => 12
   [3] => 02
)

I suppose something like
   preg_match("/(\d{4})(\d{2})(\d{2})/", $mydate, list($y,$m$d));
Is vaguely what I am gunning for.

And substr()...
$date  = 20031202;
$year  = substr($date,0,4);
$month = substr($date,3,2);
$day   = substr($date,5,2);
That seems like a lot of lines of code, and I am believe that substr() 
is expensive.

Maybe I have been doing too much perl, as it seems such a neat solution 
to me :P

preg_match should do it...

$mydate = "20031202";
$date = array();
preg_match("/(\d{4})(\d{2})(\d{2})/", $mydate, $date);
print_r($date);
substr would be much quicker though

On Tue, 2003-12-02 at 13:14, Tom wrote:
 

Hi.

Is there an easy, non expensive way to do the perl-equivalent of:
$date=20031202;
($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/;
I looked through the preg_* functions online, but couldn't see anything
to help me. Am I stuck with substr() :P ?
Thanks.
   

 

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


Re: [PHP] Best way to split a string of numbers into segments.

2003-12-02 Thread Tom
David Otton wrote:

On Tue, 02 Dec 2003 13:14:20 +, you wrote:
 

Is there an easy, non expensive way to do the perl-equivalent of:
$date=20031202;
($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/;
I looked through the preg_* functions online, but couldn't see anything
to help me. Am I stuck with substr() :P ?
   

list() springs to mind

list ($a, $b, $c) = preg_split (/* mumble mumble */);
 

Hi David.

Yes, list() was, initially, my starting point. But preg_split() will not 
allow me split with the
full /(\d{4})(\d{2})(\d{2})/ syntax (and assign the temp vars to thos in 
list().
Unless I missed something?

$date=20031202;
list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/);
> parse error, unexpected '/', expecting ')'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Non American strtotime

2004-01-16 Thread Tom
Is there a way I can force PHP's time functions not to read date strings
in the American MM-DD- format?
I am using strtotime and strftime and date at various points (mainlty to
avoid some niggly 0/NULL problems between PHP and mySQL
and datefields).
My date calculations (which are done in mySQL) are coming out with
screwy results: adding 6 months the 3rd July becomes 7th September.
("03/07/2004" reads as 7th March, add six months for 7th September
which is then displayed as "07/09/2003").
Is there a way I can have strtotime read "10-01-2004" (and all other such
date connotations) as the 10th Jan and not 1st Oct?
Thanks.

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


Re: [PHP] Non American strtotime

2004-01-16 Thread Tom
Ford, Mike [LSS] wrote:

On 16 January 2004 11:14, Tom wrote:
 

Is there a way I can force PHP's time functions not to read
date strings
in the American MM-DD- format?
   

[*snip*]

Is there a way I can have strtotime read "10-01-2004" (and
all other such
date connotations) as the 10th Jan and not 1st Oct?
   

No.  strtotime() only recognises the formats mm/dd/, -mm-dd and mmdd for numeric months; if you use a textual month, you can pretty much put the day, month and year in any order.

Your best bet is to rejig the date into one of the formats recognised before passing it to strtotime -- although, once you've split it into its constituent parts, you might just as well use mktime() to get your timestamp.

And if you just want to insert into mySQL, why not use the mySQL date format specifiers to specify the format of your incoming dates?  (Someone else can expound better on this, as I don't use mySQL.)
 

This will really stump me, and leads me to the conclusion that the only 
PHP solution is to write my own strtotime function, which is unlikely to 
be an acceptable answer.

The end user gets to chose their date format, and so if I cannot reverse 
their arbitrary date format into a timestamp then I have no chance of 
ensuring that dates are correct.

This seems like a really fundamentally bad thing about PHP :(

I don't suppose there are any PHP classes to hand that connect to mySQL 
and do all this?


Re: [PHP] Please help me as fast as possible.. very important!!

2004-01-20 Thread Tom
Radwan Aladdin wrote:

Hi all

Is it possible in mySQL to put a timer that changes a value inside a row in a table every while?

For example : Add "1" to the value very 10 minutes for example.. Field number = 5 after ten minutes = 6 after another 10 minuste = 7..Etc..

Is it possible?And how?

Regards..

 

I am not aware of any such functionality within MySQL.

However if you have a one-one relationship between a period of time and 
an incremental,
could you not simply INSERT a timestamp and then compare with times with 
NOW,
and then divide by your time period?

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


[PHP] Display who is onlin

2001-01-14 Thread TOM

Is it possible to find out who is logged in a site and display their name in
PHP?

--
best wishes,
enethk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Upgrade PHP3 to PHP4

2001-01-15 Thread TOM

I would like to upgrade PHP3 to PHP4 on my Turbo Linux, does anyone has
experience on this?

--
best wishes,
enethk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] configure for WDDX functions

2001-03-04 Thread Tom


I am getting the dreaded
"Call to undefined function: wddx_serialize_vars()"
from code that previously ran/now runs fine on 4.0.2pl1 (win32)

Here's what I have:

I am on an server farm that has 4.0.4pl1 installed (FreeBSD)

phpinfo shows XML enabled - but not 'additional modules' are shown (where 
WDDX module is typically shown as enabled by defult

the 'configuration directives' as seen in phpinfo have _no_ mention of WDDX

I do have control of the php.ini file 
-- I tried the "php_flag wddx on" approach in php.ini but it had no effect 
(in phpinfo() output either)

Any clues as to what I am missing?

Many thanks,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] unset()- newbie question

2001-05-20 Thread Tom

I can't seem to get unset() to work when I'm strying to delete an 
element from an array.

I have a select list that is populated by an array, and i need to 
be able to delete items from the list by deleting them from the 
array, but I don't know how.

I tried using unset($array['element']); but it doesn't work.
Does anyone know why?
Does anyone know of a way to use array_diff() to delete elements 
from an array?

Thanks,
Tom 




 
   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Pls Help with this newbie question

2001-05-21 Thread Tom

I can't seem to get unset() to work when I'm strying to delete an 
element from an array.

I have a select list that is populated by an array, and i need to 
be able to delete items from the list by deleting them from the 
array, but I don't know how.

I tried using unset($array['element']); but it doesn't work.
Does anyone know why?
Does anyone know of a way to use array_diff() to delete elements 
from an array?

Thanks,
Tom  




 
   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Array Problem

2001-05-22 Thread Tom

What is the best way to delete an element from an array?
I tried using unset(), and it didn't work.

Thanks in advance.



Tom Malone
Web Designer
HurstLinks Web Developmenthttp://www.hurstlinks.com/
Norfolk, VA  23510(757)623-9688 FAX 623-0433
PHP/MySQL - Ruby/Perl - HTML/Javascript


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] GD fonts and ImageLoadFont

2002-02-27 Thread Tom


Hello,

I've been trying to figure out how to properly convert a bdf font 
into a GD font for use with ImageLoadFont. The conversion goes 
without a problem, and I can load and use the font, but for some 
reason, all the characters look as though they have a space inserted 
between them. So, instead of the number "20", I get something that 
looks like "2 0". Instead of "Hello", I get something that looks like 
"H e l l o".

I've seen suggestions to use the php commands that use truetype 
instead of GD fonts, but we're working with a hosting company who 
does not have freetype installed (much less current versions of gdlib 
and php).

Is there something I can do to get the GD fonts to space properly?

Thanks,

Tom

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




[PHP] Hosting companies that offer PHP?

2002-02-27 Thread Tom


I think I might be about to discover that our hosting company neither 
supports the GD-related functions in php, nor has any plans to do so. 
Consequently, I may very well be looking for another hosting company, 
and I'd be interested in any recommendations from the php community 
at large, preferably of hosts that offer shell accounts.

Regards,

Tom

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




[PHP] Re: Hosts with PHP support

2002-03-03 Thread Tom

To all who responded: Thank You!

I realized something after I posted the message- I did a little 
research to clarify what I really need, and it boils down to this: I 
need a php installation that supports the GIF and JPEG-related 
functions (like ImageCreateFromGif), and it would also be nice if it 
offered Truetype support, so that I can use functions like 
ImageTTFText. I will check out the recommendations at this point.

Thanks very much.

Tom


>Datasnake.co.uk would be able to help you out
>
>Alastair
>
>>  -Original Message-
>>  From: Tom [mailto:[EMAIL PROTECTED]]
>>  Sent: 28 February 2002 04:57
>>  To: [EMAIL PROTECTED]
>>  Subject: [PHP] Hosting companies that offer PHP?
>>
>>
>>
>>  I think I might be about to discover that our hosting company neither
>>  supports the GD-related functions in php, nor has any plans to do so.
>>  Consequently, I may very well be looking for another hosting company,
>>  and I'd be interested in any recommendations from the php community
>>  at large, preferably of hosts that offer shell accounts.
>>
>>  Regards,
>>
>>  Tom
>>
>>  --
>>  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] Coding for email response forms

2009-01-26 Thread Tom
I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The 
following page has my form but the submit button is not working properly. 
http://www.richlandmtg.com/contacts.html
What code is needed and where does it get placed in the page.? I thought CS3 
took care of this.

Any input is greatly appreciated.
Tom

   

  Contact Form
 

  Have a Question?.
   Please include Name, Email address and a 
short message when replying. Your questions will be answered 
shortly.
  
 
 

Name:

E-mail:

Message:

clearsend
 
   
  



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom
My Hosting site said that I needed to include the PHP otherwise the form 
won't work. I need to know where to include my email info to get this set up 
don't I? What do you suggest?
T
"Daniel Brown"  wrote in message 
news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. 
>> The
>> following page has my form but the submit button is not working properly.
>> http://www.richlandmtg.com/contacts.html
>> What code is needed and where does it get placed in the page.? I thought 
>> CS3
>> took care of this.
>
>Tom,
>
>This issue has nothing at all to do with PHP.  This is all client
> side (JavaScript and HTML).
>
> -- 
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find 
> out! 



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Shawn McKenzie" <> wrote in message 
news:a0.87.62571.3d92e...@pb1.pair.com...
> Tom wrote:
>> My Hosting site said that I needed to include the PHP otherwise the form
>> won't work. I need to know where to include my email info to get this set 
>> up
>> don't I? What do you suggest?
>> T
>> "Daniel Brown"  wrote in message
>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the webpages.
>>>> The
>>>> following page has my form but the submit button is not working 
>>>> properly.
>>>> http://www.richlandmtg.com/contacts.html
>>>> What code is needed and where does it get placed in the page.? I 
>>>> thought
>>>> CS3
>>>> took care of this.
>>>Tom,
>>>
>>>This issue has nothing at all to do with PHP.  This is all client
>>> side (JavaScript and HTML).
>>>
>>> -- 
>>> 
>>> daniel.br...@parasane.net || danbr...@php.net
>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>> Unadvertised dedicated server deals, too low to print - email me to find
>>> out!
>>
>>
>
> What you have now is a form that when submitted sends the data to
> itself.  So you either need to include some php in this file to gather
> up the data and email it when submitted, or submit to another file that
> does that.
>
>
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com

Shawn,
So would that look something like this:





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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Daniel Brown"  wrote in message 
news:ab5568160901261347h1dab427bo29a1313494cd...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>>
>> Shawn,
>> So would that look something like this:
>> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>
>> // Just to be safe, I strip out HTML tags
>> $realname = strip_tags($realname);
>> $email = strip_tags($email);
>> $feedback = strip_tags($feedback);
>>
>> // set the variables
>> // replace $...@mysite.com with your email
>> $sendto = "$...@mysite.com";
>> $subject = "Sending Email Feedback From My Website";
>> $message = "$realname, $email\n\n$feedback";
>>
>> // send the email
>> mail($sendto, $subject, $message);
>>
>> }
>> ?>
>
>For processing once it reaches the server, yes - almost exactly.
> A few recommended changes though:
>
>* Change  different PHP configurations.
>* Change your if() to if($_POST['realname'])
>* DO NOT rely on register_globals - it's insecure and will
> soon be phased-out of PHP.  Instead, using your code:
>$realname = strip_tags($_POST['realname']);
>* Use explicit headers with mail().  For example:
>$headers  = "From: y...@example.com\r\n";
>$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
>mail($sendto,$subject,$message,$headers);
>* Do something (exit, header("Location: otherpage.html")
> redirect, etc.) so that the form doesn't reappear.
>
>Then, either include that code at the top of the file in which
> your HTML resides, or place it in it's own file (for example:
> formproc.php) and change your form tag to:
> id="formName">
>
>
>NB: My original responses that this wasn't PHP-related was based
> on your original message, saying that your "submit button" wasn't
> working, and then including HTML and JavaScript code only.  It didn't
> appear as though it had anything to do with PHP.  Getting a good
> answer is best-achieved by asking a well-formed question.
>
> -- 
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find 
> out!

Us newbies don't always phrase the questions right but you & Shawn answered 
my question. Just have to try it out now.
Thanks
T 



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Shawn McKenzie"  wrote in message 
news:497e3ab9.2060...@mckenzies.net...
>
>
> Shawn McKenzie wrote:
>>
>> Tom Scott wrote:
>>> - Original Message - From: "Shawn McKenzie"
>>> 
>>> Newsgroups: php.general
>>> To: 
>>> Sent: Monday, January 26, 2009 3:52 PM
>>> Subject: Re: [PHP] Coding for email response forms
>>>
>>>
>>>> Tom wrote:
>>>>> "Shawn McKenzie" <> wrote in message
>>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>>>>>> Tom wrote:
>>>>>>> My Hosting site said that I needed to include the PHP otherwise
>>>>>>> the form
>>>>>>> won't work. I need to know where to include my email info to get
>>>>>>> this set
>>>>>>> up
>>>>>>> don't I? What do you suggest?
>>>>>>> T
>>>>>>> "Daniel Brown"  wrote in message
>>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com...
>>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>>>>>>>>> webpages.
>>>>>>>>> The
>>>>>>>>> following page has my form but the submit button is not working
>>>>>>>>> properly.
>>>>>>>>> http://www.richlandmtg.com/contacts.html
>>>>>>>>> What code is needed and where does it get placed in the page.? I
>>>>>>>>> thought
>>>>>>>>> CS3
>>>>>>>>> took care of this.
>>>>>>>>Tom,
>>>>>>>>
>>>>>>>>This issue has nothing at all to do with PHP.  This is all 
>>>>>>>> client
>>>>>>>> side (JavaScript and HTML).
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> 
>>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>>>>>>>> to find
>>>>>>>> out!
>>>>>> What you have now is a form that when submitted sends the data to
>>>>>> itself.  So you either need to include some php in this file to 
>>>>>> gather
>>>>>> up the data and email it when submitted, or submit to another file
>>>>>> that
>>>>>> does that.
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Thanks!
>>>>>> -Shawn
>>>>>> http://www.spidean.com
>>>>> Shawn,
>>>>> So would that look something like this:
>>>>> >>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>>>
>>>>> // Just to be safe, I strip out HTML tags
>>>>> $realname = strip_tags($realname);
>>>>> $email = strip_tags($email);
>>>>> $feedback = strip_tags($feedback);
>>>>>
>>>>> // set the variables
>>>>> // replace $...@mysite.com with your email
>>>>> $sendto = "$...@mysite.com";
>>>>> $subject = "Sending Email Feedback From My Website";
>>>>> $message = "$realname, $email\n\n$feedback";
>>>>>
>>>>> // send the email
>>>>> mail($sendto, $subject, $message);
>>>>>
>>>>> }
>>>>> ?>
>>>>>
>>>>>
>>>>>
>>>> Oh, you should also think about some other things, such as validation.
>>>> Is realname only alpha characters?  Is email in the form of a real 
>>>> email
>>>> address?  At a bare minimum, are they not empty:
>>>>
>>>> if (empty($_POST['email']) ||
>>>> empty($_POST['realname']) ||
>>>> empty($_POST['feedback']))
>>>> {
>>>>echo 'You must complete all required fields!';
>>>> // show form again
>>>> }
>>>>
>>>>
>>>> -- 
>>>> Thanks!
>>>> -Shawn
>>>> http://www.spidean.com
>>> Ok. I have the validation part.
>>> http://www.richlandmtg.com/index-5.html still working on the Send 
>>> button.
>>>
>>> T
>>>
>>>
>> Please reply all so this stays on the list.
>>
>> 1.  In the source for your link I see that the JS is doing some 
>> validation.
>> 2.  You have method="get" in your form.  This will work, but you'll have
>> to change the PHP code to use $_GET instead of $_POST vars.  Or change
>> to method="post" in the form.
>> 3.  If you want to keep the .html extension for the page, then you'll
>> probably need to send the post to another script with a .php extension.
>> Normally a file with a .html extension won't execute the PHP code.
>>
>> Thanks!
>> -Shawn
>>
>>
>>
I was just looking at that. Someone told me to use GET instead of POST. 
Since JS is validating is it as easy replacing GET with POST ? Nothing else 
needed? Is it better to remove the JS and just code using PHP as you showed 
before?
if (empty($_POST['email']) ||
empty($_POST['realname']) ||
empty($_POST['feedback']))

Thanks,
Tom



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



Re: [PHP] Coding for email response forms

2009-01-26 Thread Tom

"Eric Butera"  wrote in message 
news:6a8639eb0901261509s1008e1b1j89c2a8f63669e...@mail.gmail.com...
> On Mon, Jan 26, 2009 at 4:47 PM, Daniel Brown  wrote:
>> On Mon, Jan 26, 2009 at 16:34, Tom  wrote:
>>>
>>> Shawn,
>>> So would that look something like this:
>>> >> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>>>
>>> // Just to be safe, I strip out HTML tags
>>> $realname = strip_tags($realname);
>>> $email = strip_tags($email);
>>> $feedback = strip_tags($feedback);
>>>
>>> // set the variables
>>> // replace $...@mysite.com with your email
>>> $sendto = "$...@mysite.com";
>>> $subject = "Sending Email Feedback From My Website";
>>> $message = "$realname, $email\n\n$feedback";
>>>
>>> // send the email
>>> mail($sendto, $subject, $message);
>>>
>>> }
>>> ?>
>>
>>For processing once it reaches the server, yes - almost exactly.
>> A few recommended changes though:
>>
>>* Change > different PHP configurations.
>>* Change your if() to if($_POST['realname'])
>>* DO NOT rely on register_globals - it's insecure and will
>> soon be phased-out of PHP.  Instead, using your code:
>>$realname = strip_tags($_POST['realname']);
>>* Use explicit headers with mail().  For example:
>>$headers  = "From: y...@example.com\r\n";
>>$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
>>mail($sendto,$subject,$message,$headers);
>>* Do something (exit, header("Location: otherpage.html")
>> redirect, etc.) so that the form doesn't reappear.
>>
>>Then, either include that code at the top of the file in which
>> your HTML resides, or place it in it's own file (for example:
>> formproc.php) and change your form tag to:
>>> id="formName">
>>
>>
>>NB: My original responses that this wasn't PHP-related was based
>> on your original message, saying that your "submit button" wasn't
>> working, and then including HTML and JavaScript code only.  It didn't
>> appear as though it had anything to do with PHP.  Getting a good
>> answer is best-achieved by asking a well-formed question.
>>
>> --
>> 
>> daniel.br...@parasane.net || danbr...@php.net
>> http://www.parasane.net/ || http://www.pilotpig.net/
>> Unadvertised dedicated server deals, too low to print - email me to find 
>> out!
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Also make sure there aren't line returns or any nonsense like that in
> the to & subjects.  Look up email header injection.  Your script might
> become quite popular at advertising p3n1s pills otherwise. :)

Thanks I'll check it out. I tried including the above code but I still can't 
seem to get it to work. Must be missing something.

Thanks,
T 



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



Re: [PHP] Coding for email response forms

2009-01-27 Thread Tom

"Edmund Hertle"  wrote in message 
news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com...
> 2009/1/26 Tom 
>
>>
>> "Shawn McKenzie"  wrote in message
>> news:497e3ab9.2060...@mckenzies.net...
>> >
>> >
>> > Shawn McKenzie wrote:
>> >>
>> >> Tom Scott wrote:
>> >>> - Original Message - From: "Shawn McKenzie"
>> >>> 
>> >>> Newsgroups: php.general
>> >>> To: 
>> >>> Sent: Monday, January 26, 2009 3:52 PM
>> >>> Subject: Re: [PHP] Coding for email response forms
>> >>>
>> >>>
>> >>>> Tom wrote:
>> >>>>> "Shawn McKenzie" <> wrote in message
>> >>>>> news:a0.87.62571.3d92e...@pb1.pair.com...
>> >>>>>> Tom wrote:
>> >>>>>>> My Hosting site said that I needed to include the PHP otherwise
>> >>>>>>> the form
>> >>>>>>> won't work. I need to know where to include my email info to get
>> >>>>>>> this set
>> >>>>>>> up
>> >>>>>>> don't I? What do you suggest?
>> >>>>>>> T
>> >>>>>>> "Daniel Brown"  wrote in message
>> >>>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com.
>> ..
>> >>>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom  wrote:
>> >>>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the
>> >>>>>>>>> webpages.
>> >>>>>>>>> The
>> >>>>>>>>> following page has my form but the submit button is not working
>> >>>>>>>>> properly.
>> >>>>>>>>> http://www.richlandmtg.com/contacts.html
>> >>>>>>>>> What code is needed and where does it get placed in the page.? 
>> >>>>>>>>> I
>> >>>>>>>>> thought
>> >>>>>>>>> CS3
>> >>>>>>>>> took care of this.
>> >>>>>>>>Tom,
>> >>>>>>>>
>> >>>>>>>>This issue has nothing at all to do with PHP.  This is all
>> >>>>>>>> client
>> >>>>>>>> side (JavaScript and HTML).
>> >>>>>>>>
>> >>>>>>>> --
>> >>>>>>>> 
>> >>>>>>>> daniel.br...@parasane.net || danbr...@php.net
>> >>>>>>>> http://www.parasane.net/ || http://www.pilotpig.net/
>> >>>>>>>> Unadvertised dedicated server deals, too low to print - email me
>> >>>>>>>> to find
>> >>>>>>>> out!
>> >>>>>> What you have now is a form that when submitted sends the data to
>> >>>>>> itself.  So you either need to include some php in this file to
>> >>>>>> gather
>> >>>>>> up the data and email it when submitted, or submit to another file
>> >>>>>> that
>> >>>>>> does that.
>> >>>>>>
>> >>>>>>
>> >>>>>> --
>> >>>>>> Thanks!
>> >>>>>> -Shawn
>> >>>>>> http://www.spidean.com
>> >>>>> Shawn,
>> >>>>> So would that look something like this:
>> >>>>> > >>>>> if ($_SERVER['REQUEST_METHOD'] == "POST") {
>> >>>>>
>> >>>>> // Just to be safe, I strip out HTML tags
>> >>>>> $realname = strip_tags($realname);
>> >>>>> $email = strip_tags($email);
>> >>>>> $feedback = strip_tags($feedback);
>> >>>>>
>> >>>>> // set the variables
>> >>>>> // replace $...@mysite.com with your email
>> >>>>> $sendto = "$...@mysite.com";
>> >>>>> $subject = "Sending Email Feedback From My Website";
>> >>>>> $message = "$realname, $email\n\n$feedback";
>> >>>>>
>> >>>>> // send the email
>

Re: [PHP] Coding for email response forms

2009-01-28 Thread Tom
"Clancy"  wrote in message 
news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>
> ..
>>>
>>> Also make sure there aren't line returns or any nonsense like that in
>>> the to & subjects.  Look up email header injection.  Your script might
>>> become quite popular at advertising p3n1s pills otherwise. :)
>>
>>Thanks I'll check it out. I tried including the above code but I still 
>>can't
>>seem to get it to work. Must be missing something.
>>
>>Thanks,
>
> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very 
> clear  instructions
> on installing PHP and implementing the essential items such as this.
>
Thanks I'll check it out.

 I am no Coder and don't have a lot of time to devote to these things, to 
busy running a business, but I do enjoy learning how things work which is 
why I have taken this on. Website is just for informational display as they 
don't produce much in the way of mortgage originations. I was hoping to get 
something along the lines of the actually coding needed to pull this off. I 
have spent every available moment over the last three  months on this 
website (which is my first) with nothing more than an online beginners 
course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone has 
coding I can cut and paste with just a few adjustments on my end that would 
be great.

Thanks,
Tom 



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



Re: [PHP] Coding for email response forms

2009-01-30 Thread Tom

"Shawn McKenzie"  wrote in message 
news:47.36.08436.e8b80...@pb1.pair.com...
> Tom wrote:
>> "Clancy"  wrote in message
>> news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
>>> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>>>
>>> ..
>>>>> Also make sure there aren't line returns or any nonsense like that in
>>>>> the to & subjects.  Look up email header injection.  Your script might
>>>>> become quite popular at advertising p3n1s pills otherwise. :)
>>>> Thanks I'll check it out. I tried including the above code but I still
>>>> can't
>>>> seem to get it to work. Must be missing something.
>>>>
>>>> Thanks,
>>> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very
>>> clear  instructions
>>> on installing PHP and implementing the essential items such as this.
>>>
>> Thanks I'll check it out.
>>
>>  I am no Coder and don't have a lot of time to devote to these things, to
>> busy running a business, but I do enjoy learning how things work which is
>> why I have taken this on. Website is just for informational display as 
>> they
>> don't produce much in the way of mortgage originations. I was hoping to 
>> get
>> something along the lines of the actually coding needed to pull this off. 
>> I
>> have spent every available moment over the last three  months on this
>> website (which is my first) with nothing more than an online beginners
>> course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone 
>> has
>> coding I can cut and paste with just a few adjustments on my end that 
>> would
>> be great.
>>
>> Thanks,
>> Tom
>>
>>
> You have the code.  You just need to create a contact.php file and put
> the email specific PHP in it and then modify your form to have
> method="post" action="contact.php".
>
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com

The following link shows my PHP configurations.
http://www.richlandmtg.com/test.php Are there any that should be set 
differently? I noticed the system is Linux.

T 



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



Re: [PHP] time

2007-01-29 Thread tom

test
Jay Blanchard :

[snip]
I am writing a program for managing leads and contacts. I would like to
add
the ability to see what TIME it is where the contact is not there server
time. So if you looked at a list of contacts from all over the country
you
would see different times compared to what time it is where the user is
at.
What should I be looking at to calculate out the different time zones.
Could
somebody just point me in the write direction at this time I have no
idea on
how to proceeded.
[/snip]

You would use JavaScript to capture their local 'browser' time and
process it with PHP


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



[PHP] Re: Parsing mail file

2007-02-01 Thread tom

Easy!!
Pierre Pintaric :

Hello there,

I'm sure this question was ask 1,000 times, but I didn't find any 
archive about this, that's why I need help...


Here is my problem:
I receive mail file from my MTA (ie QMail), that works fine. Now, I 
would to find a class or a function that parse the mail and gives 
headers informations, body of the mail (even if it is a multi-part mail) 
and file attachments.

I found nothing in PEAR library, nothing on the web, ...

I don't what want to rebuild the wheel if somebody works on it and made 
a good job...
If somebody uses a great function and want to share, I will please 
him... :-)


Thanks for your help.

Pierre


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



[PHP] XSLTProcessor issue

2010-03-21 Thread Tom
I have located what appears to me to be bug in the XSLTProcessor in
PHP5.2.13 but want to insure that I am not overlooking something before
reporting it. Any advice will be appreciated.

The issue is apparent discrepancies in output sort order in an XSLTProcessor
generated list. Following is a detailed description.

Scenario: Disk resident xml file with a top level "Places" element and a
list of subordinate "Place" elements. Each "Place" element has a "fullName"
attribute with self explanatory value. Place heirarchy is indicated by comma
separated fields in the attribute value, e.g. Accomac Co., Virginia, USA.
Also, a disk resident xsl file whose purpose is to transform the xml file
into a html file with the "Place" element collection sorted and rewritten as
a list of full place names. When the xsl translation is invoked by assigning
the xsl to the xml file and accessing the xml file in IE8, the displayed
output appears exactly as expected, e.g.

Accomack Co., VA, USA
Adams Co., PA, USA
Ahoskie Twp., Hertford Co., NC, USA
Ahoskie, Hertford Co., NC, USA
AK, USA
AL, USA
Alachua Co., FL, USA
Alamance Co., NC, USA
Alameda Co., CA, USA
Alameda, Alameda Co., CA, USA

However, when invoked via the following php script, using PHP5.2.13 -

$xml = new DOMDocument();
$xml->load("F:\Places.xml");
$xsl = new DOMDocument();
$xsl->load("F:\Places.xsl");
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl);
echo $xslt1->transformToXML($xml);

some sort order discrepancies appear in the output, e.g.

AK, USA
AL, USA
Accomack Co., VA, USA
Adams Co., PA, USA
Ahoskie Twp., Hertford Co., NC, USA
Ahoskie, Hertford Co., NC, USA
Alachua Co., FL, USA
Alamance Co., NC, USA
Alameda Co., CA, USA
Alameda, Alameda Co., CA, USA

Note that the state records, which have upper case second character,
incorrectly appear ahead of other places. This behavior appears even if the
"case-order='lower-first'" attribute is included in the  element
in the xsl stylesheet.

Question: Is this a bug or am I overlooking something? 



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



Re: AW: [PHP] export mysql to csv prob

2005-02-11 Thread Tom
If your mysql server has access (or can have access) to the directory 
where you want to dump the file, you can just use the "SELECT INTO 
OUTFILE FIELDS TERMINATED BY ','..." syntax as your query, which is very 
fast.

Mirco Blitz wrote:
Hi, 
Probably the Pear Excel_Syltesheet_Writer works for you.
http://pear.php.net/package/Spreadsheet_Excel_Writer

I found out that it is faster with huge data sets on my system.
Greetings
Mirco
-Ursprüngliche Nachricht-
Von: Redmond Militante [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 11. Februar 2005 00:02
An: php-general@lists.php.net
Betreff: [PHP] export mysql to csv prob

hi
i have a script that exports the result of a mysql query to a csv file
suitable for downloading
the code looks like
$result = mysql_query("select * from user,mjp1,mjp2,mjp3,mjp4");
while($row = mysql_fetch_array($result)) { 
$csv_output .= "$row[userid] $row[firstname] $row[lastname]\n" }

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".xls");  print
$csv_output;
this works fine, except that when i expand the line $csv_output
.="$row[userid] $row[firstname] $row[lastname] $row[anotherfield]
$row[anotherfield] ...\n"} -to include an increasing number of fields, it
tends to bog down the speed at which the $csv_output file can be printed.
when i have this line output 30+ fields for each row, wait time for output
file generation is almost 4-5 minutes.
is this the most efficient way to do this?  i'd like to be able to generate
the file as quickly as possible.
thanks
redmond
--
Redmond Militante
Software Engineer / Medill School of Journalism FreeBSD 5.2.1-RELEASE-p10
#0: Wed Sep 29 17:17:49 CDT 2004 i386  4:45PM  up  4:01, 3 users, load
averages: 0.00, 0.00, 0.00
 

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


[PHP] Implementing compulsory fields in a mySQL driven, SMARTY templated site?

2004-04-22 Thread Tom
Hello.

As per the subject: I am using PHP, mySQL and Smarty for
a web site with lots of forms everywhere. The site is
split into display, content and logic. And I want to
introduce the concept of mandatory fields.
Manually editing all the content files to mark the
mandatory fields and matching them 'manually' in the
logic scripts is one solution, but I am racking my
brains to move more towards a way of a full management
suite - being able to set the mandatory fields on a
page on the site in the site itself.
I appreciate that the first solution is much more
realistic than the latter, but a sensible, middle-
ground solution is still evading me.
Has anyone got any ideas, suggestion, solutions or
handy links to forums that have tackled this problem?
Thanks much :)

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


[PHP] Upgrading SAPI from 4.2.2 to 4.3.6 on RH9 with Apache 2

2004-05-10 Thread Tom
Hi.

I'm trying to upgrade a server (up2date RedHat9) - which is running 
Apache 2 (default!) and PHP 4.2.2 - to PHP 4.3.6. It is the SAPI version 
(running as an Apache module).

I have downloaded the tar.gz, exploded that and run
./configure --disable-cgi --with-apxs2=/var/share/Apache/apxs.pl
However it errors with apxs:Error: 
/home/httpd-win32-msi/apache-1.3.20/httpd not found or not executable

So it seems I have completely the wrong version! I don't seem to be able 
to find apxs.pl for Apache 2 on linux (RH9).

Could anyone point me in the right direction and possibly warn of me of 
the upcoming problems I am bound to face? :)

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


Re: [PHP] WHERE clause...getting closer

2004-05-05 Thread Tom
Ray Hunter wrote:
On Tue, 2004-05-04 at 19:18, msa wrote:
$query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' .
YEAR('NOW'()) . ' AND MONTH(datePublished) = ' . MONTH('NOW'()) . ' ORDER BY
sortBy DESC';
this is supposed to return only the records that have the current month and
year in the datePublished record.
got this error:
Fatal error: Call to undefined function: year()

You sure you did not mean $dataPublished?
I think datePublished is his columnName?
But also:
Assuming mySQL (I can't find your original post?):
+++This is all wrong:
mysql> SELECT YEAR('NOW'());
ERROR 1064: You have an error in your SQL syntax.  Check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near '())' at line 1

+++This is even worse, really:
mysql> SELECT YEAR('NOW()');
+---+
| YEAR('NOW()') |
+---+
|  NULL |
+---+
1 row in set (0.00 sec)
+++This is what you want:
mysql> SELECT YEAR(NOW());
+-+
| YEAR(NOW()) |
+-+
|2004 |
+-+
1 row in set (0.00 sec)

So I'd guess at your syntax being:
$query_rsENews = <<<_SQL
SELECT *
  FROM NewsArchive
 WHERE YEAR(datePublished)  = YEAR(NOW())
   AND MONTH(datePublished) = MONTH(NOW())
 ORDER BY sortBy DESC
_SQL;
HTH
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Client does not support authentication protocol...

2007-05-28 Thread Tom
Hi, as always, I'm trying to connect to a MySQL database in the following 
way:

mysql_connect('host','user','password');

In my local PC this Works perfectly, but in the server I receipt the 
following error:

mysql_connect(): Client does not support authentication protocol requested 
by server; consider upgrading MySQL client

Which can the cause of this error be?
Am I able to make something to solve it or does a problem belong exclusively 
to the administrator of the server?

Thank you very much,

Tom. 

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



[PHP] The data get lost when click back button

2007-06-16 Thread Tom
My problem:

I have a form for that the users register indicating a user's name and 
password and other data.
Previously to add the user in the data base I verify that user's name 
doesn't already exist. In that case I show an error message and I ask him to 
attempt it again.
But,  when the user returns to the form all the data of the fields 
disappeared! Then the user has enter all the information again.

How can I make in simple way that, the data in the fields don't get lost 
when the user returning to the form?

Ahead of time, thank you very much,

Tom.

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



[PHP] problem using imagejpeg function all

2006-11-21 Thread Tom
Hello,

I’m trying to use the imagejpeg function call in a php script and I
can’t quite seem to get it working properly.

 

Here is my gd dump.

 

  'GD Version' => 'bundled (2.0.28 compatible)' (length=27)
  'FreeType Support' => true
  'FreeType Linkage' => 'with freetype' (length=13)
  'T1Lib Support' => false
  'GIF Read Support' => true
  'GIF Create Support' => true
  'JPG Support' => true
  'PNG Support' => true
  'WBMP Support' => true
  'XPM Support' => false
  'XBM Support' => true
  'JIS-mapped Japanese Font Support' => false

 

 

Would I need to have T1Lib support in order for this it work?

 

As a quick example, here is some code I’ve been playing around with that I
found somewhere.

 



 

Should make a red square.

 

Any help would be greatly appreciated. Thank you.

 

Tom

 


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.14.11/543 - Release Date: 20/11/2006
9:20 PM
 


RE: [PHP] problem using imagejpeg function all

2006-11-21 Thread Tom
Can you show me what your gd dump looks like?




Is that way I got mine.

Also, what php version are you using? I'm using 5.1.6.

Thanks for the info.

Tom


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: November 21, 2006 11:40 PM
To: Tom
Cc: php-general@lists.php.net
Subject: Re: [PHP] problem using imagejpeg function all

On Tue, 2006-11-21 at 23:31 -0500, Tom wrote:
>   $image = imagecreate(200, 200);
>  $colorRed = imagecolorallocate($image, 255, 0, 0);
>  imagefill($image, 0, 0, $colorRed);
> 
>  //send image
>  //header("Content-type: image/jpeg");
>  imagejpeg($image);
> 
> ?> 

Works for me with the header line uncommented.

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

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.14.11/543 - Release Date: 20/11/2006
9:20 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.14.11/543 - Release Date: 20/11/2006
9:20 PM
 

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



[PHP] Using linkDisplayFields of FormBuilder

2006-04-25 Thread Tom

Hello all,

I've successfully generated my DataObjects for my database and have a 
set of objects that extend these generated classes so that my logic is 
separate from the generated code (so that any slight schema changes 
won't overwrite my code).


My question concerns using FormBuilder to change the displayfield for a 
linked dataobject.  For example, I have table1 and table2.  table1 is 
extended by table1extended class.  I create a do from this extended 
class and pass that to formbuilder.  table1 has a link to table2, but 
I'd like to make table2 use a different field when being displayed by 
the form generated for table1 *without having to place the 
fb_linkDisplayField variable into the generated do for table2*.  I'd 
prefer to keep that out of the do.  Putting it in the extendedtable2 
class is alright, but how do I make formbuilder see that class instead 
of the base do that is generated?  Even better, I'd like to be able to 
effect the way table2 is displayed in a form(s) generated from table1 
from the page that is creating that form.  (Page one with a form 
displays table2's name field, while page two with a form displays one of 
table2's other fields).


This may fall more into how to structure my application.  I want to 
separate the generated do code from my 'business logic' and separate the 
form/display details from the business logic.


Any help/advice is greatly appreciated.

Thanks,
Tom

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



Re: [PHP] Using linkDisplayFields of FormBuilder

2006-04-25 Thread Tom
I've mailed this list per the instructions on the pear.php.net site.  I 
first thought to email the lead maintainer (Justin Patrin) for the 
DB_DataObject_FormBuilder package 
(http://pear.php.net/package/DB_DataObject_FormBuilder)


but the email form page gave these instructions:

"Do not send email to this developer if you are in need of support for 
any of his/her package(s), instead we recommend emailing 
[EMAIL PROTECTED] where you are more likely to get answer.
You can subscribe to the pear-general mailinglist from the Support - 
Mailinglist page."



That's what I've done.  Also, searching the list archive turned up some 
questions from users and answers from the package's lead maintainer 
(http://beeblex.com/lists/index.php/php.pear.general/20823?s=formbuilder+%3Aphp.pear.general), 
so I thought this was appropriate, on top of respecting the explicit 
instructions of the site, Justin Patrin's inbox and the idea that 
submitting to the mailinglist will allow others to see 
questions/solutions and contribute/benefit.


Other than contacting the developer directly (which, again, seems to be 
discouraged), and search engines, (google didn't turn up anything 
specific to this concern), does anyone have other specific resources 
regarding FormBuilder?


Tom




Richard Lynch wrote:

On Tue, April 25, 2006 4:26 pm, Tom wrote:

I've successfully generated my DataObjects for my database and have a
...
My question concerns using FormBuilder to change the displayfield for


Of the 3000+ people on this list devoted to *GENERAL* PHP Topics,
let's be generous and assume about 300 of them actually USE
FormBuilder and DataObjects.

Of them, maybe 30 have enough experience to actually have SOME CLUE
what you are asking and why.

Of that, maybe 1 is going to manage to read the message in time to do
you any good.

That is why you probably should have first asked this question in a
forum devoted to FormBuilder and/or DataObjects, whatever those are,
where ALL the readers actually care about FormBuilder and
DataObjects...

YMMV



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



[PHP] Session variables on Windows

2006-06-05 Thread Tom
Does some well-known problem exist with the session variables in Windows 
servers?
Because in a system that I have running on a Windows server, sometimes the 
session variables are null causing errors, then I close the browser and open 
it and in the next intent everything works well... I can't understand why...
The same system in a Linux server runs well always ¿?

Ahead of time, thank you very much,

Tom. 

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



[PHP] php File upload

2008-08-06 Thread Tom
Hi,

on a linux system (Suese 10.2) with 1 GB memory its not possible to upload 
via http a  1 Gb File. Thats no limit problem  on my php config. i can look 
the mem stats when uploading and the growing tmp file. If the temp file has 
900 MB, Main Memory free is 0 and the script aborts and php deletes the tmp 
file.

Why don't php use swap memory ?

Greets Tom 



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
No, ist'not a php limit.  The upload is written in main memory, if i look 
with vmstat, free is going to 0 and the php upload breaks at 0 bytes free. 
Nothing swap used. Any other ideas?

"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> Hi,
>
> on a linux system (Suese 10.2) with 1 GB memory its not possible to
> upload via http a  1 Gb File. Thats no limit problem  on my php
> config. i can look the mem stats when uploading and the growing tmp
> file. If the temp file has 900 MB, Main Memory free is 0 and the
> script aborts and php deletes the tmp file.
>
> Why don't php use swap memory ?

It doesn't need to - as you've noticed, the uploaded file is being
written to disk, it's not being kept in memory.

This sounds like a php limit problem to me.


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
No Apache limit, enough diskspace, no permission problem.
Fact is: During upload looking at main memory, goes to 0 and if 0 uploadet 
tmp File was deleted and no error occur.

It was great, if anybody can test such a upload. The uploaded File musst be 
greater as main memory. While teh uload is running, take a look at memory 
with vmstat. free is goin to 0, no swap is used. I don't know, that is a 
suse 10.2 effcet only.



"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> No, ist'not a php limit.  The upload is written in main memory, if i
> look with vmstat, free is going to 0 and the php upload breaks at 0
> bytes free. Nothing swap used. Any other ideas?
>

Interesting problem - maybe an apache limit?  Lack of diskspace?
Permissions? Which error do you get?


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
smaller files is no problem. The error occoured, if the uploaded File is 
bigger than the installed  main memory.
Ok, i know that http ist not designed for big uploads. But on a big website 
with upload enabled and 30 users upload simultan a 20 MB File, they lost the 
upload while php hold all in memory/Cache and swap is not used. I  don't 
understand why php write the upload chunck for chunck (i can look this)  in 
upload temp file AND holds the upload in main memory.



""Richard Heyes"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
>> No Apache limit, enough diskspace, no permission problem.
>> Fact is: During upload looking at main memory, goes to 0 and if 0 
>> uploadet
>> tmp File was deleted and no error occur.
>>
>> It was great, if anybody can test such a upload. The uploaded File musst 
>> be
>> greater as main memory. While teh uload is running, take a look at memory
>> with vmstat. free is goin to 0, no swap is used. I don't know, that is a
>> suse 10.2 effcet only.
>
> What happens with a smaller file? Say 500Mb? You could gradually
> increase the file size until you get the error.
>
> -- 
> Richard Heyes
> http://www.phpguru.org 



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
hmm, memory buying is okay, not the final solution. I think php design fault 
on this function.  It's not comprehensible why php use such a lot main 
memory for an upload.



""Richard Heyes"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> Well, you lost me right about... Well when you started. But memory is
> cheap...:-/
>
> -- 
> Richard Heyes
> http://www.phpguru.org 



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
With what linux BS have you tested?
No, it isn't the apaches job/problem.
I do nothing with the file. Looking for $_FILES Varables and then 
move_uploaded_file.

But i said it before, the problem is not at this point.
If i upload the file and watch memory with vmstat, free is going 0, cache is 
going to top and if free is 0 => temp file was deleted and script witout an 
error comes back. At the crash point, the File is not complete  uploaded, so 
my $_FILES  have no entry about the file specs.

Im hanging some days with many tests on differnet machines (alls suse) on 
this Problem and can't solve it :-(


"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> hmm, memory buying is okay, not the final solution. I think php design
> fault on this function.  It's not comprehensible why php use such a
> lot main memory for an upload.

Well, PHP doesn't - the upload is apaches job. Once the file is
uploaded, PHP is invoked to process it.  You do your
move_uploaded_file() etc.  What do you do to the uploaded file?


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
>Ah, so it's not PHP and it's not apache using up your memory - it's your
>filesystem cache.  Check how many files you have in the tmp directory
>and the destination directory.

Okay, thats light in the darkness. But i don't have any idea what i can do 
here. tmp is empty.

Look at the first entry, its after the upload start. The last entry is after 
free = 0 and break. I really have no idea whats going on here.
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 677076  28020 216052001758  370  166  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 1  0  0 667404  28028 225536001758  371  167  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  1  0 660088  28036 231456001760  371  168  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  1  0 656616  28040 235820001760  372  168  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 653640  28052 239364001760  372  168  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 650044  28056 242948001760  372  168  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 1  0  0 642480  28060 250432001760  372  169  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 635536  28068 257244001760  373  170  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 1  0  0 630080  28072 262440001760  373  170  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 624500  28080 267892001760  374  170  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  2  0 620532  28080 270440001762  374  171  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  2  0 620904  28080 270440001762  374  171  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 2  0  0 618672  28092 273756001762  374  171  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 613960  28096 278432001762  374  171  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  2  0 114984  28668 768276001788  406  209  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0 105932  28684 778608001788  407  210  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us sy id 
wa
 0  0  0  96756  28692 787448001788  407  211  1  0 98 
1
linuxserver:/tmp # vmstat
procs ---memory-- ---swap-- -io -system-- cpu
 r  b   swpd   free   buff  cache   si   sobibo   in   cs us

Re: [PHP] php File upload

2008-08-07 Thread Tom
i use ext3
Im realy on no limit. destination ist /tmp and is  fairly empty.
The question is now, if cache full => must hypothetical swap used?
ok, im glad to see your result.



"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

>>Ah, so it's not PHP and it's not apache using up your memory - it's
>>your
>>filesystem cache.  Check how many files you have in the tmp directory
>>and the destination directory.
>
> Okay, thats light in the darkness. But i don't have any idea what i
> can do here. tmp is empty.
>

What about the destination directory?  Which filesystem are you using?

I'll try the 1Gb upload again and see how vmstat reacts.


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-07 Thread Tom
Hi Per,

your result is on a suse 8.2 ?
hmm, i don't know the reason why my suse 10.2 machines do that failure.
My limits for for post_max_size and upload_max_size is both 1500M.

Greets & thanx, Tom



"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> i use ext3
> Im realy on no limit. destination ist /tmp and is  fairly empty.
> The question is now, if cache full => must hypothetical swap used?
> ok, im glad to see your result.

No, high utilization of file system cache will not cause any swapping -
file system caching uses whatever is spare.  If there's nothing, no
caching.  AFAIU.

I can confirm what you're seeing about the cache being used up - I
saw that too.  My cache-number only went to about 485000, and free only
down to 6000-7000.  My webserver also has 1Gb RAM, but it does a few
more things.

Does your free memory actually go as low as 0?  I don't think this is
about the file system cache - I know you said no limits, but what do
you have for post_max_size and upload_max_size ?  I'm using 1200M for
both for this test.


/Per Jessen, Zürich



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



[PHP] Re: php File upload

2008-08-08 Thread Tom
Problem solved (at one machine)!

I can upload  a ~ 2 GB File now on a machine with 1 GB Main Memory! No 
Problem, swap is used but no break now.
The answer is, i think, the dramatical overhead for http upload, simply my 
post_max_size and upload_max_size are to small. If i will upload 1 GB it 
must minimum 1.5 GB (better more) on this limit variables.
Im very glad to fix this problem, but the next one is here: Other machine 
(but 2 GB Ram), same suse version, same (working now)  php.ini with limits 
to 5000M now and i can't upload a File greater than 900MB.
A file under 900MB i see the tmp file growing. A File with +1 GB no temp 
file seeing at all and break after a view minutes. It's horrible with no 
error codes and wasting pure of time :-(
Now i begin at bottom on this machine.

Thanx for alle, who look for this problem.
Now we are the very only that can say that php 100% working file uploads if 
memory lower than the file size :-)




""Tom"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> Hi,
>
> on a linux system (Suese 10.2) with 1 GB memory its not possible to upload 
> via http a  1 Gb File. Thats no limit problem  on my php config. i can 
> look the mem stats when uploading and the growing tmp file. If the temp 
> file has 900 MB, Main Memory free is 0 and the script aborts and php 
> deletes the tmp file.
>
> Why don't php use swap memory ?
>
> Greets Tom
> 



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



Re: [PHP] Re: php File upload

2008-08-08 Thread Tom
What is set this limit?

"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> Im very glad to fix this problem, but the next one is here: Other
> machine (but 2 GB Ram), same suse version, same (working now)  php.ini
> with limits to 5000M now and i can't upload a File greater than 900MB.
> A file under 900MB i see the tmp file growing. A File with +1 GB no
> temp file seeing at all and break after a view minutes. It's horrible
> with no error codes and wasting pure of time :-(

The maximum size of an HTTP request is 2Gb.


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-08 Thread Tom
Hi Per,

Execution Time ist set to 72000, i learned to set it not to low for tests 
:-)
I learned also the last days many things about the php.ini. Many changes 
affect later, its mostly for me a trial and error thing and results in much 
phenomenon.

At moment its okay, i can upload 1.2 Gb, no problem. I test to upload a 1.9 
GB file (reading the max is 2GB a browser can handle), but this failes. I 
don't know is this the overhead or what else.
Now i search the max value Browseres can handle for . Know you this value?



"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> Hi Per,
>
> your result is on a suse 8.2 ?
> hmm, i don't know the reason why my suse 10.2 machines do that
> failure. My limits for for post_max_size and upload_max_size is both
> 1500M.
>
> Greets & thanx, Tom

Tom,

check your maximum PHP execution time.  I've just done some testing
where the upload was interrupted after 60seconds with this error:

PHP Fatal error:  Maximum execution time of 60 seconds exceeded in
Unknown on line 0, referer: http://tintin/uploadbig.php

I increased time to 240seconds, and had no problem uploading a 1Gb file.
This was on a openSUSE 10.3 system with only 256M RAM.


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-08 Thread Tom
Practical i  implement a robust filebase in my new gamer portal and go to 
max. at upload values. If the users make a big upload, it should be stable.
I think, later (after release) i will enhance it with a ftp port. But not 
yet.

Here you can see, what i have in filebase, but a 1.9 GB upload fails. I 
don't know if this is the overhead.
http://www.guildmeets.de/index.php?onlydirid=78

(in Folder "Neue Game Demos")



"Per Jessen" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
Tom wrote:

> Hi Per,
>
> Execution Time ist set to 72000, i learned to set it not to low for
> tests
> :-)
> I learned also the last days many things about the php.ini. Many
> changes affect later, its mostly for me a trial and error thing and
> results in much phenomenon.
>
> At moment its okay, i can upload 1.2 Gb, no problem. I test to upload
> a 1.9 GB file (reading the max is 2GB a browser can handle), but this
> failes. I don't know is this the overhead or what else.

Well, it seems to me that you've achieved what you need, right?  You
don't need one big upload, you need many smaller but concurrent
uploads, yeah?
I'll try a bigger file later today and see what happens.


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-08 Thread Tom
Andrew write the answer:
-1149239296 Bytes is indiz for to big.


This time I had set the upload_file_size and post_max_size to 3000Mb
each, which probably didn't work.  When I tried the 1900Mb file again I
got this error:

[Fri Aug 08 16:57:28 2008] [error] [client 192.168.2.113] PHP Warning:
POST Content-Length of 1992294868 bytes exceeds the limit
of -1149239296 bytes in Unknown on line 0, referer


/Per Jessen, Zürich



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



Re: [PHP] php File upload

2008-08-08 Thread Tom
> PUT is raw (AFAIK)

That sounds good. Have you any link to a basicly methode description? This 
is a really new methode for me but sounds better than http upload btw. 
resume function is not bad.




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



php-general@lists.php.net

2004-01-28 Thread Tom
Gerard Samuel wrote:

> On Wednesday 28 January 2004 09:32 am, Stuart wrote:
>
>> Diana Castillo wrote:
>>
>>> is there any function that will always replace a "&" with a "&" in a
>>> string?
>>
>>
>> $string = str_replace('&', ' ', $string);
>>
>
>
> Just a heads up on using the above method.
> If there are more than one & in the string it will produce unexpected 
results.
> For example
> "Here is one & and here is another &"
> will produce
> "Here is one & and here is another &"
>

You could use preg_replace( '/&(?!amp;)/', '&', $string);
But I suspect that the OP is probably looking for "htmlentities"
and other such built in PHP functions.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] array walk and class member functions

2005-01-12 Thread Tom
Hi
I'm batting my head against a wall on this one...
I have a class that has a constructor which sets some initial 
conditions, and then a public function that does some work. I want to be 
able to call this function from an external array_walk call, but when I 
try and reference it as $myClass->myFunction in the array_walk call, I 
get an error back saying that this is an invalid function.

eg)

   $myArray = array("item1"=>"firstItem", "item2"=>"secondItem");
   $myClass = new aClass;
   array_walk($myArray,'$myClass->aMemberFunction');
?>
As a workaround, I redifined the class so that there was a public 
function which made the array_walk call with the worker function defined 
internally as follows, but this throws another issue in that if I create 
multiple instances of the class then I get an error to say that the 
internal function is already defined ...

*Fatal error*: Cannot redeclare aFunction() (previously declared in 
/usr/local/apache2/htdocs/includes/functions.php:23) in 
*/usr/local/apache2/htdocs/includes/functions.php* on line *23*
class aClass
{
some other stuff, constructor etc
   public function aPublicFunction($anArray)
   {
  global $aRetrunString;
 
  function aFunction($value, $key)
  {
   global $aReturnString;
   $aReturnString = $aReturnString.$value; 
  }

  array_walk($anArray,'aFunction');
  return $aReturnString;
   }
}
  
Can anyone help me to get either solution to a working state?

By the way...
apache 2.0.49
php-5.0.2
Thanks very much
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] array walk and class member functions

2005-01-12 Thread Tom
Thanks very much for the help - both methods work fine. I'd had a look 
at the array_walk manual, but didn't realise that the second param would 
accept an array - that's really cool!

I don't like the function_exists method much, as I frequently overload 
class members. Not needed now as I have the worker defined as a private 
function and can access it from the public one as
array_walk($anArray,array($this,'aFunction');

Thanks
Tom
Jochem Maas wrote:
Tom wrote:
Hi
I'm batting my head against a wall on this one...
I have a class that has a constructor which sets some initial 
conditions, and then a public function that does some work. I want to 
be able to call this function from an external array_walk call, but 
when I try and reference it as $myClass->myFunction in the array_walk 
call, I get an error back saying that this is an invalid function.

eg)

   $myArray = array("item1"=>"firstItem", "item2"=>"secondItem");
   $myClass = new aClass;
   array_walk($myArray,'$myClass->aMemberFunction');

try changing this line to:
array_walk($myArray, array($myClass,'aMemberFunction'));
or if you prefer to take the route of your second attempt read on...
?>
As a workaround, I redifined the class so that there was a public 
function which made the array_walk call with the worker function 
defined internally as follows, but this throws another issue in that 
if I create multiple instances of the class then I get an error to 
say that the internal function is already defined ...

which is correct, you are trying to create this function multiple times.

*Fatal error*: Cannot redeclare aFunction() (previously declared in 
/usr/local/apache2/htdocs/includes/functions.php:23) in 
*/usr/local/apache2/htdocs/includes/functions.php* on line *23*

class aClass
{
some other stuff, constructor etc
   public function aPublicFunction($anArray)
   {
  global $aRetrunString;
   function aFunction($value, $key)
  {
   global $aReturnString;
   $aReturnString = $aReturnString.$value;   }
  array_walk($anArray,'aFunction');
  return $aReturnString;
   }

wrap the function def. like so:
if (!function_exists('aFunction')) {
function aFunction($value, $key)
{
global $aReturnString;   
$aReturnString = $aReturnString.$value;
}
}

OR define the function outside of the class e.g.
function aFunction($value, $key)
{
global $aReturnString;   
$aReturnString = $aReturnString.$value;
}

BTW: using a global in the way you do in this function is a bad idea.
array_walk() is defined as follows:
bool array_walk ( array &array, callback funcname [, mixed userdata])
check out the manual for info on the last arg:
http://nl2.php.net/array_walk
}
  Can anyone help me to get either solution to a working state?
By the way...
apache 2.0.49
php-5.0.2
Thanks very much
Tom


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


Re: [PHP] Re: php style guides

2005-01-12 Thread Tom
Something I've laboured over for years, in various languages (same issue 
in perl, ASP, JSP...).
My personal preference depends on how much of what is being dumped. If 
it's a really simple page, then do it in line, I tend to indent it as a 
seperate tree to the php code (ie there are two staggers).
However if it's a longer page or includes loads of javascript or 
dynamically built tables etc, then I tend to keep the html in another 
file wrapped up as php functions with a UI_ prefix. This does make it a 
bit slower (calling loads of functions), but the maintenance is loads 
easier and it leaves the main code tree legible!

All down to personal preference though. The only hard and fast rule is 
to keep it consistent and comment well so that when you pick it up again 
a few months down the line you can still maintain it!

eg

Tom
But what I'm really wanting to get everyones thoughts about is in regard 
to combining PHP with HTML.

I used to do:
test
but just tried

  echo 'blah';
  echo 'test';
  echo 'blah';
?>
   

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


[PHP] mysql improved extensions affected_rows

2005-01-13 Thread Tom
I've just started playing with the php5 improved mysqli extensions.
I have the following code:-

$updateQuery = "UPDATE client SET status = 'INACTIVE' WHERE clientName = 
'Tom'";

if ($mysqli->query($updateQuery))
{
   $updateCount = $mysqli->affected_rows;
   echo "updateCount = $updateCount";
}
else
{
   excpetionHandler("updateFailed: ".$updateQuery);
}
?>
This returns "updateCount = 1"
However, when I check the underlying table, there are actually 4 rows 
updated (and yes, before anyone asks, I have repeated this several 
times, correctly resetting the data before each run)

Is this a known bug, or am I doing something stupid?
(php 5.0.2, apache 2.0.49)
Thanks
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mysql improved extensions affected_rows

2005-01-14 Thread Tom
Richard Lynch wrote:
Tom wrote:
 

I've just started playing with the php5 improved mysqli extensions.
I have the following code:-

$updateQuery = "UPDATE client SET status = 'INACTIVE' WHERE clientName =
'Tom'";
if ($mysqli->query($updateQuery))
{
   $updateCount = $mysqli->affected_rows;
   echo "updateCount = $updateCount";
}
else
{
   excpetionHandler("updateFailed: ".$updateQuery);
}
?>
This returns "updateCount = 1"
However, when I check the underlying table, there are actually 4 rows
updated (and yes, before anyone asks, I have repeated this several
times, correctly resetting the data before each run)
Is this a known bug, or am I doing something stupid?
(php 5.0.2, apache 2.0.49)
   

How many rows actually had 'Tom' for their clientName?...
I mean, is the '1' wrong because it should be 4, or is it changing records
it shouldn't?
 

It correctly updates 4 rows, but returns 1 as the count.
I think that this may actually be a mysql issue - I've put the same 
php/apache configs onto another similar box, the only difference being 
that the second box is mysql 5.0.1, whereas the problem is reported 
against 5.0.0 (both alpha's!). The correct value is returned from the 
second  box.

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


Re: [PHP] Execute shell script from PHP

2005-01-18 Thread Tom
shell_exec()
Tom
Khan wrote:
Hello,
I have a shell script for ading users to LDAP. It looks like this:
#!/bin/bash
MUID=userlogin
FULLNAME="First Last"
LASTNAME="Last"
DOMAIN=example.org
SERVER=qmail.example.org
PASS=userpass
cat > .ldif.tmp.$MUID << EOF
dn: uid=$MUID,ou=accounts,dc=example,dc=org
cn: $FULLNAME
sn: $LASTNAME
objectclass: top
objectclass: person
objectclass: inetOrgPerson
objectclass: qmailUser
mail: [EMAIL PROTECTED]
mailhost: $DOMAIN
mailMessageStore: /var/qmail/maildirs/$MUID/Maildir
userPassword: $PASS
uid: $MUID
accountStatus: enabled
EOF
ldapadd -x -v -w secret -D "cn=Manager,dc=example,dc=org" \
-f .ldif.tmp.$MUID
rm .ldif.tmp.$MUID
How Can I run (trigger) this script from PHP so I could create web 
form for adding users.

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


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread Tom
Marcus Bointon wrote:
How is this not a bug?

outputs:
2005-01-18 09:58:09 (correct)
2005-01-18 17:58:09 (incorrect)
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just reading 
the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

The time zone correction is applied in the wrong direction. Does it in 
both current PHP 4 and 5.

Named time zones like these are supposedly deprecated, but the 
suggested alternative in the docs doesn't work at all:

print date('Y-m-d H:i:s', strtotime('now UTC-0800'))."\n";
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Execute shell script from PHP

2005-01-18 Thread Tom
Khan wrote:
Tom wrote:
shell_exec()

yes, I have try that but nothing happenes. here is my code. Is this 
correct?


looks fine to me, except that I tend to run a check to make sure that it 
has run ok, like
$myReturn = shell_exec('/test/acct.sh');
or
if (shell_exec('/test/acct.sh');

On some systems you have to execute the script
eg
$myReturn = shell_exec('. /test/acct.sh');
Also make sure that the acct.sh script is executable by the php user
(chmod / chown are your evil friends :) )
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread Tom
Marcus Bointon wrote:
On 18 Jan 2005, at 10:53, Tom wrote:
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just 
reading the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

OK, I see some logic in that - now how to work around it?
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";

sorry, wrong language, you need
echo "full date PST is ", date('Y-m-d H:i:s', strtotime('now -8 
hours')), "";
If you define the constants in another file, then you can use them wherever
eg $PST = -8;
...
$dateString = 'now '.$PST.' hours';
echo "full date PST is ", date('Y-m-d H:i:s', strtotime($dateString)), 
"";

Tom
That definitely won't work; -0800 will be interpreted as an octal 
value, but it's not a legal value. If it was interpreted as a decimal 
value, it would subtract 800 minutes, which is no use to anyone. 
Numeric offsets are supposed to work inside the strtotime string 
param, according to the docs.

Much of the point of using zone names rather than fixed numeric 
offsets is that it allows for correct daylight savings calculations 
(assuming that locale data is correct on the server).

Let me rephrase the question - how can I get the current time in a 
named time zone using strtotime and without using a numeric offset?

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


Re: [PHP] PHP Cache

2005-01-25 Thread Tom
Squid any good to you? You can configure it to cache based on page name, 
GET and POST params (personally don't like to use POST params for static 
or semi static content, but that's a personal preference, not a hard and 
fast rule), farside domains
You set it up above your php servers so it doesn't care what language 
you are using to provide the content.

Tom
Merlin wrote:
Hi there,
I am trying to find a open source PHP Cache extension. After trying 
out ionCube PHP Accelerator (http://www.php-accelerator.co.uk) I had 
to remove it from the system since it brought down the server every 
few weeks due to some memory leak. There is also APC, but the latest 
build is over 3 years old.

Is there a working alternative for Zend? I am not sure if it is worth 
for me to spend that much money for a lizence.

Thank you for any suggestion.
Regards,
merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Log-in script help

2005-01-26 Thread Tom
Joe Harman wrote:
Hey Andrew... 

IN MY OPINION... forget the cookies... only use php sessions... but
like I said IMO you can never rely on the end user having them
cookies enabled... same with things like javascript...
let me outline some steps for you... everyone else... feel free to
state pros and cons to theses.. cause i always make mistakes, or
forget things :o)
1. get the user's access info... ie username & password
2. look for the user in the database that stores the access infro
3. if access is granted, I usually set 2 session variables
 a. $_SESSION['auth'] = TRUE  // They are authorized
 b. $_SESSION['user_id'] = {who}  // Who is it
 a. $_SESSION['user_level'] = {level} // What level access do
they have (optional)
4. at the beginning of each restricted access page, verify that they
are authorized to access that page... if they are not redirect them to
a access denied page.
that should get you started... maybe the second step would be to make
this stuff into functions... ... also, IMO.. it's a good idea to make
a logout script that will distroy that user's active session...
my turn for an IMO :) - my preference is to have a check on the function 
that writes the $_SESSION vars or the cookie (I generally use encrypted 
cookies which are in turn restricted to certain areas of the site). This 
check is on the referer - if it's not from a foreign URL, then write 
them new as if the user is non auth. This stops people on public 
machines from hitting a back button and being authenticated as the 
previous user.
Tom

not
sure what your PHP experience is... but hopefully the above steps will
help you out some..
Cheers!
Joe


On 25 Jan 2005 17:35:08 -0600, Bret Hughes <[EMAIL PROTECTED]> wrote:
 

On Tue, 2005-01-25 at 16:45, [EMAIL PROTECTED] wrote:
   

Hey,
  I need a particular type log in script. I'm not sure how to do it or
where I could find a tutorial that would help me, so I'll describe what I need
and then maybe someone could tell me what kind of script I need (sessions or
whatever) and where I could get the script/learn how to make it.
  I need a pretty basic log in script. Something that people log in to,
and the page and all linked/related pages cannot be accessed unless the person
has logged in.
  So what do I need for this? Cookies, sessions both? And where can I
learn how?
-Andrew
 

I use the pear auth package and like it alot.  I know I did some
modification for our purposes but I suspect it works out of the box.
All you do is include auth.php on all pages you want to protect and it
will direct you to a login page if you have not logged in.  Pretty cool
stuff.
http://pear.php.net/package/Auth
HTH
Bret
--
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] Apache: Request exceeded the limit of 10 internal redirects

2005-01-26 Thread Tom
James Guarriman wrote:
Hi
I've just installed Apache 2.0.52, with:
./configure --prefix=/usr/local/httpd --enable-so
--enable-modules=all
My httpd.conf includes:
---

ServerAdmin [EMAIL PROTECTED]
DocumentRoot "/home/mydomain"
ServerName mydomain
ErrorLog logs/mydomain-error_log
CustomLog logs/mydomain-access_log common
DirectoryIndex index.php index.html index.html.var

php_flag allow_url_fopen 1
php_flag magic_quotes_gpc 0
RewriteEngine on
RewriteOptions MaxRedirects=15
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /$1.php


-
(I try to make Apache serve 'foo' as 'foo.php')
But when accessing 'http://mydomain/foo', I get no
webpage,
but this error log:
--
[Mon Jan 24 10:47:59 2005] [debug]
mod_rewrite.c(1778): [client
192.168.2.101] mod_rewrite's internal redirect status:
10/15.
[Mon Jan 24 10:47:59 2005] [error] [client
192.168.2.101] Request
exceeded the limit of 10 internal redirects due to
probable
configuration error. Use 'LimitInternalRecursion' to
increase the limit
if necessary. Use 'LogLevel debug' to get a backtrace.
[Mon Jan 24 10:47:59 2005] [debug] core.c(2748):
[client 192.168.2.101]
r->uri =
/favicon.ico.php.php.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php.php
[Mon Jan 24 10:47:59 2005] [debug] core.c(2754):
[client 192.168.2.101]
redirected from r->uri =
/favicon.ico.php.php.php.php.php.php.php

If I remove the line 'RewriteOptions MaxRedirects=15',
I get
a very similar error:

[Wed Jan 24 10:31:29 2005] [debug]
mod_rewrite.c(1778): [client 192.168.2.101]
mod_rewrite's internal redirect status: 10/10.
[Wed Jan 24 10:31:29 2005] [error] [client
192.168.2.101] mod_rewrite: maximum number of internal
redirects reached. Assuming configuration error. Use
'RewriteOptions MaxRedirects' to increase the limit if
neccessary.
[Wed Jan 24 10:31:29 2005] [debug]
mod_rewrite.c(1778): [client 192.168.2.101]
mod_rewrite's internal redirect status: 0/10.
---
What am I doing wrong? Thank you very much.
 

What you are doing wrong is trying to use mod_rewrite, the nightmare 
extension from hell!
Seriously though, it is your rewrite rule that is wrong, you have 
defined a recursion in there for any filename that do not already end 
'.php' or have no .

RewriteRule ^(.*)$ /$1.php => add '.php' to the end of any filename that has a 
'.' in it somewhere (remember that you are in unix world, so the . does not 
signify a file extension in the same way as a domestos environment, it is just 
part of the filename).
eg1) blah => blah (no change as it doesn't match the regex)
eg2) favicon.ico => favicon.ico.php
when the rule next runs, it finds that favicon.ico.php does not match the 
exception of .php (the .ico gives the first match), so adds .php again, and 
again, and again, and again.
Tom
		
__ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

 

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


Re: [PHP] check server status...please help

2005-01-27 Thread Tom
Sarcasm was also my first thought on this one, then I thought I'd tell 
the world how I handle it !

For one of my sites there are two solutions implemented to two 
situations (that's two solutions in total, not four :)).

1) User is already in site, and makes another request.
Load up a very small js with the site. When the request times out, this 
script either pops an error message or redirects the requests to the 
failover.

2) User is trying to get to the site for the first time.
The domain is actually pointed to a GSLOB (load balancer). This 
continually polls both primary and secondary (and tertiary...) sites and 
directs traffic to whichever has the lowest load, or to whichever site 
the rules are set to.
This is of course a more expensive solution that may not be at all 
applicable in your instance (expense is the purchase and hosting of the 
load balancer hardware).

Tom
Jay Blanchard wrote:
[snip]
I want to write a script that will check if the server is down if it is
I 
want to redirect the user to another site, the backup server.

Similarly I want users who go on to the seondary site when the main
server 
is UP to be redirected to the main site.

Can this be done using PHP. If not can you point me in the right
direction?
Kind regards,
[/snip]
So I'm on this server at this URL right? And the HTTP server is down,
right? The script would have to be aware of an HTTP request, right? 

Let us say I am on http://foo.com and I click a link or enter an address
for http://bar.com . If the server is down that is hosting
http://bar.com  well, I think you see where I am going.
Now, you could requests to port 80 maybe. And PHP CLI could be set in a
loop to handle the request, but this may be a really bad plan. You would
probably want some sort of port sniffer to monitor the port for
activity.
 

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


Re: [PHP] mysql_pconnect / persistent database conections

2005-01-28 Thread Tom
Ben Edwards wrote:
Been meaning to investigate persistent database connections for a
while.  Coming from a rdbms background (oracle with a bit of whatcom
sqlanywhare) I have always felt that the overhead of opening a
connection at the beginning of each page was a little resource
intensive.
 

MySQL is not remotely the same beast as oracle - take pure session 
create times. I have a machine that runs both. Creating an oracle 
session with sqlplus command line takes in the region of 2 seconds (get 
around this for web apps by connection pooling). Creating a mysql 
connection (c client) takes in the region of 5 mS.
You also need to consider the memory / processor implications of caching 
connections (or keeping persistent connections) from your web server.

Anyway, I found mysql_pconnect and this sounds like just the ticket. 
Seems that I can just change my connect method from mysql_connect to
mysql_pconnect and it will just work.

I do have a couple of questions.  Firstly what is the story with
mysql_close.  There is no mysql_pclose.  I guess you don't need to
close the connection at the end of each page but what if you do.   Is
mysql_close ignored if the connection was made with mysql_pconnect or
douse it close the connection and next time mysql_pconnect is run it
reconnects causing no benefit over mysql_pconnect.  also what is the
timeout likely to be?
My other question is what happens if lots of people connect using the
same user/password.  I tend to do my own user management so everybody
douse.  Is doing my own user management really dodge, if we were
talking about oracle I would probably say it is.
Ben
 

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


[PHP] file upload error

2005-01-31 Thread Tom
Hi
I have a very simple file upload form and script to handle it (copied 
verbatim from the php manual, except for the file target location and 
the script name).
However, it always fails, with an error code in the _FILE array or 6.
Does anyone know what this error is or what I am likely to have set 
wrong? All that I can find in the docs are errors from 0 to 4 :-(
Also, the tmp_name is always empty (as is the type, but I would expect 
that as I'm not explicitly setting it).

My config is php5 with apache 2 on linux. My php.ini file has 
upload_tmp_dir explicitly set to /tmp (permissions on this are 777)

Code as follows :-
1) Form
 1 
 2Form to test file uploads
 3
 4   
 5
 6 
 7 
 8 
 9 
10 Send this  
11 
12 
13
14 

2) Handler
 1 
 2 // script to handle file uploads. Files are recieved from 
uploadForm.php in same directory.
 3
 4 $uploaddir = '/usr/local/apache2/htdocs/TradEx/uploads/';
 5 $uploadfile = $uploaddir . 
basename($_FILES['userfile']['name']);
 6
 7 echo '';
 8 if (move_uploaded_file($_FILES['userfile']['tmp_name'], 
$uploadfile))
 9 {
10 echo "File is valid, and was successfully uploaded.\n";
11 }
12 else
13 {
14 echo "Possible file upload attack!\n";
15 echo 'Here is some more debugging info:';
16 print_r($_FILES);
17 print "";
18 }
19
20 ?>

3) Output :-
Possible file upload attack!
Here is some more debugging info:Array
(
   [userfile] => Array
   (
   [name] => MANIFEST
   [type] => 
   [tmp_name] => 
   [error] => 6
   [size] => 0
   )

)
Thanks for any help
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] file upload error

2005-02-01 Thread Tom
Thanks for the replies. My manual was out of date, not that it would 
have made any difference to this anyway as .
upload_tmp_dir variable was correctly set in the php.ini file, and I'd 
restarted the web server several times. It seems however that the file 
is getting cached somehow, and is not re-read until I restart the entire 
box. Anyone out there know why this may be, or a slightly better way of 
getting around it than rebooting?
(By the way, the upload functionality is fine after the reboot :))

Ta
Tom
Marek Kilimajer wrote:
Tom wrote:
Hi
I have a very simple file upload form and script to handle it (copied 
verbatim from the php manual, except for the file target location and 
the script name).
However, it always fails, with an error code in the _FILE array or 6.
Does anyone know what this error is or what I am likely to have set 
wrong? All that I can find in the docs are errors from 0 to 4 :-(

It's there:
http://sk.php.net/manual/en/features.file-upload.errors.php
UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and 
PHP 5.0.3.

Note: These became PHP constants in PHP 4.3.0.
Set the correct upload_tmp_dir in php.ini and restart webserver
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Getting two queries into one result set

2005-02-02 Thread Tom
Graham Cossey wrote:
You don't say how many tables you have, how they are named or anything
outside of the query itself.
Assuming that not all your tables are named PID_* how about simply doing
SHOW TABLES LIKE '%PID_%'
and selecting appropriate results within the php script using strstr
or regular expressions? SHOW TABLES is (normally) such a quick query
returning a larger result set shouldn't be too much of a problem,
should it?
 

If it is, then you should rework your db to reduce the number of tables :)
Alternatively use multi-query with use_result and more_results.
If it's concise code that you are after, then set up all the search 
strings in an array, and pass this through a loop that performs each 
query at a time and cats the results into a new array.

HTH
Graham
On Wed, 02 Feb 2005 15:15:38 +0100, Marek Kilimajer <[EMAIL PROTECTED]> wrote:
 

Shaun wrote:
   

Hi guys,
Thanks for your replies but neither UNION or REGEXP can be used with SHOW
TABLES...
Any ideas?
 

It's time to change your table design. Use one pid table and add another
column that would hold the number.
--
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] How to get new row on top?

2001-02-18 Thread Tom


The approach I've used is four steps:

(1) read the current file into a variable (which preserves it)
(2) open the 'old' file for writing "w"  (which clears it also)
(3) write the "new stuf" to the file first
(4) lastly write the "old stuff" to the file

Here's a code sample that I just tested...

$new_line=" $LABEL\n";
$filecontents = join ('', file('./classified.html'));
$fp=fopen("./classified.html","w");
fwrite($fp,$new_line);
fwrite($fp,$filecontents);
fclose($fp);


Hope that helps, but YMMV.

CHeers,
Tom Henry



[EMAIL PROTECTED] (Jan Grafström) wrote in 
<[EMAIL PROTECTED]>:

>Hi!
>I have this code:
>$message = ereg_replace("\r\n\r\n", "\n", $message);
>And the new rows are placed under the old ones.
>I want to change so the old messages get placed under is that possible?
>Thanks for help.
>Jan
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Php search results]

2002-11-23 Thread Tom Culpepper
I wrote this function to fetch a news item off another web page but with
a little modification it should work for you.  To use it you needed to
identify a set of of strings in the source to use as anchors ($start,
$end) and then it pulls that section and crops off the anchor text so
you are left with just what you wanted.


function get_item($url, $start, $end) {
	global $item;
	if(!($fp=fopen($url,"r"))) {
		echo $url." is not accessable";
		exit;
	}
	while(!feof($fp)) {
		$item.=fgets($fp,255);
	}
	
	fclose($fp);
	$start_position=strpos($item, $start)+strlen($start);
	$end_position=strpos($item, $end);
	$length=$end_position-$start_position;
	$item=substr($item, $start_position, $length);	
}
echo $item;
?>

Soemthing like this might work for you:

$results=search results;
$keyword=search string;
$startposition=strpos($results, $keyword)-200;
$endposition=strpos($results, $keyword)+200;
$length=$endposition-$startposition;
$item=substr($item, $startposition, $length;
echo $item
?>

Tom Culpepper
www.multicasttech.com
[EMAIL PROTECTED]


Alex wrote:
> you could also use regular expressions, but php isn't perl, so good 
luck on
> that one :p.
>
>
> "Philip Hallstrom" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>>You could use strstr() to find the index location of the
>>string searched for in FIELD.  Then use substr() to return say 50
>>characters on either side...
>>
>>-philip
>>
>>On Thu, 21 Nov 2002, Daniel Masson wrote:
>>
>>
>>>Hello everyone ...
>>>
>>>Im working on some kind of search engine for two little tables on text
>>>fields on mssql, and the text fields can be very large fields, im doing
>>>the search with SELECT FIELD FROM TABLE WHERE FIELD LIKE '%SOMTHING%' ..
>>>My question is:
>>>
>>>When displaying the search results i dont want to display the entire
>>>field, only the specific parts where the keyword was found , and bold
>>>for the keyword and i just dony know  how to to do that, i mean
>>>displaying the keyword in bold is no problem .. I need to know how to
>>>display only the parts where this keyword is.
>>>
>>>Any help will be very helpful
>>>
>>>Thanks every1
>>>
>>>
>>>
>>>--
>>>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] grabbing data from a site

2002-11-23 Thread Tom Culpepper
Try this function, Ijust wrote it for the same purpose.  You just need a 
 unique string in front of the stuff you want, and one after it.  You 
can usually get a string of code on either end that will do this.  The 
function will open the URL, find the anchor strings you told it, then 
strip them away leaving only the text/code that was in between them


function get_item($url, $start, $end) {
global $item;
if(!($fp=fopen($url,"r"))) {
echo $url." is not accessable";
exit;
}
while(!feof($fp)) {
$item.=fgets($fp,255);
}

fclose($fp);
$start_position=strpos($item, $start)+strlen($start);
$end_position=strpos($item, $end);
$length=$end_position-$start_position;
$item=substr($item, $start_position, $length);
}
echo $item;
?>

Tom Culpepper
Multicast Technologies

Adam wrote:
someone gave me the following expression which uses another program and it
works fine for them... is there something similar with php?

wget --timeout=90 -q -O- http://www.BoM.GOV.AU/products/IDO30V01.shtml | sed
'1,/>Melbourne //;s/<.*//'

thanks,
adam.

"Evan Nemerson" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

If the target is in well-formed XML (XHTML is an example), you could use


XSLT


to say 'i want the third column of a particular row - in this instance,
Melbourne'. However, since few people actually adhere to standards, you're
probably going to need a regex... if you're not comfortable with them,
explode() could be useful (although it is slower)

Somebody posted an extremely helpfull little quick reference at


php.net/ereg,


i think... that might help you.


On Friday 22 November 2002 01:40 pm, Adam wrote:


I have the following website that i want to grab info from:

http://www.bom.gov.au/products/IDV60034.shtml

Say I wanted the current temperature for Melbourne from this table, what
line of code would I need to tell it to get that info - ie, an ereg()
expression...

i'm wondering whether there are ways of saying "i want the third column



of


a particular row - in this instance, Melbourne"?

Thanks for any help.
Adam.


- --
I pledge allegiance to the flag, of the United States of America, and to


the


republic for which it stands, one nation indivisible, with liberty, and
justice for all.

- -Pledge of Allegiance
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE93qVm/rncFku1MdIRAshSAJ9phj0DqR3seanlzKXhdnKj8cvI8QCfW7kM
tfUfUEF4yVJSRnm0GCkIeaM=
=AyI1
-END PGP SIGNATURE-










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




Re: [PHP] put result of "include" into a variable

2002-11-23 Thread Tom Culpepper
Try using fopen() to open the file and then fread() to read it into the 
buffer and set that equal to the variable.

Tom Culpepper
Multicast Technologies

Patrick Anderson at TUE wrote:
Hi,

For some (strange, I know) reason I would like to copy the content of a
webpage into a database.

I would like to have code like

$whocares = include ("http://www.microsoft.nl";);
$query = "insert into html values ($whocares,...)";
..

However, include can not copy the content to a variable. Does anyone
have an idea how to circumvent this problem?

Thanks,
Patrick







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




Re: [PHP] Parse URLs

2002-11-23 Thread Tom Culpepper
not entirely sure what is going on there, but if the user is entering 
the url in a html form.  Then just grab the variable on the next page 
and run this

$url=user $HTTP_GET_VARS["url"]; (or $HTTP_POST_VARS depending on your 
form method)
$url="".$url."";
echo $url;

the only way to change it dynamically on the same page would be javascript.

-tom culpepper

Stephen wrote:
I have a simple post script and I want to make it so if a user types in 
a URL of some sort, to change it to make it clickable. How could I do that?

Thanks,
Stephen Craton
http://www.melchior.us
 
"Life is a gift from God. Wasting it is like destroying a gift you got 
from the person you love most." -- http://www.melchior.us




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




Re: [PHP] Parse URLs

2002-11-23 Thread Tom Culpepper
from the archives of the list
http://www.phpbuilder.com/mail/php-windows/2001042/0222.php

-tom culpepper


Stephen wrote:

They are entering in a whole paragraph or two of text and I want to search
the paragraph for URLs then make it a clickable URL and then store it in a
MySQL database.


- Original Message -
From: "Tom Culpepper" <[EMAIL PROTECTED]>
To: "Stephen" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, November 23, 2002 9:05 PM
Subject: Re: [PHP] Parse URLs




not entirely sure what is going on there, but if the user is entering
the url in a html form.  Then just grab the variable on the next page
and run this

$url=user $HTTP_GET_VARS["url"]; (or $HTTP_POST_VARS depending on your
form method)
$url="".$url."";
echo $url;

the only way to change it dynamically on the same page would be


javascript.


-tom culpepper

Stephen wrote:


I have a simple post script and I want to make it so if a user types in
a URL of some sort, to change it to make it clickable. How could I do



that?


Thanks,
Stephen Craton
http://www.melchior.us

"Life is a gift from God. Wasting it is like destroying a gift you got
from the person you love most." -- http://www.melchior.us





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










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




Re: [PHP] Decrypt Password

2002-11-26 Thread Tom Woody
Password function is one way only...your only choice is to use
encrypt() decrypt() or just do like most other places, they say they
lost it, and you email it to a verified email address.


On Tue, 26 Nov 2002 16:16:22 -0500
"Stephen" <[EMAIL PROTECTED]> wrote:

> I would like to make a "Lost Password" part to my member's area script
> but the problem is, the passwords in the database are encrypted using
> the password function. How could I decrypt it for a lost password
> thing?
> 
> Thanks,
> Stephen Craton
> http://www.melchior.us
> 
> "Life is a gift from God. Wasting it is like destroying a gift you got
> from the person you love most." -- http://www.melchior.us


-- 
Tom Woody
Systems Administrator
NationWide Flood Research, Inc.
phone: 214-631-0400 x209
  fax: 214-631-0800

Don't throw your computer out the window, 
throw the Windows out of your computer! 


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




Re: [PHP] php bugs (Chinese word display problem)-help

2002-11-26 Thread Tom Culpepper
I am not positive of the problem as I can not see your code, but if you 
want to display the words that end in '5C' the you can do them like so:
\(escape character)  like this: \(95 5C 5C)

If you could sttach some code we might have a better idea.

-tom culpepper

[EMAIL PROTECTED] wrote:
Hi, everyone:
I am a Chinese, I am a programmer.
I encounter a problem about php.
Attachment is 1.php,
when i open this file (this file is saved at linux server, apache and
php 4.2.3 are installed on this server) in Internet Explorer, error
displays:

 Parse error: parse error, expecting `','' or `';'' in
/usr/3give/test/1.php on line 5


(If your computer is windows 2000, and Simplify Chinese and Traditional
chinese language are installed) you will read the Chinese word.

I found that if the hex code for Chinese word ends with '5C', then the
error will exist.
Anymore, if I input a Chinese word which hex code ends with '5C' in the
database field, then the display result will add a suffix '\', for example,
if i input "ÖÐß\", it will display "ÖÐß\\" at the browser (Internet
explorer).
I don't know why this problem exist, can you solve this problem for us?

 Contact me by: [EMAIL PROTECTED]; (86)755-27232311->samuel

Best regards
Thanks.
Samuel












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




Re: [PHP] Invalid Charactors in a string.

2002-11-26 Thread Tom Culpepper
lookup ereg() and eregi()

-tom culpepper

Philip J. Newman wrote:

Where should i start, tips wanted.

I would like to check a username string for valid charactors before the name
is processed.

Someone point me in the right direction please

---
Philip J. Newman.
Head Developer.
PhilipNZ.com New Zealand Ltd.
http://www.philipnz.com/
[EMAIL PROTECTED]

Mob: +64 (25) 6144012.
Tele: +64 (9) 5769491.

VitalKiwi Site:
Philip J. Newman
Internet Developer
http://www.newman.net.nz/
[EMAIL PROTECTED]

*
  Friends are like Stars,
  You can't always see them,
  But you know they are there.

*

ICQ#: 20482482
MSN ID: [EMAIL PROTECTED]
Yahoo: [EMAIL PROTECTED]
AIM: newmanpjkiwi







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




Re[2]: [PHP] object passing by reference

2002-11-27 Thread Tom Rogers
Hi

This should do it:

class parentClass {
  var $x;
  var $child;
 
 function parentClass($_x, &$_child) {//<<<<<<<<<<<<<
$this->x = $_x;
$this->child =& $_child;  //<<<<<<<<<<
$this->child->m = "Grow up, son";
 }
 
 function foo() {
return "I'm the parent.";
 }
}


class childClass {
 var $m;
 
 function childClass($_m) {
  $this->m = $_m;
 }
 
 function goo(){
  return "I'm the child.";
 }
}


$son = new childClass("I want my mommy");
$dad = new parentClass("I want a new Porche", $son);

echo $dad->child->goo();
echo $dad->child->m;
echo $son->m;





-- 
regards,
Tom


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




Re: [PHP] Logging out and session ids

2002-11-29 Thread Tom Rogers
Hi,

Friday, November 29, 2002, 4:58:02 PM, you wrote:
GS> I was just going through the archive.  Seems this comes up enough for me 
GS> to think I have something wrong.
GS> A simplistic code flow of events...
GS>  session_start();

GS> // user successfully logs in, set a session variable
GS> $_SESSION['user_id'];

GS> // when the user logs out, destroy session and redirect to top
GS> $_SESSION = array();
GS> setcookie(session_name(), '', time() - 3600);
GS> session_destroy();

GS> header('location: back_to_top');

?>>

GS> Ok, so when the user logs in, a session id is assigned to them.
GS> When they log out and are redirected to the beginning, the session id is 
GS> the same (verified by the file name in /tmp and cookie manager in mozilla).
GS> My question is, even though the session contains no data after its 
GS> destroyed, should the session id remain the same, after logging out,
GS> or should another be assigned when session_start() is called after the 
GS> redirect???

The browser will send the old cookie and as the name is probably the same as the
the old session it will get used again, or at least I think that is what is
happening :)
This should not be a problem as the data associated with the old session is
gone.
If you close the browser and start a fresh one you will get a new session id.

-- 
regards,
Tom


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




Re[2]: [PHP] Logging out and session ids

2002-11-29 Thread Tom Rogers
Hi,

I have never bothered with the cookie, I only delete the server side info.
-- 
regards,
Tom


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




Re: [PHP] Inheritance problem

2002-12-01 Thread Tom Rogers
Hi,

Sunday, December 1, 2002, 10:05:53 PM, you wrote:
BC> Hi,

BC> I would like to post the following question related to an inheritance 
BC> problem with PHP OO programming : 

BC> With an object of a subclass, I call a method of the parentclass in order 
BC> to modify an attribute of the parentclass. It does work correctly but later 
BC> when I call the display method of the parentclass, I receive the previous 
BC> value of the attribute !!!

Try this:

class Rain
{
var $jungle;

function Rain(&$jungle) //<<<<<
{
$this->jungle =& $jungle; //<<<<<
}

function fall($density)
{
$this->jungle->receiverain($density);
}


} // Rain




-- 
regards,
Tom


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




Re: [PHP] RV: includes & globals

2002-12-01 Thread Tom Rogers
Hi,

Monday, December 2, 2002, 4:06:54 PM, you wrote:
CA> Hi all,

CA> I'm making a site with a dynamic menu based on IF statements and DB
CA> queries, but have this little problem which I can't understand the
CA> reason. My programming method is based upon an application.php file
CA> which controls the hole site and paths, template files for the header &
CA> footer and main PHP files which includes all the needed files that I
CA> mentioned before.

CA> As an example of this, the header TITLE tag has a  variable
CA> to take a different title for each page and after that, I put a
CA> $LOCATION variable to tell the menu() function which page is being
CA> displayed (different menus for products, about us, etc.) but the menu()
CA> function (fetched from a library) is not recognizing this $LOCATION
CA> variable. I'm declaring it as a GLOBAL inside the function, but nothing
CA> happens. Here's part of my code:

CA> This is part of my product's index.php file:

CA> 
 Your if statements should be like this:

 if ($LOCATION == "productos") //needs the double '=' sign

 otherwise $LOCATION is always set to  productos


-- 
regards,
Tom


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




Re: [PHP] How to handle "so called" expired sessions??

2002-12-02 Thread Tom Rogers
Hi,

Tuesday, December 3, 2002, 1:57:21 PM, you wrote:
GS> Ive just been getting myself deep into using sessions.
GS> Sessions are working as it should except for one condition.
GS> Say I log into the site, and the session is started, and I don't do 
GS> anything for the next 30 mins, then go back to the site.
GS> Im temporarily logged out, but because the session cookie is still good, 
GS> the next page load logs me back in.
GS> How do the people who use sessions handle this type of scenario??

GS> Thanks for any insight you may provide...

GS> -- 
GS> Gerard Samuel
GS> http://www.trini0.org:81/
GS> http://dev.trini0.org:81/


Do your own session timing by storing a last access time in sessions and check
the duration yourself, if it is over the timeout you want delete the session
data and start again. That way the cookie is ok but won't point to any old data.

-- 
regards,
Tom


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




Re: [PHP] Validating get and post data

2002-12-02 Thread Tom Rogers
Hi,

Tuesday, December 3, 2002, 12:12:09 PM, you wrote:
BG> Okay, I've just solved my own problem by simply doing:

BG> settype($input,"integer");

BG> but.. I'm puzzled about why the following more complicated solution 
BG> didn't work. The ASCII value for 0 is 48, and for 9 is 57.

BG> The idea was to read a character at a time from the $rawinput string, 
BG> check if it's within the correct range, and if so concantenate it to the 
BG> end of the output string.

BG> However bizarrely this seems to behave incorrectly, as it cuts out "0" 
BG> as well. Can anyone explain why it does this?

BG> function stripnum($rawinput)
BG> {

BG> for($x=0;$x < strlen($rawinput);$x++)
BG> {
BG> $c = substr($rawinput,$x,1);

BG> switch($c){

BG> case ($c > chr(47) and $c < chr(58)):
BG> $output .=$c;
BG> break;

BG> default:
BG> echo "escaped character at ".$x;
BG> break;
BG> }

BG> }

BG> return $output;
BG> }


BG> I just can't find the bug in my code at all, and even though I found a 
BG> better way to do it, it's annoying me that this didn't work!!!

BG> Beth Gore
BG> --
BG> http://bethanoia.dyndns.org/
BG> rss feed: http://bethanoia.dyndns.org/bethanoia.rss

switch will treat 0 as false which ever way you try to dress it up :)
I solved a similar problem like this:

switch($c){

   case (ord($c) > 47 && ord($c) < 58)?True:False:
$output .=$c;
   break;

   default:
echo "escaped character at ".$x;
   break;
}

-- 
regards,
Tom


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




Re[2]: [PHP] Validating get and post data

2002-12-02 Thread Tom Rogers
Hi,

Tuesday, December 3, 2002, 5:17:48 PM, you wrote:
TR> Hi,

TR> Tuesday, December 3, 2002, 12:12:09 PM, you wrote:
BG>> Okay, I've just solved my own problem by simply doing:

BG>> settype($input,"integer");

BG>> but.. I'm puzzled about why the following more complicated solution 
BG>> didn't work. The ASCII value for 0 is 48, and for 9 is 57.

BG>> The idea was to read a character at a time from the $rawinput string, 
BG>> check if it's within the correct range, and if so concantenate it to the 
BG>> end of the output string.

BG>> However bizarrely this seems to behave incorrectly, as it cuts out "0" 
BG>> as well. Can anyone explain why it does this?

BG>> function stripnum($rawinput)
BG>> {

BG>> for($x=0;$x < strlen($rawinput);$x++)
BG>> {
BG>> $c = substr($rawinput,$x,1);

BG>> switch($c){

BG>> case ($c > chr(47) and $c < chr(58)):
BG>> $output .=$c;
BG>> break;

BG>> default:
BG>> echo "escaped character at ".$x;
BG>> break;
BG>> }

BG>> }

BG>> return $output;
BG>> }


BG>> I just can't find the bug in my code at all, and even though I found a 
BG>> better way to do it, it's annoying me that this didn't work!!!

BG>> Beth Gore
BG>> --
BG>> http://bethanoia.dyndns.org/
BG>> rss feed: http://bethanoia.dyndns.org/bethanoia.rss

TR> switch will treat 0 as false which ever way you try to dress it up :)
TR> I solved a similar problem like this:

TR> switch($c){

TR>case (ord($c) > 47 && ord($c) < 58)?True:False:
TR> $output .=$c;
TR>break;

TR>default:
TR> echo "escaped character at ".$x;
TR>break;
TR> }

TR> -- 
TR> regards,
TR> Tom

BTW you may find this runs a bit quicker

function stripnum($rawinput)
{
$len =  strlen($rawinput);
$output = '';
for($x=0;$x < $len;$x++)
{

switch($rawinput[$x]){

case (ord($rawinput[$x]) > 47 && ord($rawinput[$x]) < 
58)?True:False:
$output .= $rawinput[$x];
break;

default:
echo "escaped character at ".$x;
break;
}

}

return $output;
}

-- 
regards,
Tom


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




Re: [PHP] help needed with crypt()

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 12:45:15 AM, you wrote:
cyc> Hi

cyc> The script is not working.

cyc>function authenticate($user,$pass) {
cyc>  $result = -1;
cyc>  $data = file("shadow"); /* permission every
cyc> one read */

cyc>  foreach($date as $line ) {
cyc> $arr = explode(":",$line); 
cyc>  if($arr[0] == $user) {
cyc>   /* user name matching */
cyc>  if(crypt(trim($pass),$salt) == $arr[1])
cyc>{  $result = 1;
cyc> break;
cyc> }
cyc>   else
cyc>{
cyc>$result = 0;
cyc> break;
cyc> }
cyc>}  /* end of for */
cyc>   return $result ;

cyc> }


cyc> The above programme always returs -1.

cyc> Any help would be appreciated.

cyc> regards
cyc> CVR




cyc> __
cyc> Do you Yahoo!?
cyc> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
cyc> http://mailplus.yahoo.com


This line should probably be like

foreach($data as $line ) { //currently date

and you will have to extract $salt from the password field too

-- 
regards,
Tom


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




Re[2]: [PHP] help needed with crypt()

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 1:27:49 AM, you wrote:

cyc> Hi
cyc>I made some changes to this script but still it is
cyc> not working 


Try using the whole password as the salt like this

if(crypt(trim($pass),$arr[1]) == $arr[1])

Or are you still only getting -1 returned ?

-- 
regards,
Tom


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




Re[2]: [PHP] How to handle "so called" expired sessions??

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 4:01:07 AM, you wrote:
>> Ive just been getting myself deep into using sessions.
>> Sessions are working as it should except for one condition.
>> Say I log into the site, and the session is started, and I don't do
>> anything for the next 30 mins, then go back to the site.
>> Im temporarily logged out, but because the session cookie is still
JWH> good,
>> the next page load logs me back in.
>> How do the people who use sessions handle this type of scenario??

JWH> Whether your logged back in or not is dependant on your program. Once
JWH> you are gone for over X minutes, your session file is deleted. So, even
JWH> though the cookie is still good, the session will not have any data.
JWH> What's usually done is to check for a certain session value, like
JWH> $_SESSION['logged_in'] and if it's present, then continue, otherwise
JWH> force the user to log back in again.

JWH> ---John Holmes...

Not quite that simple as the cleanup proccess may not have run and the data is
still sitting there, I use msession so I am not sure if the normal session stuff
will return expired data after it expires and before it is deletedmsession
does so I hacked it to cleanup if expired data is requested.

-- 
regards,
Tom


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




Re: [PHP] My first post

2002-12-03 Thread Tom Rogers
Hi,

Tuesday, December 3, 2002, 7:37:20 AM, you wrote:
VE> Hi.

VE> I'm new in PHP. Could you point me where can i download a sample script
VE> about how can i paginate some results?

VE> TIA
Here is a class that will create a google like pagination of results  if that is
what you are after :)

count = $count;
$this->show = $show;
$this->maxpages = $max;
($this->count % $this->show == 0)? $this->pages = 
intval($this->count/$this->show) :$this->pages intval($this->count/$this->show) +1;
if(!empty($_GET['search_page'])){
$this->page = $_GET['search_page'];
$this->start = $this->show * $this->page - $this->show;
}
}
function get_limit(){
$limit = '';
if($this->count > $this->show) $limit = 
'LIMIT'.$this->start.','.$this->show;
return $limit;
}
function make_head_string($pre){
$r = $pre.' ';
$end = $this->start + $this->show;
if($end > $this->count) $end = $this->count;
$r .= ($this->start +1).' - '.$end.' of '.$this->count;
return $r;
}
function make_page_string($words,$pre='Result Page:'){
$r = $pre.' ';
if($this->page > 1){
$y = $this->page - 1;
$r .= 'Previous ';
}
$end = $this->page + $this->maxpages-1;
if($end > $this->pages) $end = $this->pages;
$x = $this->page - $this->maxpages;
$anchor = $this->pages - (2*$this->maxpages) +1;
if($anchor < 1) $anchor = 1;
if($x < 1) $x = 1;
if($x > $anchor) $x = $anchor;
while($x <= $end){
if($x == $this->page){
$r .= ''.$x.' ';
}
else{
$r.= ''.$x.' ';
}
$x++;
}
if($this->page < $this->pages){
$y = $this->page + 1;
$r .= 'Next ';
}
return $r;
}
}

//Usage

mysql_connect("**.**.**.**", "**", "") or die (mysql_error());

$Query = "SELECT COUNT(*) AS cnt FROM tabletosearch WHERE fieldtosearch LIKE '%" 
.$searchword. "%'";
$query = mysql_query($Query) or die(mysql_error());
$row = mysql_fetch_array($result);
$count = $row['cnt'];
if($count > 0){
  //start class total number of results,number of results to show,max number 
of pages on a sliding scale (ends up as 2x this number..ie 20)
$page = new page_class($count,5,10); 
$limit = $page->get_limit();
$Query2= "SELECT * FROM tabletosearch WHERE fieldtosearch LIKE '%" 
.$searchword. "%' ORDER BY  whatever ASC ".$limit;
$result = mysql_query($Query2) or die(mysql_error());
$hstring = $page->make_head_string('Results');
$pstring = 
$page->make_page_string("&searchword=".$searchword."&whatever=".$whatever);//add
 the other variables to pass to next page in a similar fashion
echo "".$hstring."";
while($row = mysql_fetch_array($result)){
   echo "".$show_data_here."";
}
echo "".$pstring."";
}
?>
Note: the search variables on subsequent pages will be passed by GET method








-- 
regards,
Tom


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




Re[4]: [PHP] How to handle "so called" expired sessions??

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 1:04:07 PM, you wrote:
S> I have a similar problem only my sessions expire once you leave the site,
S> even for a second. I'm not so experienced with cookies so how can I fix
S> this?


S> - Original Message -----
S> From: "Tom Rogers" <[EMAIL PROTECTED]>
S> To: "John W. Holmes" <[EMAIL PROTECTED]>
S> Cc: "'Gerard Samuel'" <[EMAIL PROTECTED]>; "'php-gen'"
S> <[EMAIL PROTECTED]>
S> Sent: Tuesday, December 03, 2002 9:52 PM
S> Subject: Re[2]: [PHP] How to handle "so called" expired sessions??


>> Hi,
>>
>> Wednesday, December 4, 2002, 4:01:07 AM, you wrote:
>> >> Ive just been getting myself deep into using sessions.
>> >> Sessions are working as it should except for one condition.
>> >> Say I log into the site, and the session is started, and I don't do
>> >> anything for the next 30 mins, then go back to the site.
>> >> Im temporarily logged out, but because the session cookie is still
>> JWH> good,
>> >> the next page load logs me back in.
>> >> How do the people who use sessions handle this type of scenario??
>>
>> JWH> Whether your logged back in or not is dependant on your program. Once
>> JWH> you are gone for over X minutes, your session file is deleted. So,
S> even
>> JWH> though the cookie is still good, the session will not have any data.
>> JWH> What's usually done is to check for a certain session value, like
>> JWH> $_SESSION['logged_in'] and if it's present, then continue, otherwise
>> JWH> force the user to log back in again.
>>
>> JWH> ---John Holmes...
>>
>> Not quite that simple as the cleanup proccess may not have run and the
S> data is
>> still sitting there, I use msession so I am not sure if the normal session
S> stuff
>> will return expired data after it expires and before it is
S> deletedmsession
>> does so I hacked it to cleanup if expired data is requested.
>>
>> --
>> regards,
>> Tom
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

You will have to put phpinfo(32);
at the top of your page and see what the browser is sending for session info
sounds like it is not sending the session cookie.
Are you using apache style authentication?
netscape will not send a cookie and auth info together (at least that is what I
have noticed when I tried that style of authenticating and eventually abandoned
it :)

-- 
regards,
Tom


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




Re[4]: [PHP] How to handle "so called" expired sessions??

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 1:33:03 PM, you wrote:
No question :)
It's just that this is what the original question was about and why I suggested
doing his own sesssion timeout check as the deleting proccess is too unreliable
to depend on for timeout handling. PHP will quite happily return stale data
which could be bad in a login type of situation.

JWH> Okay, so what's your question? The cookie and data is still there, but
JWH> it's expired? How? As far as I know it's not expired until it is
JWH> deleted. 

JWH> ---John Holmes...






-- 
regards,
Tom


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




Re[6]: [PHP] How to handle "so called" expired sessions??

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 1:59:11 PM, you wrote:

JWH> Okay. I think I thought you were the original poster. How do you know
JWH> it's returning "stale" data, though? If the cookie is valid, and there
JWH> is still a session file (or data in memory), then why is it stale or
JWH> expired. Maybe I'm just missing something here. If it's expired because
JWH> you think it's too old, then you track your own timestamps and do your
JWH> own cleanup. Is that what you're saying? 

Yes exactly, common problem is someone logs in but doesn't log out and the
session is open to everyone, session timeout is supposed to help prevent these
cases or at least reduce the chance. But of course the main use of session
timeout is to frustrate developers who take more than 40 mins to suss out the
next bit of code 
-- 
regards,
Tom


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




Re: [PHP] Whimper, help :)

2002-12-03 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 2:06:36 PM, you wrote:
JTJ> Martin,
JTJ> Anyone,

JTJ> I'm desperate :( PHP isn't sending my SQL correctly. It's not a MySQL problem. 
It's my PHP syntax.

JTJ> Debugging:
JTJ> http://ccl.flsh.usherb.ca/print/print.html?search=%26quot%3Bready+maria%26quot%3B

JTJ> $sql = 'SELECT ... FROM '.$table.' WHERE MATCH ... AGAINST
JTJ> (\'"ready maria"\' IN BOOLEAN MODE) ORDER BY id asc';

JTJ> Yay ... :) it works!!! (http://ccl.flsh.usherb.ca/print/display.test.inc.phps)

JTJ> If I copy & paste this SQL into PHPMyAdmin, it works.

JTJ> BUT IT WON'T WORK IN PHP. The code belows echos $sql correctly, but MySQL thinks 
it received:

JTJ> +ready +maria

JTJ> not

JTJ> "ready maria"

JTJ> See: 
http://ccl.flsh.usherb.ca/print/index.html?search=%26quot%3Bready+maria%26quot%3B

JTJ>   $sql = 'SELECT ... FROM '.$table.' WHERE MATCH ... AGAINST
JTJ>   (\''.stripslashes($search).'\' IN BOOLEAN MODE) ORDER BY id
JTJ>   asc';

JTJ>   $sql = "SELECT ... FROM `$table` WHERE MATCH ... AGAINST
JTJ>   ('".stripslashes($search)."' IN BOOLEAN MODE) ORDER BY id
JTJ>   asc";

JTJ>   See (http://ccl.flsh.usherb.ca/print/display.table.inc.phps)

JTJ> What is the correct PHP syntax to get MySQl to read my SQl correctly?
JTJ> What am I f***ing up?

JTJ> John


If you are looking for " in a string just quote it with '

example
$like = '"ready maria"';
$ sql = " SELECT .. WHERE  LIKE '$like'";

no need to escape anything

-- 
regards,
Tom


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




Re: [PHP] Re: mcrypt 2.4.x - trouble with small data fields?

2002-12-04 Thread Tom Rogers
Hi,

Wednesday, December 4, 2002, 3:39:10 PM, you wrote:
>>Is there a minimum field size for using mcrypt?

SY> Boy I feel dumb now.  :)  My answer was in my post.  Mcrypt returns a
SY> string that is usually longer than the original string, since the return has
SY> to be a multiple of the block size used. So a 2-character string takes
SY> "blocksize" characters when encrypted.  Mcrypt also apparently needs the
SY> extra characters when decrypting.

SY>  - Steve Yates
SY>  - If at first you don't succeed, lower your standards.

SY> ~ Taglines by Taglinator - www.srtware.com ~

Here is a class I made that will handle any size string and always returns the
same string that was encoded.

class encrypt_class{
var $secret;
function encrypt_class(){
$this->secret = 'this is a very long key, even too long for me';
}
Function encode($id){
$eid = $iv = 0;
$len = strlen($id);
$id = $len.'-'.$id;
$td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
$key = substr($this->secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack("a".mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$eid = base64_encode(mcrypt_generic ($td, $id));
mcrypt_generic_deinit($td);
  return $eid;
}
Function decode($eid){
$id = $iv = 0;
$td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
$key = substr($this->secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack("a".mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$id = mdecrypt_generic ($td, base64_decode($eid));
$len = strtok($id,'-');
$id = substr($id,(strlen($len)+1),$len);
mcrypt_generic_deinit($td);
return $id;
}
}









-- 
regards,
Tom


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




  1   2   3   4   5   6   7   8   9   10   >