php-general Digest 8 Sep 2005 08:53:40 -0000 Issue 3670

Topics (messages 221994 through 222016):

Checking a date for validity
        221994 by: Todd Cary
        221996 by: Jordan Miller
        221997 by: Todd Cary
        221998 by: Todd Cary
        222000 by: Chris W. Parker
        222001 by: Ben
        222005 by: JamesBenson

Learning PHP - question about hidden form fields
        221995 by: Iggep
        221999 by: James Kaufman
        222002 by: bruce
        222003 by: Iggep

Re: Cookie-question?
        222004 by: Jose Miguel
        222006 by: Gustav Wiberg

Re: Help with Class
        222007 by: Ian Barnes
        222008 by: Ian Barnes

PHP wiki recommendations
        222009 by: Murray . PlanetThoughtful

preg_match help please
        222010 by: Steve Turnbull
        222011 by: Jasper Bryant-Greene
        222013 by: Steve Turnbull
        222014 by: Jasper Bryant-Greene

unserialize() problem
        222012 by: Harris Kosmidhs

Re: regular expression for integer range
        222015 by: Mark Rees

problem with multi field validation
        222016 by: Muthukumar

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 --- I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available?

Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
    if (strtotime($date) == -1) {
      $retval = 0;
    } else {
      if (strpos($date, "/") > 0) {
        $parts = explode("/", $date);
      } elseif (strpos($date, "-") > 0) {
        $parts2 = explode("-", $date);
        $parts[0] = $parts2[1];
        $parts[1] = $parts2[2];
        $parts[2] = $parts2[0];
      } else {
        $parts = explode(".", $date);
      }
      //print_r($parts);
      if (checkdate($parts[0], $parts[1], $parts[2]) )
        return 1;
      else
        return 0;
    }
    return $retval;
  }

Is there a simplier solution?

Many thanks......

--- End Message ---
--- Begin Message --- writing a parse script is okay, but it will be very difficult to always ensure they are inputting it correctly. I recommend putting a popup calendar next to the input field. If the field is automatically populated in this way you will have a much easier time parsing it correctly. I can't recommend a good one offhand, but there are several that are DHTML and JS only, so that should be a good starting point for standards compliance. See:
http://www.dynarch.com/projects/calendar/
and
http://www.google.com/search?q=dhtml+popup+calendar

Jordan


On Sep 7, 2005, at 5:39 PM, Todd Cary wrote:

I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available?

Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
    if (strtotime($date) == -1) {
      $retval = 0;
    } else {
      if (strpos($date, "/") > 0) {
        $parts = explode("/", $date);
      } elseif (strpos($date, "-") > 0) {
        $parts2 = explode("-", $date);
        $parts[0] = $parts2[1];
        $parts[1] = $parts2[2];
        $parts[2] = $parts2[0];
      } else {
        $parts = explode(".", $date);
      }
      //print_r($parts);
      if (checkdate($parts[0], $parts[1], $parts[2]) )
        return 1;
      else
        return 0;
    }
    return $retval;
  }

Is there a simplier solution?

Many thanks......

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





--- End Message ---
--- Begin Message ---
Jordan Miller wrote:
writing a parse script is okay, but it will be very difficult to always ensure they are inputting it correctly. I recommend putting a popup calendar next to the input field. If the field is automatically populated in this way you will have a much easier time parsing it correctly. I can't recommend a good one offhand, but there are several that are DHTML and JS only, so that should be a good starting point for standards compliance. See:
http://www.dynarch.com/projects/calendar/
and
http://www.google.com/search?q=dhtml+popup+calendar

Jordan


On Sep 7, 2005, at 5:39 PM, Todd Cary wrote:

I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available?

Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
    if (strtotime($date) == -1) {
      $retval = 0;
    } else {
      if (strpos($date, "/") > 0) {
        $parts = explode("/", $date);
      } elseif (strpos($date, "-") > 0) {
        $parts2 = explode("-", $date);
        $parts[0] = $parts2[1];
        $parts[1] = $parts2[2];
        $parts[2] = $parts2[0];
      } else {
        $parts = explode(".", $date);
      }
      //print_r($parts);
      if (checkdate($parts[0], $parts[1], $parts[2]) )
        return 1;
      else
        return 0;
    }
    return $retval;
  }

