php-general Digest 31 Oct 2008 10:47:38 -0000 Issue 5765

2008-10-31 Thread php-general-digest-help

php-general Digest 31 Oct 2008 10:47:38 - Issue 5765

Topics (messages 282673 through 282693):

Sessions in object oriented code
282673 by: Ben Stones
282674 by: Yeti
282675 by: Ben Stones
282682 by: Ashley Sheridan
282686 by: Yeti

Re: PreReq Index
282676 by: Craige Leeder

Re: Mailing lists
282677 by: Robert Cummings
282678 by: Daniel P. Brown
282679 by: Shawn McKenzie
282680 by: Robert Cummings
282681 by: Ashley Sheridan
282683 by: Lupus Michaelis
282688 by: Richard Heyes
282689 by: Richard Heyes
282690 by: Richard Heyes

Invalid byte sequence for encoding UTF-8
282684 by: paragasu
282685 by: Lester Caine
282691 by: paragasu

Re: DOCTYPE, javascript and Firefox
282687 by: Ross McKay
282692 by: Arno Kuhl

VAT number validation
282693 by: Koenraad Vanden Daele

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Hi,

Hope I can explain this as easily as possible, basically I am using both
cookies and sessions for my script, whereby the user is allowed to choose
which method they want to login with. Problem for me is removing the
registration form, etc., from those that are logged in. The thing is the
form is in its own method in a seperate file, and its called within HTML
code so obviously if I included session_start() in the seperate include file
where the methods/classes are, etc., I'd get a headers already sent error.
So is there a solution to this?

Thanks.
---End Message---
---BeginMessage---
OK I guess it's somehow like this ..

form
?php
if (isset($_POST['submit'])) {
include('sessions.php');
// include sessions.php
}
?
!-- form innerhtml --
/form

now this of course is something very bad to do and it wont work.
One way to prevent markup from being outputted is using ob_buffer() [1]

EXAMPLE:
?php
$form = FORM
form
!-- form inner xml --
/form
FORM;
ob_start();
echo $form;
$output_buffer = ob_get_contents();
ob_end_clean();
var_dump(nl2br(htmlentities($output_buffer)));
?

So what we do here is simply start the output buffer befor echoing $form.
ob_get_contents() returns the outputbuffer as it is right now.
By calling ob_end_clean() buffering is stopped and the buffer cache released.
Still keep in mind that headers will still be sent when buffering the output.

here is a more complex
EXAMPLE:
?php
ob_start(); // starting the output buffer
?
html
body
!-- inner xml --
{{replace_me}}
/body
/html
?php
$output_buffer = ob_get_contents();
ob_end_clean();
session_start();
$_SESSION['test'] = time();
echo str_replace('{{replace_me}}', 'pThis is the replaced string.br
/SESSION[test] was set to: '.$_SESSION['test'].'/p',
$output_buffer);
?

Now we start the output buffer at the beginning of the script and the
session at the end.
It does not matter whether we close the PHP tag after starting the
ob_buffer. ( like with ? )
As long as we do not flush_end or clean_end the output buffering
process it will continue caching the output (except headers).
So session_start should work after actually outputting markup.

Another method could be like we did above the str_replace() [2] ...

EXAMPLE:
?php
$some_number = time();
$html = HTML
html
body
pTime: $some_number/p
p{{replace_me}}/p
/body
/html
HTML;
echo str_replace('{{replace_me}}', 'This string was changed by PHP', $html);
?

There is still plenty of other possible solutions. Keep on rocking

[1] http://in.php.net/manual/en/ref.outcontrol.php
[2] http://in.php.net/manual/en/function.str-replace.php

//A yeti
---End Message---
---BeginMessage---
Hi,

I can't really understand that. Not sure if you understand my problem
properly (if I've not explained properly). Anyone can give me some solutions
please?

Thanks.

2008/10/31 Yeti [EMAIL PROTECTED]

 OK I guess it's somehow like this ..

 form
 ?php
 if (isset($_POST['submit'])) {
 include('sessions.php');
 // include sessions.php
 }
 ?
 !-- form innerhtml --
 /form

 now this of course is something very bad to do and it wont work.
 One way to prevent markup from being outputted is using ob_buffer() [1]

 EXAMPLE:
 ?php
 $form = FORM
 form
 !-- form inner xml --
 /form
 FORM;
 ob_start();
 echo $form;
 $output_buffer = ob_get_contents();
 ob_end_clean();
 var_dump(nl2br(htmlentities($output_buffer)));
 ?

 So what we do here is simply start the output buffer befor echoing $form.
 ob_get_contents() returns the outputbuffer as it is right now.
 By calling ob_end_clean() buffering is stopped and the buffer cache
 released.
 Still keep in mind that headers will still be sent when buffering the
 output.

 here is a more complex
 

Re: [PHP] Invalid byte sequence for encoding UTF-8

2008-10-31 Thread Lester Caine

paragasu wrote:

i am using php with postgresql. when i submit post query to the
server. i have the pg_exec error
snip
Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid
byte sequence for encoding UTF8: 0x93 HINT: This error can also
happen if the byte sequence does not match the encoding expected by
the server, which is controlled by client_encoding.
/snip
is there any function to prevent this type of error. something i can
apply to any POST query
before i submit to pg_query() ?


You probably need to tell us which functions you are using to create/modify 
the UTF8 string that you are sending as data. I does sound like a conversion 
TO UTF8 is not being carried out somewhere. PHP5 requires that only multi-byte 
string functions are used to handle UTF8 data


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] Sessions in object oriented code

2008-10-31 Thread Yeti
 I can't really understand that. Not sure if you understand my problem
 properly (if I've not explained properly). Anyone can give me some solutions
 please?
Well as long as you don not provide any code it's all just wild guesses.
What I tried was to show you a way of simply preventing the HTML from
being sent to the browser before you include the session and/or cookie
file. So you would just have to add the output buffering syntax to
your existing code without changing all the scripts.

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



[PHP] Re: DOCTYPE, javascript and Firefox

2008-10-31 Thread Ross McKay
On Thu, 30 Oct 2008 15:45:55 +0200, Arno Kuhl wrote:

[...]
This code works fine in IE, Opera and Chrome, but gives a javascript error
in FF when I click the radio button: autostartlabel is not defined.
However if I comment out the DOCTYPE line in the header it works fine in all
browsers including FF. (Took ages to narrow it down to the DOCTYPE.) Does
anyone know why, and how to fix it?

You aren't doing it the DOM way, and telling FF3 to use HTML 4.01 (or
XHTML) means you should be doing it the DOM way. IE, Opera and Chrome
are being lax; FF isn't.

