php-windows Digest 5 Feb 2003 07:39:16 -0000 Issue 1573

Topics (messages 18355 through 18361):

Re: script not allowing login after generating new password
        18355 by: Svensson, B.A.T. (HKG)

remind me of a function...
        18356 by: krizz

Re:Subject: Difficult String/number fomatation plz hlp!
        18357 by: Neil Smith

code change in new version?
        18358 by: paradiddles
        18360 by: Pat Johnston

Re: Difficult String/number fomatation plz hlp!
        18359 by: Martin Ramsch

MSQL
        18361 by: Kobus Myburgh

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]


----------------------------------------------------------------------
--- Begin Message ---
> From: Beach, Jim 

> In hind-sight it was painfully obvious. I have a lot to learn about
> testing and debugging!

We all do. 

There is an entire, thick, book (a classical work) called "software
testing" or just "testing",  don't really remember any more, by, hmm,
I seams to have forgotten that to :), Brezesinki maybe? That deals with
the procedures around testing software. So it is defnitly not any
"learn over the coffe break" or "20 steps to sucess" thing to learn.

Nowadays I guess there are a lot of more books on the market, but
this one was the first to seriously cover this topic (read: software
engineering related problem child).

Testing is supposed to be a formal automated procedure, which
unfortunately is not true all the time. With debugging on the
other hand, we got a slightly different story. It is a combination
of skills and luck (intuition), which comes with experience. In
short; it is a pure creative activity.

Testing (which could be made formal) is a activity in order to
minimize the dependency of being reliable on the lucky-part to
do successfully debugging. However testing wont tell you were
the bug is (it can be absolutely somewhere else), it just give
an indication on what kind of direction you first might want
to look into.

Anyhow, good luck (you need it for debugging:) in your progress.

--- End Message ---
--- Begin Message ---
can you remind me, of a function I show once, that opens another's site
files and returns part of it so it be placed in yours. Like an always update
service for the original site. Like news tags and stuff...


--- End Message ---
--- Begin Message --- Try split() function which splits a string into an array based on a regular expression (PP manual) : this is different than explode() which splits on a fixed delimiter.

eg (this is in the manual ):
$stringparts=split ('[,-]', $string);

Will split $string= "1,3, 3-6, 8" into individual array elements. Don't forget to remove spaces from the input first, str_replace(" ","",$string) or add spaces as a non-separator to your regex.

Then use array_unique(array,array) to remove duplicates. Don't you just *love* PHP :-)

Finally recombine the array in your desired format (I have no idea what rules the 'correct form' takes - you have to write that yourself :-)

Cheers,
Neil Smith.


At 15:15 04/02/2003 +0000, Bobo wrote:
Message-ID: <000901c2cc35$23fbe940$9df81e0a@elstudion>
From: "Bobo Wieland" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Tue, 4 Feb 2003 11:06:37 +0100
MIME-Version: 1.0
Content-Type: text/plain;
        charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Subject: Difficult String/number fomatation plz hlp!

Hi!

I have a textfield wich allows any number of integers seperated with " ",
"," or "-"...

I need this input to be formated in two steps:
First into a sequence of numbers into an array, lowest first... Second to
the correct form of the initial input...

Example:

User input: "1,3, 3-6, 8" (string)
First step: 1,3,4,5,6,8 (array)
second step: "1,3-6,8" (string)

please help me with this one! I don't mind using ereg-functions though I'm
not good at it myself...

--- End Message ---
--- Begin Message ---
Hey everyone!

I noticed that in the older version of php (when register globals was 'on' by default) 
that coding for 'post' variables (where info is passed from the form into the 
variables) took an easier approach ...ie. 

$totalqty = $tireqty + $oilqty + $sparkqty; (old way)

$HTTP_POST_VARS["tireqty"] + $HTTP_POST_VAR["oilqty"] + HTTP_POST_VARS["sparkqty"];  
(new way)

2 questions:

1.) Is there a shorter way to code this stuff now?

 2.) Do I need to change the way I code for everything now, or do the changes only 
apply to retrieveing form variables?

thanks-



----------------
"forget your lust for the rich man's gold. All that you need, is in your soul. You can 
do this if you try. All that I want for you my son, is to be satisfied"

  ~ Lynard Skynard



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--- End Message ---
--- Begin Message ---
There was a thread on the list regarding this. Do a search here for
'register globals on and off'. That thread should help you..

Regards


"Paradiddles" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> Hey everyone!
>
> I noticed that in the older version of php (when register globals was 'on'
by default) that coding for 'post' variables (where info is passed from the
form into the variables) took an easier approach ...ie.
>
> $totalqty = $tireqty + $oilqty + $sparkqty; (old way)
>
> $HTTP_POST_VARS["tireqty"] + $HTTP_POST_VAR["oilqty"] +
HTTP_POST_VARS["sparkqty"];  (new way)
>
> 2 questions:
>
> 1.) Is there a shorter way to code this stuff now?
>
>  2.) Do I need to change the way I code for everything now, or do the
changes only apply to retrieveing form variables?
>
> thanks-
>
>
>
> ----------------
> "forget your lust for the rich man's gold. All that you need, is in your
soul. You can do this if you try. All that I want for you my son, is to be
satisfied"
>
>   ~ Lynard Skynard
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now


--- End Message ---
--- Begin Message ---
Bobo Wieland <[EMAIL PROTECTED]> wrote:

> I have a textfield wich allows any number of integers seperated with
> " ", "," or "-"...
> 
> I need this input to be formated in two steps:
> First into a sequence of numbers into an array, lowest first...
> Second to the correct form of the initial input...
> 
> Example:
> 
> User input: "1,3, 3-6, 8" (string)
> First step: 1,3,4,5,6,8 (array)
> second step: "1,3-6,8" (string)

There are many ways to do this (as always :) ...

Do you really need the fully expanded array in step one, considering
it might get quite big?

Anyway, you can easily replace input ranges by expanded enumerations
with preg_replace:

  $input = preg_replace('= (\d+) \s* - \s* (\d+) =ex',
                        'implode(",", range($1,$2))',
                        $input);

>From there, next step is to transform this list of numbers into an array
and normalize it, eliminating duplicates and sorting.
If you're really dealing with integers only, a funny and efficient way
to eliminate duplicates is to flip the array, because any array key can
exist only once:

  $keys = array_keys( array_flip( split('[ ,]+', $input) ) );
  sort($keys);

For the second step, merging consecutive numbers into a range, just do
what you would do with paper and pencil:  start with first number,
step to next one and look, if it belongs to the previous range or starts
a new one.  Write a dash only for real ranges with more than a single
number:

  $start = $old = $keys[0]; $output = "$start";
  foreach($keys as $value) {
     if ($value > $old+1) // new range begins
     {
        if ($old<>$start) { $output .= "-$old"; }
        $start = $value; $output .= ",$start";
     }
     $old = $value;
  }
  if ($old<>$start) { $output .= "-$old"; }

HTH,
  Martin

--- End Message ---
--- Begin Message ---
Hi,

I am running PHP 4.2.3 on Windows XP, and for some reason, even though PHP supports 
msql_* commands, they generate syntax errors when I want to open the page.

I suspect that I require some sort of module for php to be able to utilize those 
commands. I searched the site for "msql module" and "msql library" and couildn't find 
anything that looked like a download.

Any ideas would be appreciated.

Regards,

Kobus


--- End Message ---

Reply via email to