Is there a simplier solution?

Many thanks......

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




My need has to do with claimants for class action lawsuits, so I guess having drop downs for months, days and years is one answer.

Todd

--- End Message ---
--- Begin Message ---
Jordan Miller wrote:
writing a parse script is okay, but it will be very difficult to always ensure they are inputting it correctly. I recommend putting a popup calendar next to the input field. If the field is automatically populated in this way you will have a much easier time parsing it correctly. I can't recommend a good one offhand, but there are several that are DHTML and JS only, so that should be a good starting point for standards compliance. See:
http://www.dynarch.com/projects/calendar/
and
http://www.google.com/search?q=dhtml+popup+calendar

Jordan


On Sep 7, 2005, at 5:39 PM, Todd Cary wrote:

I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available?

Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
    if (strtotime($date) == -1) {
      $retval = 0;
    } else {
      if (strpos($date, "/") > 0) {
        $parts = explode("/", $date);
      } elseif (strpos($date, "-") > 0) {
        $parts2 = explode("-", $date);
        $parts[0] = $parts2[1];
        $parts[1] = $parts2[2];
        $parts[2] = $parts2[0];
      } else {
        $parts = explode(".", $date);
      }
      //print_r($parts);
      if (checkdate($parts[0], $parts[1], $parts[2]) )
        return 1;
      else
        return 0;
    }
    return $retval;
  }

Is there a simplier solution?

Many thanks......

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




My need has to do with claimants for class action lawsuits, so I guess having drop downs for months, days and years is one answer.

Todd

--- End Message ---
--- Begin Message ---
Todd Cary <mailto:[EMAIL PROTECTED]>
    on Wednesday, September 07, 2005 3:39 PM said:

>    /* Is date good */
>    function is_date_good($date) {
>      if (strtotime($date) == -1) {
>        $retval = 0;
>      } else {
>        if (strpos($date, "/") > 0) {
>          $parts = explode("/", $date);
>        } elseif (strpos($date, "-") > 0) {
>          $parts2 = explode("-", $date);
>          $parts[0] = $parts2[1];
>          $parts[1] = $parts2[2];
>          $parts[2] = $parts2[0];

Why $parts2?

Just use $parts instead, like you did in the other two blocks.

Change it to:

>        if (strpos($date, "/") > 0) {
>          $parts = explode("/", $date);
>        } elseif (strpos($date, "-") > 0) {
>          $parts = explode("-", $date);
>        } else {
>          $parts = explode(".", $date);
>        }

> Is there a simplier solution?

How about strtotime()? In your function you're pretty much only
accepting a certain number of formats for your date already so you could
probably go with just passing the date (in whatever format it's given)
to strtotim() and check for a 'false' or a timestamp.


Chris.

--- End Message ---
--- Begin Message ---
Todd Cary wrote:

My need has to do with claimants for class action lawsuits, so I guess having drop downs for months, days and years is one answer.

Drop down menus can certainly make your life easier, especially if you're dealing with an international audience and wondering what order to put the year, month, and day. Once the info has been submitted you can check them against the checkdate function (http://ca3.php.net/manual/en/function.checkdate.php) to make sure they're valid (ie February 31st, etc.).

- Ben

--- End Message ---
--- Begin Message ---
I would use something like:-



$date = '09/09/2005';

list($month, $day, $year) = explode("/", $date);

        if(checkdate($month, $day, $year)) {
                /* valid date */
        } else {
                /* invalid date */
        }






Todd Cary wrote:
I need to check the input of a user to make sure the date is valid and correctly formatted. Are there any examples available?

Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
    if (strtotime($date) == -1) {
      $retval = 0;
    } else {
      if (strpos($date, "/") > 0) {
        $parts = explode("/", $date);
      } elseif (strpos($date, "-") > 0) {
        $parts2 = explode("-", $date);
        $parts[0] = $parts2[1];
        $parts[1] = $parts2[2];
        $parts[2] = $parts2[0];
      } else {
        $parts = explode(".", $date);
      }
      //print_r($parts);
      if (checkdate($parts[0], $parts[1], $parts[2]) )
        return 1;
      else
        return 0;
    }
    return $retval;
  }

Is there a simplier solution?

Many thanks......

--- End Message ---
--- Begin Message ---
Hey all!  I sat down and started learning PHP today and ran into a bit of a 
spot.  Hoped someone here could lead me in the right direction.  I created a 
simple test form called form.php.  I thought I had this strait in my mind 
when I created it, but obviously it didn't work.  All I want to do is create 
a static value and pass it back to the page which then triggers a statement 
for the user to read.

Problem I'm running into is that I can't seem to find a way to pass that 
variable correctly with all this being on a single file.   I'd prefer to do 
this in a single file if possible.

Any ideas?

<html>
<head>
        <title>Test Form</title>
</head>
<body>

<?php
if (defined('form_submitted'))  {
        echo "<p>Thank you for submitting your trouble ticket.  We have 
received your 
trouble ticket and will be in touch with you about it as soon as 
possible.</p>";
        echo "<p>If you wish to submit another ticket, please use the form 
below.</p>";
}

echo "<form action='form.php' method='post'>";
echo "<input type='hidden' name='preform_submitted' value='y'>";
echo "<input type='hidden' name='form_submitted' value='$preform_submitted'>";
echo "<table>";
        echo "<tr><td>Last Name:</td><td><input name='lname' 
type='text'></td></tr>";
        echo "<tr><td>First Name:</td><td><input name='fname' 
type='text'></td></tr>";
        echo "<tr><td>Email Address:</td><td><input name='email_add' 
type='text'></td></tr>";
        echo "<tr><td colspan=2>Trouble:</td></tr>";
        echo "<tr><td colspan=2><textarea name='explan'></textarea></td></tr>";
        echo "<tr><td><input type='submit'></td></tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>

--- End Message ---
--- Begin Message ---
On Wed, Sep 07, 2005 at 06:47:28PM -0400, Iggep wrote:
> Hey all!  I sat down and started learning PHP today and ran into a bit of a 
> spot.  Hoped someone here could lead me in the right direction.  I created a 
> simple test form called form.php.  I thought I had this strait in my mind 
> when I created it, but obviously it didn't work.  All I want to do is create 
> a static value and pass it back to the page which then triggers a statement 
> for the user to read.
> 
> Problem I'm running into is that I can't seem to find a way to pass that 
> variable correctly with all this being on a single file.   I'd prefer to do 
> this in a single file if possible.
> 
> Any ideas?
> 
> <html>
> <head>
>       <title>Test Form</title>
> </head>
> <body>
> 
> <?php
        if ($_POST['form_submitted']=='y') {

> if (defined('form_submitted'))        {
>       echo "<p>Thank you for submitting your trouble ticket.  We have 
> received your 
> trouble ticket and will be in touch with you about it as soon as 
> possible.</p>";
>       echo "<p>If you wish to submit another ticket, please use the form 
> below.</p>";
> }
> 
> echo "<form action='form.php' method='post'>";
> echo "<input type='hidden' name='preform_submitted' value='y'>";
> echo "<input type='hidden' name='form_submitted' value='$preform_submitted'>";
> echo "<table>";
>       echo "<tr><td>Last Name:</td><td><input name='lname' 
> type='text'></td></tr>";
>       echo "<tr><td>First Name:</td><td><input name='fname' 
> type='text'></td></tr>";
>       echo "<tr><td>Email Address:</td><td><input name='email_add' 
> type='text'></td></tr>";
>       echo "<tr><td colspan=2>Trouble:</td></tr>";
>       echo "<tr><td colspan=2><textarea name='explan'></textarea></td></tr>";
>       echo "<tr><td><input type='submit'></td></tr>";
> echo "</table>";
> echo "</form>";
> ?>
> </body>
> </html>
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619
CCNA, CISSP# 65668
---
Scientists inhabit quite an inhuman world, and so they tend to believe in a
universe beyond people. And young people destined to become good scientists
tend to be more curious about the universe around them than about other people.
                -- Jerry Ostriker (Astrophysicist)

--- End Message ---
--- Begin Message ---
iggep...

what are you trying to do with the following:
>>echo "<input type='hidden' name='preform_submitted' value='y'>";
>>echo "<input type='hidden' name='form_submitted'
value='$preform_submitted'>";

if i had to guess, i'm pretty sure you're trying to assign the val of
'preform_submitted' to 'form_submitted'... but i'm not sure why...

$preform_submitted will not have the val you think it does.. in fact, from
your sample, it's not defined... in your sample, when you call the form.php
using the POST method, the elements in the form are available via the $_POST
array...

so you could simply check for the val of $_POST['preform_submitted'] and
assign that to the hidden val..

in a similar manner, you could also check in your logic using the $_POST[]
val...

-bruce


-----Original Message-----
From: Iggep [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07, 2005 3:47 PM
To: [email protected]
Subject: [PHP] Learning PHP - question about hidden form fields


Hey all!  I sat down and started learning PHP today and ran into a bit of a
spot.  Hoped someone here could lead me in the right direction.  I created a
simple test form called form.php.  I thought I had this strait in my mind
when I created it, but obviously it didn't work.  All I want to do is create
a static value and pass it back to the page which then triggers a statement
for the user to read.

Problem I'm running into is that I can't seem to find a way to pass that
variable correctly with all this being on a single file.   I'd prefer to do
this in a single file if possible.

Any ideas?

<html>
<head>
        <title>Test Form</title>
</head>
<body>

<?php
if (defined('form_submitted'))  {
        echo "<p>Thank you for submitting your trouble ticket.  We have received
your
trouble ticket and will be in touch with you about it as soon as
possible.</p>";
        echo "<p>If you wish to submit another ticket, please use the form
below.</p>";
}

echo "<form action='form.php' method='post'>";
echo "<input type='hidden' name='preform_submitted' value='y'>";
echo "<input type='hidden' name='form_submitted'
value='$preform_submitted'>";
echo "<table>";
        echo "<tr><td>Last Name:</td><td><input name='lname'
type='text'></td></tr>";
        echo "<tr><td>First Name:</td><td><input name='fname'
type='text'></td></tr>";
        echo "<tr><td>Email Address:</td><td><input name='email_add'
type='text'></td></tr>";
        echo "<tr><td colspan=2>Trouble:</td></tr>";
        echo "<tr><td colspan=2><textarea name='explan'></textarea></td></tr>";
        echo "<tr><td><input type='submit'></td></tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>

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

--- End Message ---
--- Begin Message ---
Wanted to thank the handful of you who wrote me with some hints.  I really 
appreciate the guidance.  :)  The test form is working like a champ.

--- End Message ---
--- Begin Message ---
Ok, please correct me if i'm wrong...

First of all, i'd rather use $_COOKIE instead of $HTTP_COOKIE_VARS.

And in the line...

if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

Why don't you use the operator NOT IDENTICAL (!==), cause != will also 
return true if the variables are the same type sometimes.

On 9/7/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> 
> Hi there!
> 
> Look at following code below, and please give me a clue why this
> cookie-thing doesn't work?
> $IDJoke is set before and is an ID from a row in a db
> It seems to work a while, but is there a limit for the expire-parameter?
> 
> /G
> http://www.varupiraten.se/
> 
> 
> //Get cookie from users computer for current joke to tell if user is
> allowed to vote or not!
> //
> $cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"];
> if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}
> 
> //User wants to vote?
> //
> if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {
> 
> $showVoteValues = 'N'; //Don't show values directly after
> vote...
> 
> //Save IDJoke to a cookie with the value - voted to users
> computer
> setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100); /*
> expires in about 100 years*/
> 
> //END User wants to vote
> //
> }
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Jose Arce
http://sinexion.com - http://josearce.com

--- End Message ---
--- Begin Message ---
---- Original Message ----- 
  From: Jose Miguel 
  To: Gustav Wiberg 
  Cc: PHP General 
  Sent: Thursday, September 08, 2005 3:26 AM
  Subject: Re: [PHP] Cookie-question?


  Ok, please correct me if i'm wrong...

  First of all, i'd rather use $_COOKIE instead of $HTTP_COOKIE_VARS.

  And in the line...

  if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

  Why don't you use the operator NOT IDENTICAL (!==), cause != will also return 
true if the variables are the same type sometimes.


  On 9/7/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
    Hi there! 

    Look at following code below, and please give me a clue why this
    cookie-thing doesn't work?
    $IDJoke is set before and is an ID from a row in a db
    It seems to work a while, but is there a limit for the expire-parameter? 

    /G
    http://www.varupiraten.se/


    //Get cookie from users computer for current joke to tell if user is
    allowed to vote or not!
        //
        $cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"]; 
        if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}

        //User wants to vote?
        //
        if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

                $showVoteValues = 'N'; //Don't show values directly after
    vote...

                //Save IDJoke to a cookie with the value - voted to users
    computer
                setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100);  /*
    expires in about 100 years*/

        //END User wants to vote
        //
        }

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





  -- 
  Jose Arce
  http://sinexion.com - http://josearce.com 