input type='radio' name='autostart' value='0'
 onclick=document.getElementById('autostartlabel').className='disable';
 document.getElementById('startdate').disabled=true; No
input type='radio' name='autostart' value='1'
 onclick=document.getElementById('autostartlabel').className='normal';
 document.getElementById('startdate').disabled=false; Yes
label id='autostartlabel'Startdate/label
input type='text' name='startdate' id='startdate' disabled='disabled' 

Better would be to throw the actions into a function, e.g.

script type=text/javascript
function setStartDateDisabled(asDisabled) {
var autostartlabel = document.getElementById('autostartlabel');
if (autostartlabel)
autostartlabel.className = asDisabled ? 'disable' : 'normal';

var startdate = document.getElementById('startdate');
if (startdate)
startdate.disabled = asDisabled;
}
/script

input type='radio' name='autostart' id='autostart_0' value='0'
 onclick=setStartDateDisabled(true); No
input type='radio' name='autostart' id='autostart_1' value='1'
 onclick=setStartDateDisabled(false); Yes

PS: pick HTML4 or XHTML; your sample code shows the latter, the DOCTYPE
says the former.
--  
Ross McKay, Toronto, NSW Australia
The lawn could stand another mowing; funny, I don't even care
- Elvis Costello

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



Re: [PHP] Mailing lists

2008-10-31 Thread Richard Heyes
  It depends on what english your are using, isn't it ?

Well I suppose there's real English, and then American English.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

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



Re: [PHP] Mailing lists

2008-10-31 Thread Richard Heyes
 Hmmpff.. I'll try and remember... there's a large divide between my desk
 and the rest of reality.

You could say about a lot of peoples desks... :-)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

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



RE: [PHP] DOCTYPE, javascript and Firefox

2008-10-31 Thread Arno Kuhl
-Original Message-
From: Andrew Ballard [mailto:[EMAIL PROTECTED] 
Sent: 30 October 2008 05:15 PM
To: [EMAIL PROTECTED]
Cc: PHP - General
Subject: Re: [PHP] DOCTYPE, javascript and Firefox

The pragmatic approach says that you've already fixed it: just leave
the DOCTYPE out. :-)

I'm not sure what yours should be, but based on the snippet of HTML
you posted, yours should not be HTML 4.01. Since you are closing the
input/ tags, you should probably be using one of the XHTML DOCTYPEs
(as long as the rest of your markup is consistent). I'm not sure that
would fix your issue, though.

As for why your page does that, I'm not really sure. If you leave the
DOCTYPE off the the browser will select the DOCTYPE it wants to use.
Perhaps since you declared the document to be HTML 4.01 Transitional,
Firefox is applying JavaScript rules where you can't refer to an
element in script simply using its ID attribute. You usually have to
use something like:

 document.getElementById('autostartlabel').className = 'disable';

Andrew

-- 

Hi Andrew and Ross, thanks a lot - using getElementById sorted it out. As
for the DOCTYPE the scripts aren't consistent enough yet to use one of the
XHTML DOCTYPEs, but it's work in progress. Maybe starting that process
caused the problem because I remember testing this successfully in FF, the
reason I persevered so long was I knew it once worked.

As a matter of interest is there a way to see what DOCTYPE the browser chose
to use? The browser is obviously smarter than I am in selecting DOCTYPEs so
maybe I should follow its cue.

Thanks to everyone else who kindly responded as well, I really appreciate
it.

Cheers
Arno


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



Re: [PHP] VAT number validation

2008-10-31 Thread Stut

On 31 Oct 2008, at 10:47, Koenraad Vanden Daele wrote:

Ther is a VAT number validation API.

http://isvat.appspot.com/

How to use this; integrate it in PHP to validate VAT-numbers without  
the

user experiencing anything?


Did you even have a go? Did you look at the PHP manual for clues as to  
how to make an HTTP request?


Lucky for you I've used this API before so I already had a snippet so  
I dug it out and knocked up an example: http://dev.stut.net/php/validatevat.php


Note that it's nowhere near production-quality code but it should give  
you a head start. Also note that this relies upon you having the  
allow_url_fopen configuration option enabled. If you don't then you  
could do this with curl or raw sockets. Again the manual is your friend.


-Stut

--
http://stut.net/

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



Re: [PHP] Invalid byte sequence for encoding UTF-8

2008-10-31 Thread paragasu
i do not use any function other that addslashes on the $_POST

On 10/30/08, Lester Caine [EMAIL PROTECTED] wrote:
 paragasu wrote:
 i am using php with postgresql. when i submit post query to the
 server. i have the pg_exec error
 snip
 Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid
 byte sequence for encoding UTF8: 0x93 HINT: This error can also
 happen if the byte sequence does not match the encoding expected by
 the server, which is controlled by client_encoding.
 /snip
 is there any function to prevent this type of error. something i can
 apply to any POST query
 before i submit to pg_query() ?

 You probably need to tell us which functions you are using to create/modify
 the UTF8 string that you are sending as data. I does sound like a conversion
 TO UTF8 is not being carried out somewhere. PHP5 requires that only
 multi-byte
 string functions are used to handle UTF8 data

 --
 Lester Caine - G8HFL
 -
 Contact - http://lsces.co.uk/lsces/wiki/?page=contact
 L.S.Caine Electronic Services - http://lsces.co.uk
 EnquirySolve - http://enquirysolve.com/
 Model Engineers Digital Workshop - http://medw.co.uk//
 Firebird - http://www.firebirdsql.org/index.php

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



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



Re: [PHP] Mailing lists