------------------------------------------------------------------------------


  No virus found in this incoming message.
  Checked by AVG Anti-Virus.
  Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06

  Hi

  Ok, Thanx for the input! :-)

  /G
  http://www.varupiraten.se/

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

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _____  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



                        foreach ( $forums as $num=>$val )

                        {

                                    $db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

                                    $sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

                                    $result = $db->get($sql);

                                    $fetchd = mysql_fetch_array ( $result );

                                    $forumid = $fetchd['forumid'];

                                    $posterid = $fetchd['posterid'];

                                    $title = $_POST['title'];

                                    $desc = $_POST['desc'];

                                    $post = $_POST['post'];

                                    require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

                                    $SDK =& new ipbsdk;

                                    $info = $SDK -> get_info ( $posterid );

                                    $postername = $info['name'];

                                    echo "Forum ID:".$forumid;

                                    echo "<BR>Title:".$title;

                                    echo "<BR>Desc:".$desc;

                                    echo "<BR>Post:".$post;

                                    echo "<BR>PosterID:".$posterid;

                                    echo "<BR>PosterName:".$postername;

                                    echo "<BR>";

                        }



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 


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

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _____  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



                        foreach ( $forums as $num=>$val )

                        {

                                    $db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

                                    $sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

                                    $result = $db->get($sql);

                                    $fetchd = mysql_fetch_array ( $result );

                                    $forumid = $fetchd['forumid'];

                                    $posterid = $fetchd['posterid'];

                                    $title = $_POST['title'];

                                    $desc = $_POST['desc'];

                                    $post = $_POST['post'];

                                    require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

                                    $SDK =& new ipbsdk;

                                    $info = $SDK -> get_info ( $posterid );

                                    $postername = $info['name'];

                                    echo "Forum ID:".$forumid;

                                    echo "<BR>Title:".$title;

                                    echo "<BR>Desc:".$desc;

                                    echo "<BR>Post:".$post;

                                    echo "<BR>PosterID:".$posterid;

                                    echo "<BR>PosterName:".$postername;

                                    echo "<BR>";

                        }



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 


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

I want to add a wiki to my blog site to help create a knowledgebase of the
characters, localities, stories I write to make it easier for new visitors
to delve into the areas that interest them.

I've been experimenting with a couple of different wiki packages, but am
always interested in others' thoughts and recommendations.

In particular, I've looked at MediaWiki and PmWiki. Of the two, I like
MediaWiki's 'completeness', but it's also quite slow and doesn't strike me
as being particularly (or easily?) customizable. PmWiki is probably my
current candidate, but again I'd like to make sure I'm not missing a more
obvious choice.

My shopping list for the ideal wiki application is:

- wiki entries preferably stored in MySQL tables. I'm not adamant about this
(eg PmWiki uses files rather than a db backend), but it would suit my
purposes better to be able to draw from the wiki tables from the front page
of my blog to show lists of recently added and recently updated wiki entries

- non-reliance on CamelCase wiki links. Many of my characters etc use joined
CamelCase names (eg KillFork and DangerSpoon), and to avoid confusion I'd
rather explicitly define links to wiki content

- ability to categorize wiki entries

- ability to compare history of wiki edits and easily reinstate older edits
if wiki pages get 'graffiti'd' 

- ability to allow others to edit / create wiki entries, thru a user id /
password system, so that regulars who would like to participate can do so

- ability to customize presentation of wiki pages, presumably through CSS
etc, so that I can maintain the 'look and feel' of my blog thru the wiki
content