2008-10-31 Thread Richard Heyes
 we wouldn't have had to improve
 it!  ;-P

Improuve? Thaut's nout whaut Iu'd caull iut...

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

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



[PHP] VAT number validation

2008-10-31 Thread Koenraad Vanden Daele
Ther is a VAT number validation API.

http://isvat.appspot.com/

How to use this; integrate it in PHP to validate VAT-numbers without the 
user experiencing anything?





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



[PHP] Reg Ex

2008-10-31 Thread Kyle Terry
I'm horrible with regular expression. I need to match the text before a file
extension. So if the file is called US.123.kyle.20081029.zip, I would then
need to match US.123.kyle.20081029.

Thanks!

-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] Reg Ex

2008-10-31 Thread Stut

On 31 Oct 2008, at 12:27, Kyle Terry wrote:
I'm horrible with regular expression. I need to match the text  
before a file
extension. So if the file is called US.123.kyle.20081029.zip, I  
would then

need to match US.123.kyle.20081029.


No regex required. Why do people think everything like this needs a  
regex??


  http://php.net/pathinfo

-Stut

--
http://stut.net/

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



Re: [PHP] Reg Ex

2008-10-31 Thread Kyle Terry
I thought of a couple other ways anyway...

basename($file, '.zip')
substr($file, 0, -4)

On Fri, Oct 31, 2008 at 5:33 AM, Stut [EMAIL PROTECTED] wrote:

 On 31 Oct 2008, at 12:27, Kyle Terry wrote:

 I'm horrible with regular expression. I need to match the text before a
 file
 extension. So if the file is called US.123.kyle.20081029.zip, I would then
 need to match US.123.kyle.20081029.


 No regex required. Why do people think everything like this needs a regex??

  http://php.net/pathinfo

 -Stut

 --
 http://stut.net/




-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] Reg Ex

2008-10-31 Thread Eric Butera
On Fri, Oct 31, 2008 at 8:41 AM, Kyle Terry [EMAIL PROTECTED] wrote:
 I thought of a couple other ways anyway...

 basename($file, '.zip')
 substr($file, 0, -4)

 On Fri, Oct 31, 2008 at 5:33 AM, Stut [EMAIL PROTECTED] wrote:

 On 31 Oct 2008, at 12:27, Kyle Terry wrote:

 I'm horrible with regular expression. I need to match the text before a
 file
 extension. So if the file is called US.123.kyle.20081029.zip, I would then
 need to match US.123.kyle.20081029.


 No regex required. Why do people think everything like this needs a regex??

  http://php.net/pathinfo

 -Stut

 --
 http://stut.net/




 --
 Kyle Terry | www.kyleterry.com


Who says every file will have an extension?  Who says they're all .+3
chars?  When I first started php I tried that and it failed in a lot
of places.

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



Re: [PHP] Reg Ex

2008-10-31 Thread Warren Windvogel

Eric Butera wrote:

Who says every file will have an extension?  Who says they're all .+3
chars?  When I first started php I tried that and it failed in a lot
of places.


I've also run into that problem in the past. The way that I could work 
around all these issues was to document naming conventions for the files 
and validate these before using the regex to obtain the necessary 
information.


Regards
Warren

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



Re: [PHP] Reg Ex

2008-10-31 Thread Eric Butera
On Fri, Oct 31, 2008 at 9:09 AM, Warren Windvogel
[EMAIL PROTECTED] wrote:
 Eric Butera wrote:

 Who says every file will have an extension?  Who says they're all .+3
 chars?  When I first started php I tried that and it failed in a lot
 of places.

 I've also run into that problem in the past. The way that I could work
 around all these issues was to document naming conventions for the files and
 validate these before using the regex to obtain the necessary information.

 Regards
 Warren


...or you could just use pathinfo and be done with it.  I work for
clients.  Clients shouldn't have to read a faq to upload a file.

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



Re: [PHP] Reg Ex

2008-10-31 Thread Daniel P. Brown
On Fri, Oct 31, 2008 at 7:44 AM, Eric Butera [EMAIL PROTECTED] wrote:

 Who says every file will have an extension?  Who says they're all .+3
 chars?  When I first started php I tried that and it failed in a lot
 of places.

.htaccess is a prime example of this.

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Ask me about our current hosting/dedicated server deals!

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



Re: [PHP] Mailing lists

2008-10-31 Thread Daniel P. Brown
On Fri, Oct 31, 2008 at 4:06 AM, Richard Heyes [EMAIL PROTECTED] wrote:

 Improuve? Thaut's nout whaut Iu'd caull iut...

And while we're on the subject, who gave that Canadian the right
to say anything about OUR English down here?  We drop the 'U', but
they replace it with another 'O' in speech!  It's aboot time yoo folks
spoke properly, Cummings!  ;-P

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Ask me about our current hosting/dedicated server deals!

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



Re: [PHP] Reg Ex

2008-10-31 Thread Jochem Maas
Eric Butera schreef:
 On Fri, Oct 31, 2008 at 9:09 AM, Warren Windvogel
 [EMAIL PROTECTED] wrote:
 Eric Butera wrote:
 Who says every file will have an extension?  Who says they're all .+3
 chars?  When I first started php I tried that and it failed in a lot
 of places.
 I've also run into that problem in the past. The way that I could work
 around all these issues was to document naming conventions for the files and
 validate these before using the regex to obtain the necessary information.

 Regards
 Warren

 
 ...or you could just use pathinfo and be done with it.  I work for
 clients.  Clients shouldn't have to read a faq to upload a file.

no. they generally believe that when they upload a CSV file in a field
very clearly marked upload your FLASH file here things should just work :-)

 


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



Re: [PHP] Mailing lists

2008-10-31 Thread Dan Joseph
On Fri, Oct 31, 2008 at 10:02 AM, Daniel P. Brown [EMAIL PROTECTED]
 wrote:

 On Fri, Oct 31, 2008 at 4:06 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 
  Improuve? Thaut's nout whaut Iu'd caull iut...

 And while we're on the subject, who gave that Canadian the right
 to say anything about OUR English down here?  We drop the 'U', but
 they replace it with another 'O' in speech!  It's aboot time yoo folks
 spoke properly, Cummings!  ;-P