- PHP based, though my host does run Perl, so if the killer wiki app is a
Perl-based one, I'm sure I can muddle thru implementing it

If anyone has any recommendations for other wiki applications I should look
at before making a decision, I'd love to hear from you!

Much warmth,

Murray
---
"Lost in thought..."
http://www.planetthoughtful.org

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

I am trying to find a regular expression to match a variable, what I think
should work (but doesn't) is;

preg_match ('^/[\w],[\w],/', $variable)

The $variable MUST contain an alpha-numeric string, followed by a comma,
followed by another alpha-numeric string, followed by another comma
followed by (but doesn't have to!!) another alpha-numeric string followed
by nothing.

I realise my regex above doesn't allow for the last 'followed by nothing',
but to me it looks like it should match the first part of the string up to
the last comma?

Help appreciated, and apologies if this isn't strictly the correct group.

Thanks
Steve

--- End Message ---
--- Begin Message ---
Steve Turnbull wrote:
I am trying to find a regular expression to match a variable, what I think
should work (but doesn't) is;

preg_match ('^/[\w],[\w],/', $variable)

The $variable MUST contain an alpha-numeric string, followed by a comma,
followed by another alpha-numeric string, followed by another comma
followed by (but doesn't have to!!) another alpha-numeric string followed
by nothing.

I realise my regex above doesn't allow for the last 'followed by nothing',
but to me it looks like it should match the first part of the string up to
the last comma?

Something like

'/^\w+,\w+,\w*$/'

maybe? (untested)

http://php.net/reference.pcre.pattern.syntax

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

--- End Message ---
--- Begin Message ---
On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote:

> Steve Turnbull wrote:
>> I am trying to find a regular expression to match a variable, what I think
>> should work (but doesn't) is;
>> 
>> preg_match ('^/[\w],[\w],/', $variable)
>> 
>> The $variable MUST contain an alpha-numeric string, followed by a comma,
>> followed by another alpha-numeric string, followed by another comma
>> followed by (but doesn't have to!!) another alpha-numeric string followed
>> by nothing.
>> 
>> I realise my regex above doesn't allow for the last 'followed by nothing',
>> but to me it looks like it should match the first part of the string up to
>> the last comma?
> 
> Something like
> 
> '/^\w+,\w+,\w*$/'
> 
> maybe? (untested)
> 
> http://php.net/reference.pcre.pattern.syntax

Thats got me a lot further - thanks

I reduced it slightly to '/^\w+,\w+,' because at the end there is the
possibility of an alpha-numeric character(s) OR nothing at all with the
exception of a possible line break (note possible)

It's the 'possibly nothing at all' which I am slightly stuck on

Thanks
Steve

--- End Message ---
--- Begin Message ---
Steve Turnbull wrote:
On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote:

Something like

'/^\w+,\w+,\w*$/'

maybe? (untested)

http://php.net/reference.pcre.pattern.syntax


Thats got me a lot further - thanks

I reduced it slightly to '/^\w+,\w+,' because at the end there is the
possibility of an alpha-numeric character(s) OR nothing at all with the
exception of a possible line break (note possible)

It's the 'possibly nothing at all' which I am slightly stuck on

That's what the \w* means. That means "0 or more word-characters", as opposed to \w+ which means "1 or more word-characters. The $ after that means "end of string" which makes sure that it's the last thing in the string.

In other words, \w* means some word-characters, or nothing at all. You'd need to handle the newline in much the same way. The URL I gave you should help out a lot with that.

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

--- End Message ---
--- Begin Message ---
Hello all.

I wrote some php pages running on apache1.3/php4.4.0-1
In the login page I make use of a class where I store the users name and
some integers (i.e whether the user ia able to see a certain page) and
serialize the class to a session var. When you go to a page I
unserialize the session var and check if the user is permited to see the
page.

No when I moved the files to my host server running apache2/php4.3.2 a
strange problem appears. When I access the page for the first time the
session var is unserialized ok and so I can see the page. If I refresh
it this session var (and only this.alla the other session variables wotk
ok) is lost and I cannot unserialize it.

What may be the problem?

Thanks

--- End Message ---
--- Begin Message ---
""Murray @ PlanetThoughtful"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Hi all,
> >
> >
> > I want to write regular expression for checking the string format
entered
> > by user.
> >
> > the allowed formats are
> >
> > examples:
> > 10
> > 10,
> > 10,12-10
> > 12-10
> >
> > that is the valid strings are:
> > 1. only integer
> > 2. an integer, range of integers example 3
> >
> > and no other characters must be allowed.

You could simplify the matter by replacing all "-" and "," with, say, 0 and
then using the simple "\d+" (I think) regexp.

>
> Hi babu,
>
> As you've pointed out, you have 4 distinct scenarios to deal with, and it
> may be very difficult, without a great deal of tuning and tweaking, to
> define a regular expression that can effectively match all 4 scenarios
> without including false matches as well.
>
> One way of dealing with this is to build more specialized and exact
regular
> expressions for each possible scenario and group them together in an if
> statement.
>
> Eg.
>
> if (preg_match('/^\d+$/',$subject) || preg_match('/^\d+,$/',$subject) ||
> preg_match('/^\d+,\d+-\d+$/', $subject) || <etc etc>){
>
> // code for successful match of valid data in $subject
>
> } else {
>
> // code for invalid data in $subject
>
> }
>
> Basically, the if/else statement is testing each distinct possible pattern
> and executing code if any of those distinct possible patterns match.
>
> It may not ultimately be the most graceful way of dealing with the
> situation, but having spent many hours attempting to tweak complex regular
> expressions looking for the magic combination, I've learned that breaking
> scenarios down this way can save a lot of development time and
frustration.
> This doesn't mean there isn't a benefit to finding the perfect regular
> expression for your needs, just that it can often be difficult to
guarantee
> your code won't be plagued by false matches or false exclusions as your
> expression becomes more and more complex.
>
> Hope this helps a little.
>
> Much warmth,
>
> Murray
> ---
> "Lost in thought..."
> http://www.planetthoughtful.org

--- End Message ---
--- Begin Message ---
Hi All,
 
Greetings.
 
I am working on making php script with gets information from a file with five fields and load it on browser.
 
# cat machines.log
machine1:os:team1:member1:booked
machine2:os:team1:member2:booked
machine3:os:team1::
machine4:os:team1::
 
format is like machine:os:team:member owning now: booked / available status
 
Requirement as,
 
Read machines.log and update the gui. Change machines.log and gui on getting inputs from user on member and booked field. Member field is text box and booked is selection box. If I have two or more machines with empty members, I can not get form value using _javascript_.
 
I have attached my machines.php file for your views.
 
Please revert with any queries and inputs.
 
Thanks,
-Muthu
 

--- End Message ---

Reply via email to