Shouldn't that be proopley, eh?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Reg Ex

2008-10-31 Thread Eric Butera
On Fri, Oct 31, 2008 at 10:03 AM, Jochem Maas [EMAIL PROTECTED] wrote:
 Eric Butera schreef:
 On Fri, Oct 31, 2008 at 9:09 AM, Warren Windvogel
 [EMAIL PROTECTED] wrote:
 Eric Butera wrote:
 Who says every file will have an extension?  Who says they're all .+3
 chars?  When I first started php I tried that and it failed in a lot
 of places.
 I've also run into that problem in the past. The way that I could work
 around all these issues was to document naming conventions for the files and
 validate these before using the regex to obtain the necessary information.

 Regards
 Warren


 ...or you could just use pathinfo and be done with it.  I work for
 clients.  Clients shouldn't have to read a faq to upload a file.

 no. they generally believe that when they upload a CSV file in a field
 very clearly marked upload your FLASH file here things should just work :-)





:D

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



RE: [PHP] Reg Ex

2008-10-31 Thread Boyd, Todd M.
 -Original Message-
 From: Kyle Terry [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 31, 2008 7:28 AM
 To: PHP General Mailing List
 Subject: [PHP] Reg Ex
 
 I'm horrible with regular expression. I need to match the text before
a
 file
 extension. So if the file is called US.123.kyle.20081029.zip, I would
 then
 need to match US.123.kyle.20081029.

Someone suggested pathinfo() already... and brought up the issues of
extensions  3 chars and files with no basename (i.e., .htaccess)...

Checked out www.php.net/pathinfo, and ran a demo on my own machine. I
can't test the .htaccess problem, since I'm running Windows (and M$
won't let you have files that start with .), but I tested it with
a.b.c.d and the extension was returned as d. Basename was a.b.c.

Sounds like it will do exactly what you are trying to accomplish. For
what it's worth, if I were to do it with a regular expression, I would
use:

$filename = us.123.kyle.20081029.zip;
preg_match('/(.*)\..*$/', $filename, $match);

Check out www.regular-expressions.info ... the only excuse you can have
for not knowing is that you haven't tried to learn yet. ;)

HTH,


Todd Boyd
Web Programmer




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



Re: [PHP] Reg Ex

2008-10-31 Thread Kyle Terry
Thanks for the reply. For now I used substr($filename,0,-4) and that worked
perfectly. I need to learn reg ex badly :(.

On Fri, Oct 31, 2008 at 7:51 AM, Boyd, Todd M. [EMAIL PROTECTED] wrote:

  -Original Message-
  From: Kyle Terry [mailto:[EMAIL PROTECTED]
  Sent: Friday, October 31, 2008 7:28 AM
  To: PHP General Mailing List
  Subject: [PHP] Reg Ex
 
  I'm horrible with regular expression. I need to match the text before
 a
  file
  extension. So if the file is called US.123.kyle.20081029.zip, I would
  then
  need to match US.123.kyle.20081029.

 Someone suggested pathinfo() already... and brought up the issues of
 extensions  3 chars and files with no basename (i.e., .htaccess)...

 Checked out www.php.net/pathinfo, and ran a demo on my own machine. I
 can't test the .htaccess problem, since I'm running Windows (and M$
 won't let you have files that start with .), but I tested it with
 a.b.c.d and the extension was returned as d. Basename was a.b.c.

 Sounds like it will do exactly what you are trying to accomplish. For
 what it's worth, if I were to do it with a regular expression, I would
 use:

 $filename = us.123.kyle.20081029.zip;
 preg_match('/(.*)\..*$/', $filename, $match);

 Check out www.regular-expressions.info ... the only excuse you can have
 for not knowing is that you haven't tried to learn yet. ;)

 HTH,


 Todd Boyd
 Web Programmer






-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] Reg Ex

2008-10-31 Thread Daniel P. Brown
On Fri, Oct 31, 2008 at 9:53 AM, Kyle Terry [EMAIL PROTECTED] wrote:
 Thanks for the reply. For now I used substr($filename,0,-4) and that worked
 perfectly. I need to learn reg ex badly :(.

Before you do that, learn to read and follow along in an email
thread that you start.  We gave you perfect pointers as to (a) why
regexp's aren't needed in this case; and (b) how to better handle it.

Your substr() routine won't work as expected in all cases.
Imagine either an .htaccess file or an extensionless file named
`quagmire`.  You'll come up with `cess` and `mire`, respectively.

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Ask me about our current hosting/dedicated server deals!

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



[PHP] Yahoo/Gmail/Hotmail Contacts API

2008-10-31 Thread Feris
Hi All,
I noticed that social networking sites can retrieve our contacts using an
authenticated session. Is there any open source PHP API to achieve the same
thing ?

Thanks,

Feris


[PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Alice Wei

Hi, 

  I have a code snippet here as follows:

  $message=1|2|3|4|5;
  $stringChunks = explode(|, $message);

  Is it possible to find out the number of elements in this string? It seems 
that I could do things like print_r and find out what is the last element of 
$stringChunks is, but is there a way where I can use code from the two lines 
and have it print out 5 as the number of elements that contains after the 
splitting? 

   Or, am I on the wrong direction here?

Thanks in advance.

Alice
_
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Fwd: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Kyle Terry
-- Forwarded message --
From: Kyle Terry [EMAIL PROTECTED]
Date: Fri, Oct 31, 2008 at 9:31 AM
Subject: Re: [PHP] Count the Number of Elements Using Explode
To: Alice Wei [EMAIL PROTECTED]


I would use http://us2.php.net/manual/en/function.array-count-values.php


On Fri, Oct 31, 2008 at 9:29 AM, Alice Wei [EMAIL PROTECTED] wrote:


 Hi,

  I have a code snippet here as follows:

  $message=1|2|3|4|5;
  $stringChunks = explode(|, $message);

  Is it possible to find out the number of elements in this string? It seems
 that I could do things like print_r and find out what is the last element of
 $stringChunks is, but is there a way where I can use code from the two lines
 and have it print out 5 as the number of elements that contains after the
 splitting?

   Or, am I on the wrong direction here?

 Thanks in advance.

 Alice
 _
 Check the weather nationwide with MSN Search: Try it now!
 http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Kyle Terry | www.kyleterry.com



-- 
Kyle Terry | www.kyleterry.com


Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Daniel Brown
On Fri, Oct 31, 2008 at 11:29 AM, Alice Wei [EMAIL PROTECTED] wrote:

 Hi,

  I have a code snippet here as follows:

  $message=1|2|3|4|5;
  $stringChunks = explode(|, $message);

  Is it possible to find out the number of elements in this string? It seems 
 that I could do things like print_r and find out what is the last element of 
 $stringChunks is, but is there a way where I can use code from the two lines 
 and have it print out 5 as the number of elements that contains after the 
 splitting?

http://php.net/strlen
http://php.net/count

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Ask me about our current hosting/dedicated server deals!

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



Re: [PHP] Mailing lists

2008-10-31 Thread Robert Cummings
On Fri, 2008-10-31 at 09:02 -0500, Daniel P. Brown wrote:
 On Fri, Oct 31, 2008 at 4:06 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 
  Improuve? Thaut's nout whaut Iu'd caull iut...
 
 And while we're on the subject, who gave that Canadian the right
 to say anything about OUR English down here?  We drop the 'U', but
 they replace it with another 'O' in speech!  It's aboot time yoo folks
 spoke properly, Cummings!  ;-P

I think you're confusing us witht he Scotts.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Diogo Neves
Hi Alice,

U can simple do:
$nr = ( strlen( $message ) / 2 ) + 1 );
$nr = count( explode( '|', $message );

On Fri, Oct 31, 2008 at 4:32 PM, Daniel Brown [EMAIL PROTECTED] wrote:

 On Fri, Oct 31, 2008 at 11:29 AM, Alice Wei [EMAIL PROTECTED] wrote:
 
  Hi,
 
   I have a code snippet here as follows:
 
   $message=1|2|3|4|5;
   $stringChunks = explode(|, $message);
 
   Is it possible to find out the number of elements in this string? It
 seems that I could do things like print_r and find out what is the last
 element of $stringChunks is, but is there a way where I can use code from
 the two lines and have it print out 5 as the number of elements that
 contains after the splitting?

 http://php.net/strlen
http://php.net/count

 --
 /Daniel P. Brown
 http://www.parasane.net/
 [EMAIL PROTECTED] || [EMAIL PROTECTED]
 Ask me about our current hosting/dedicated server deals!

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


-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


Re: [PHP] Yahoo/Gmail/Hotmail Contacts API

2008-10-31 Thread Nitsan Bin-Nun
I would suggest trying Manuel's website (phpclasses).

HTH,
Nitsan

On Fri, Oct 31, 2008 at 6:25 PM, Feris [EMAIL PROTECTED] wrote:

 Hi All,
 I noticed that social networking sites can retrieve our contacts using an
 authenticated session. Is there any open source PHP API to achieve the same
 thing ?

 Thanks,

 Feris



Re: [PHP] Reg Ex

2008-10-31 Thread Diogo Neves
Hi all,

It depends on what he really want, but pathinfo really is a better option

My test worked perfectly on files with no extension and without name...

?php
var_dump( pathinfo( '.htaccess' ));
var_dump( pathinfo( 'htaccess' ));
die( );
?

On Fri, Oct 31, 2008 at 2:57 PM, Daniel P. Brown
[EMAIL PROTECTED]wrote:

 On Fri, Oct 31, 2008 at 9:53 AM, Kyle Terry [EMAIL PROTECTED] wrote:
  Thanks for the reply. For now I used substr($filename,0,-4) and that
 worked
  perfectly. I need to learn reg ex badly :(.

 Before you do that, learn to read and follow along in an email
 thread that you start.  We gave you perfect pointers as to (a) why
 regexp's aren't needed in this case; and (b) how to better handle it.

Your substr() routine won't work as expected in all cases.
 Imagine either an .htaccess file or an extensionless file named
 `quagmire`.  You'll come up with `cess` and `mire`, respectively.

 --
 /Daniel P. Brown
 http://www.parasane.net/
 [EMAIL PROTECTED] || [EMAIL PROTECTED]
 Ask me about our current hosting/dedicated server deals!

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



-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


RE: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Alice Wei

Hi,

  Thanks for all who responded, and the function is now working properly. 
  It turned out that count function works for strings that contain the actual 
data inside, but when it is an empty string, a new if clause had to be set to 
create the count. 

Alice




Alice Wei

Indiana University, MIS 2008


Programmer/Computer Application
Developer 
ProCure Treatment Centers, Inc.
420 N. Walnut St.
Bloomington, IN 47404

812-330-6644 (office)
812-219-5708 (mobile)

[EMAIL PROTECTED](email)
http://www.procurecenters.com/index.php (web) 




 Date: Fri, 31 Oct 2008 17:00:44 +
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 CC: [EMAIL PROTECTED]; php-general@lists.php.net
 Subject: Re: [PHP] Count the Number of Elements Using Explode
 
 Hi Alice,
 
 U can simple do:
 $nr = ( strlen( $message ) / 2 ) + 1 );
 $nr = count( explode( '|', $message );
 
 On Fri, Oct 31, 2008 at 4:32 PM, Daniel Brown  wrote:
 
 On Fri, Oct 31, 2008 at 11:29 AM, Alice Wei  wrote:

 Hi,

  I have a code snippet here as follows:

  $message=1|2|3|4|5;
  $stringChunks = explode(|, $message);

  Is it possible to find out the number of elements in this string? It
 seems that I could do things like print_r and find out what is the last
 element of $stringChunks is, but is there a way where I can use code from
 the two lines and have it print out 5 as the number of elements that
 contains after the splitting?

 http://php.net/strlen
http://php.net/count

 --
 
 http://www.parasane.net/
 [EMAIL PROTECTED] || [EMAIL PROTECTED]
 Ask me about our current hosting/dedicated server deals!

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


 -- 
 Thanks,
 
 Diogo Neves
 Web Developer @ SAPO.pt by PrimeIT.pt

_
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Matthew Powell

Diogo Neves wrote:

Hi Alice,

U can simple do:
$nr = ( strlen( $message ) / 2 ) + 1 );
$nr = count( explode( '|', $message );


Or...

$num = (substr_count($message, |) + 1);

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



Re: [PHP] Sessions in object oriented code

2008-10-31 Thread Diogo Neves
Well, without code is dificult to say, but session_start() don't send
headers, then possible u have a space after a ? or @ least this is the
common error...

On Thu, Oct 30, 2008 at 11:47 PM, Ben Stones [EMAIL PROTECTED]wrote:

 Hi,

 Hope I can explain this as easily as possible, basically I am using both
 cookies and sessions for my script, whereby the user is allowed to choose
 which method they want to login with. Problem for me is removing the
 registration form, etc., from those that are logged in. The thing is the
 form is in its own method in a seperate file, and its called within HTML
 code so obviously if I included session_start() in the seperate include
 file
 where the methods/classes are, etc., I'd get a headers already sent
 error.
 So is there a solution to this?

 Thanks.


-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


Re: Fwd: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Maciek Sokolewicz

Kyle Terry wrote:

-- Forwarded message --
From: Kyle Terry [EMAIL PROTECTED]
Date: Fri, Oct 31, 2008 at 9:31 AM
Subject: Re: [PHP] Count the Number of Elements Using Explode
To: Alice Wei [EMAIL PROTECTED]


I would use http://us2.php.net/manual/en/function.array-count-values.php


On Fri, Oct 31, 2008 at 9:29 AM, Alice Wei [EMAIL PROTECTED] wrote:


Hi,

 I have a code snippet here as follows:

 $message=1|2|3|4|5;
 $stringChunks = explode(|, $message);

 Is it possible to find out the number of elements in this string? It seems
that I could do things like print_r and find out what is the last element of
$stringChunks is, but is there a way where I can use code from the two lines
and have it print out 5 as the number of elements that contains after the
splitting?

  Or, am I on the wrong direction here?

Thanks in advance.

Alice
_
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







First of all, don't top post, please.
Secondly, that won't do what the OP asked for. array_count_values 
returns an array which tells you how often each VALUE was found in that 
array. so: array_count_values(array(1,2,3,4,5)) will return: 
array(1=1,2=1,3=1,4=1,5=1). While what the OP wanted was: 
some_function(array(1,2,3,4,5)) to return 5 (as in the amount of values, 
not how often each value was found in the array).
count() would do it directly, and the other suggestions people gave do 
it indirectly, assuming that the values between '|' are never  1 char wide.


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



Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Stut

On 31 Oct 2008, at 17:32, Maciek Sokolewicz wrote:

Kyle Terry wrote:

-- Forwarded message --
From: Kyle Terry [EMAIL PROTECTED]
Date: Fri, Oct 31, 2008 at 9:31 AM
Subject: Re: [PHP] Count the Number of Elements Using Explode
To: Alice Wei [EMAIL PROTECTED]
I would use http://us2.php.net/manual/en/function.array-count-values.php
On Fri, Oct 31, 2008 at 9:29 AM, Alice Wei [EMAIL PROTECTED]  
wrote:

Hi,

I have a code snippet here as follows:

$message=1|2|3|4|5;
$stringChunks = explode(|, $message);

Is it possible to find out the number of elements in this string?  
It seems
that I could do things like print_r and find out what is the last  
element of
$stringChunks is, but is there a way where I can use code from the  
two lines
and have it print out 5 as the number of elements that contains  
after the

splitting?

 Or, am I on the wrong direction here?

Thanks in advance.

Alice
_
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




First of all, don't top post, please.
Secondly, that won't do what the OP asked for. array_count_values  
returns an array which tells you how often each VALUE was found in  
that array. so: array_count_values(array(1,2,3,4,5)) will return:  
array(1=1,2=1,3=1,4=1,5=1). While what the OP wanted was:  
some_function(array(1,2,3,4,5)) to return 5 (as in the amount of  
values, not how often each value was found in the array).
count() would do it directly, and the other suggestions people gave  
do it indirectly, assuming that the values between '|' are never  1  
char wide.


I think you'll find Kyle was suggesting that the OP use that function  
to count the |'s in the string. Add 1 to that and you have the number  
of elements explode will produce. More efficient if you're simply  
exploding it to count the elements, but count would be better if you  
need to explode them too.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: PreReq Index

2008-10-31 Thread Jochem Maas
Craige Leeder schreef:
 I forgot to mention, the calls to setPreReq() would occur in each file
 in place of an include() to get prerequisite components. IE:

try autoload()ing. what your trying to do is reinvent a wheel ...
and chances are yours will be less round.

 
 html.php :
 Ember::setPrereq( array('iOutput' = Ember::mciInterface) );
 
 class html implements iOutput {
 ...
 }
 
 
 iOutput.php:
 Ember::setPrereq( array('iIO' = Ember::mciInterface) );
 
 interface iOutput implements iIO {
 ...
 }
 
 iIO.php:
 interface iIO {
 }
 


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



Re: [PHP] Recursive Directory Listing

2008-10-31 Thread Joe Schaeffer
Thanks, all, for pointing me to the SPL iterators. i've been hunting
around and i've managed to come up with a working script. I know it
could be better, though. I know this is terribly inefficient -- a lot
of manual repetition and no recursion. Here's what I've got,
commenting my concerns:
?php
// start from the current directory
$dirs = new DirectoryIterator('./');
//open master ul
echo 'ul';
foreach ( $dirs as $dir )
{
// only get dirs, exclude . and ..
// seems like this should be a function...
if (($dir-isDir()) AND ($dir != '.') AND ($dir != '..'))
{   
// begin each qualifying dir with an li
echo 'li' . $dir;
// don't close the li, check again, one level deeper
// here's where i'm missing recursion, i think...
$subDirs = new DirectoryIterator('./' . $dir .'/'); 

if ($subDirs-valid())
{
// second verse, same as the first...
echo 'ul';
foreach ($subDirs as $subDir)
{
if (($subDir-isDir()) AND ($subDir != 
'.') AND ($subDir !='..'))
{
// i could manually add another 
level check, i guess...?
echo 'li'. $subDir . '/li';
}
}
// close second list
echo '/ul';
}
//close first-level item
echo '/li';   
}   
}
//close master ul
echo '/ul';
?

this will work for me, but it's bloated, i know. and it's rendering
unnecessary ul / in the code wherever there isn't a subdirectory (i
can't get a hasChildren() check to work properly. I'd appreciate any
feedback.

I've been referring to the SPL documentation in the manual off
php.net, and the examples at phpro.org. if there are any others out
there, i'd be happy to keep digging!











On 10/30/08, Jochem Maas [EMAIL PROTECTED] wrote:
 Joe Schaeffer schreef:

  Well, that makes things much easier (and that should teach me to rely
   on a 5-year-old O'Reilly book...)! Thanks for the help!
  
   I'm able to display all the contents of the correct dirs and subdirs,
   but I'm struggling with my implementation. Since I'm trying to nest
   unordered lists, I can't seem to 'catch' sub-directories to nest it
   within their parent li tags (and then close the corresponding ul
   when necessary. Before I spend time trying to figure out how to chain
   the iterators or mine the returned arrays, is it fair to ask if this
   approach is even possible?


 sure, RecursiveIteratorIterator or DirectoryTreeIterator both have
  a getDepth() method which might come in useful.

  alternatively you could subclass either and define the beginChildren() and
  endChildren() methods to output the open/close UL tags.

  have a hunt around here: http://www.php.net/~helly/php/ext/spl/


  
   Again, thanks for the point in the right direction!
  
  
  
   On Thu, Oct 30, 2008 at 1:30 PM, Jochem Maas [EMAIL PROTECTED] wrote:
   Joe Schaeffer schreef:
   New to PHP development, new to the list; searched the archives but
   didn't find an answer (or at least nothing i could successfully
   adapt).
  
   I have a (readable) directory structure like so:
  
   ../navigation
   /cats
   /dogs
   /beagles
   /collies
   /some/other/dirs/
   /horses
  
   I need to display those directories in nested html lists (marked up
   with css). Using PHP on the above, I'd like to produce the following
   HTML:
  
   ul
   licats/li
   lidogs
   ul
   libeagles/li
   licollies
   ullisome.../li/ul
   /li
   /ul
   /li
   lihorses/li
   /ul
  
   I'm able to display one level deep (cats, dogs, horses), but not nest
   the lists accordingly. Since this is for a navigation structure,
   obviously I'll have anchors in the li/li lines. They'll be
   formatted like so
   href=index.php?section=dogschapter=colliesverse=some .
  
   Some details about my environment:
   1) no files will be in the /navigation (or sub) dirs, but i'd
   (ideally) like to define a depth, to prevent 3-4 levels of
   navigation.
   2) I can successfully exclude dirs (. and .. and anything else I define)
   3) the actual PHP script probably won't be in the /navigation
   directory, so I'll need a defined starting path (ie, $root =
   /site/docs/includes/navigation/ or somesuch...).
   4) no database access (otherwise this whole contraption wouldn't be an 
 issue...)
  
   Any help is greatly appreciated, 

[PHP] Change tracking

2008-10-31 Thread Mike Smith
I'm about to try this, but I'd like some suggestions. I have a inventory
table that an employee can update specific fields if they are incorrect,
e.g.

[INVENTORY_TABLE]
fieldsexample data
part  1027P
serial543221-K
qty   120
location  G-5

I'd like to record what changed. Let's say they change the serial. One way
would be a static changes table:

[INVENTORY_CHANGES]
fields   example data
old_part   1027P
new_part  1027P
old_serial 543221-K
new_serial   543221-4
...

I'm thinking a better/more flexible solution would be

[INVENTORY_CHANGES]
inventory_id (FK to inventory table)
field (in this case it would be serial, detected by comparing POST values to
original values, but could be serial and qty/location)
original 543221-K
new_value 543221-4

Just curious as to other possible solutions or problems with these (probably
the second one).

Thanks,
Mike Smith


Re: [PHP] Change tracking

2008-10-31 Thread Stephen
-- On Fri, 10/31/08, Mike Smith [EMAIL PROTECTED] wrote:

 [INVENTORY_TABLE]
 fieldsexample data
 part  1027P
 serial543221-K
 qty   120
 location  G-5
 
 I'd like to record what changed. Let's say they
 change the serial. One way
 would be a static changes table:

Another way is to never change a record, but to add new ones. You also need to 
add an effectivity date field.

Stephen

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



Re: [PHP] Change tracking

2008-10-31 Thread Sam Stelfox
I've always used a version field (just an incrementing id) rather than
an effective date field. I can see the benefits of being able to look
back and see when the changes were made and if done correctly make it so
things don't change until a certain date. Hmmm nifty.

Stephen wrote:
 -- On Fri, 10/31/08, Mike Smith [EMAIL PROTECTED] wrote:

   
 [INVENTORY_TABLE]
 fieldsexample data
 part  1027P
 serial543221-K
 qty   120
 location  G-5

 I'd like to record what changed. Let's say they
 change the serial. One way
 would be a static changes table:
 

 Another way is to never change a record, but to add new ones. You also need 
 to add an effectivity date field.

 Stephen

   


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



Re: [PHP] Change tracking

2008-10-31 Thread Mike Smith
Thanks Steven/Tony for your replies. I'll consider this a bit more before I
jump in. I appreciate different perspectives. And I'll have to digest Tony's
solution.


Thanks,
Mike Smith


[PHP] Re: Change tracking

2008-10-31 Thread Tony Marston
Your proposed solution is far too inflexible. Take a look at 
http://www.tonymarston.net/php-mysql/auditlog.html which describes a design 
with incorporates a fixed set of audit tables which can deal with logging 
changes to any number of application tables with any structure.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org


Mike Smith [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm about to try this, but I'd like some suggestions. I have a inventory
 table that an employee can update specific fields if they are incorrect,
 e.g.

 [INVENTORY_TABLE]
 fieldsexample data
 part  1027P
 serial543221-K
 qty   120
 location  G-5

 I'd like to record what changed. Let's say they change the serial. One way
 would be a static changes table:

 [INVENTORY_CHANGES]
 fields   example data
 old_part   1027P
 new_part  1027P
 old_serial 543221-K
 new_serial   543221-4
 ...

 I'm thinking a better/more flexible solution would be

 [INVENTORY_CHANGES]
 inventory_id (FK to inventory table)
 field (in this case it would be serial, detected by comparing POST values 
 to
 original values, but could be serial and qty/location)
 original 543221-K
 new_value 543221-4

 Just curious as to other possible solutions or problems with these 
 (probably
 the second one).

 Thanks,
 Mike Smith
 



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



Re: [PHP] Re: PreReq Index

2008-10-31 Thread Craige Leeder
No can do. The files are stored in separate directories based on their 
usage/type. They're not all just in one directory.


Regards,
- Craige

Jochem Maas wrote:

try autoload()ing. what your trying to do is reinvent a wheel ...
and chances are yours will be less round.

  



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



Re: [PHP] Reg Ex

2008-10-31 Thread Warren Windvogel

Eric Butera wrote:

...or you could just use pathinfo and be done with it.  I work for
clients.  Clients shouldn't have to read a faq to upload a file.


I agree. I assumed that pathinfo simply returned the relative or 
absolute path of the file. After further inspection I have to stand 
corrected and agree that using pathinfo is the best approach. I should 
have probably done some more research when putting together my solution. 
Asking the list would've been an even better option ;-) .  Thats why 
there's no substitute for experience or better line of work because you 
learn something everyday. Thanks gentleman. Time for some refactoring.  :-D


Regards
Warren
//

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



Re: [PHP] Mailing lists

2008-10-31 Thread Shawn McKenzie
Robert Cummings wrote:
 On Fri, 2008-10-31 at 09:02 -0500, Daniel P. Brown wrote:
 On Fri, Oct 31, 2008 at 4:06 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 Improuve? Thaut's nout whaut Iu'd caull iut...
 And while we're on the subject, who gave that Canadian the right
 to say anything about OUR English down here?  We drop the 'U', but
 they replace it with another 'O' in speech!  It's aboot time yoo folks
 spoke properly, Cummings!  ;-P
 
 I think you're confusing us witht he Scotts.
 
 Cheers,
 Rob.

No doot aboot it.  No, he's not confused.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Recursive Directory Listing

2008-10-31 Thread Jim Lucas
Joe Schaeffer wrote:
 Thanks, all, for pointing me to the SPL iterators. i've been hunting
 around and i've managed to come up with a working script. I know it
 could be better, though. I know this is terribly inefficient -- a lot
 of manual repetition and no recursion. Here's what I've got,
 commenting my concerns:
 ?php
 // start from the current directory
 $dirs = new DirectoryIterator('./');
 //open master ul
 echo 'ul';
 foreach ( $dirs as $dir )
 {
   // only get dirs, exclude . and ..
   // seems like this should be a function...
   if (($dir-isDir()) AND ($dir != '.') AND ($dir != '..'))
   {   
   // begin each qualifying dir with an li
   echo 'li' . $dir;
   // don't close the li, check again, one level deeper
   // here's where i'm missing recursion, i think...
   $subDirs = new DirectoryIterator('./' . $dir .'/'); 
 
   if ($subDirs-valid())
   {
   // second verse, same as the first...
   echo 'ul';
   foreach ($subDirs as $subDir)
   {
   if (($subDir-isDir()) AND ($subDir != 
 '.') AND ($subDir !='..'))
   {
   // i could manually add another 
 level check, i guess...?
   echo 'li'. $subDir . '/li';
   }
   }
   // close second list
   echo '/ul';
   }
   //close first-level item
   echo '/li';   
   }   
 }
 //close master ul
 echo '/ul';
 ?
 
 this will work for me, but it's bloated, i know. and it's rendering
 unnecessary ul / in the code wherever there isn't a subdirectory (i
 can't get a hasChildren() check to work properly. I'd appreciate any
 feedback.
 
 I've been referring to the SPL documentation in the manual off
 php.net, and the examples at phpro.org. if there are any others out
 there, i'd be happy to keep digging!
 

Joe,

Here is a simplified recursive version of your above statement.

?php

$dir = '.';

function displayDir($dir='.') {

$show = FALSE;

$results = glob($dir.'/*');

foreach ( $results AS $entry ) {
if ( is_dir($entry)  !in_array($entry, array('.', '..')) ) {
$dirs[] = $entry;
$show = TRUE;
}
}

if ( $show ) {
echo 'ul';
foreach ( $dirs AS $entry ) {
echo 'li', basename($entry);
displayDir($entry);
echo '/li';
}
echo '/ul';
}
}

displayDir($dir);

?

Hope this helps
-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Fwd: [PHP] Bitwise operation giving wrong results

2008-10-31 Thread sean greenslade
-- Forwarded message --
From: sean greenslade [EMAIL PROTECTED]
Date: Fri, Oct 31, 2008 at 11:22 PM
Subject: Re: [PHP] Bitwise operation giving wrong results
To: Yeti [EMAIL PROTECTED]


Cool, thanks. It worked. I didn't know you typeset PHP like that.


On Thu, Oct 30, 2008 at 3:42 AM, Yeti [EMAIL PROTECTED] wrote:

 Usually in PHP one does not take much care about the data types, but
 in this case you absoloodle have to.
 If you use bit operators on a character then its ascii number will be
 taken instead (how should a number based operation work with a
 string?)

 also if you pass on $_GET params directly into ay bitwise operation
 you might get some un-nice behaviour. So check them first.

 ?php
 $a = $b = false;
 if (is_numeric($_GET['b'].$_GET['a'])) {
$a = (int)$_GET['a'];
$b = (int)$_GET['b'];
echo $a  $b;
 }
 ?




-- 
--Zootboy



-- 
--Zootboy