php-windows Digest 1 Mar 2005 01:22:06 -0000 Issue 2594

Topics (messages 25687 through 25690):

Re: Validation of Primary Key Datetime variable
        25687 by: S.D.Price
        25688 by: Mike
        25689 by: Randy Clamons

Re: [PHP] Not able to add data to a MySQL database
        25690 by: Richard Lynch

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 ---
Thanks for this George. I am populating the datetime field from user
input, and users can change the date if they need to.

The problem I have is with validation. I think I will need to use some
kind of regular expression to check that the date has been entered in
the correct format, but I am not sure what.

Steven

-----Original Message-----
From: George Pitcher [mailto:[EMAIL PROTECTED] 
Sent: 28 February 2005 13:31
To: S.D.Price
Subject: RE: [PHP-WIN] Validation of Primary Key Datetime variable


Simon,

Why not use a varchar datatype and populate it yourself. It can then be
modified, but the data can still be displayed in the way you want, by
being a bit more creative with the code.

I don't store dates as date datatype but as integers, that way I could,
if required, move my code to a different db with no extra work.

George
> -----Original Message-----
> From: S.D.Price [mailto:[EMAIL PROTECTED]
> Sent: 28 February 2005 12:38 pm
> To: php-windows
> Subject: [PHP-WIN] Validation of Primary Key Datetime variable
>
>
> Hi, I wonder if anyone can help.
>
> I have designed a newsblog which uses PHP and MySQL. Each news story 
> has a primary key which is the current date. The datatype used in 
> MySQL is "datetime". When stories are extracted from the database the 
> user can then navigate based on date order.
>
> When a user adds a news story to the database the current days date is

> shown in the form using
>
> <dt>
> <label for="publish_date"><?php echo $publish_datelabel 
> ?></label></dt> <dd><input type="text" name="publish_date" 
> id="publish_date" value="<?php echo date('Y-m-d H:i:s') ?>"/></dd>
>
>
> This is the date added to the DB by default.
>
> However, the user must be able to change the date so that they can set

> a date sometime in the future when they want the story to be 
> published. The only stories shown in the archive (and pulled through 
> to the home
> page) are those which are before or on today's date.
>
> My problem is that I am not sure how to validate any changes made to 
> the $publish_date so that it will conform to the required datetime 
> range in MySQL and not give the useless answer 0000:00:00 00:00:00.
>
> Does anyone know how to do this?
> Thanks
>
> Steven Price
>
>
>
>

--- End Message ---
--- Begin Message ---
I know that your form currently has just an input field that displays the
date in the format that you're interested in, but have you thought of using
a form SELECT object so that the user can only pull down the month, date and
year?

You'd have to do more processing in the form to "assemble" the date and to
"disassemble" it if you wanted to display it, but then you'd know without a
doubt that someone didn't put letters or a date that's out of your range.

Just a thought.

-M

> -----Original Message-----
> From: S.D.Price [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 9:17 AM
> To: php-windows
> Subject: RE: [PHP-WIN] Validation of Primary Key Datetime variable
> 
> Thanks for this George. I am populating the datetime field 
> from user input, and users can change the date if they need to.
> 
> The problem I have is with validation. I think I will need to 
> use some kind of regular expression to check that the date 
> has been entered in the correct format, but I am not sure what.
> 
> Steven
> 
> -----Original Message-----
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: 28 February 2005 13:31
> To: S.D.Price
> Subject: RE: [PHP-WIN] Validation of Primary Key Datetime variable
> 
> 
> Simon,
> 
> Why not use a varchar datatype and populate it yourself. It 
> can then be
> modified, but the data can still be displayed in the way you want, by
> being a bit more creative with the code.
> 
> I don't store dates as date datatype but as integers, that 
> way I could,
> if required, move my code to a different db with no extra work.
> 
> George
> > -----Original Message-----
> > From: S.D.Price [mailto:[EMAIL PROTECTED]
> > Sent: 28 February 2005 12:38 pm
> > To: php-windows
> > Subject: [PHP-WIN] Validation of Primary Key Datetime variable
> >
> >
> > Hi, I wonder if anyone can help.
> >
> > I have designed a newsblog which uses PHP and MySQL. Each 
> news story 
> > has a primary key which is the current date. The datatype used in 
> > MySQL is "datetime". When stories are extracted from the 
> database the 
> > user can then navigate based on date order.
> >
> > When a user adds a news story to the database the current 
> days date is
> 
> > shown in the form using
> >
> > <dt>
> > <label for="publish_date"><?php echo $publish_datelabel 
> > ?></label></dt> <dd><input type="text" name="publish_date" 
> > id="publish_date" value="<?php echo date('Y-m-d H:i:s') ?>"/></dd>
> >
> >
> > This is the date added to the DB by default.
> >
> > However, the user must be able to change the date so that 
> they can set
> 
> > a date sometime in the future when they want the story to be 
> > published. The only stories shown in the archive (and 
> pulled through 
> > to the home
> > page) are those which are before or on today's date.
> >
> > My problem is that I am not sure how to validate any 
> changes made to 
> > the $publish_date so that it will conform to the required datetime 
> > range in MySQL and not give the useless answer 0000:00:00 00:00:00.
> >
> > Does anyone know how to do this?
> > Thanks
> >
> > Steven Price
> >
> >
> >
> >
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Just a thought... Using a primary key that is controlled by the user rather 
than your db system is risky, especially if the user can change the value after 
adding the record. Why not use an auto_increment field as your primary key and 
an indexed datetime column to list rows in the order you wish? 

Randy Clamons
Systems Programming
Novaspace.com


> ------------Original Message------------
> From: "S.D.Price" <[EMAIL PROTECTED]>
> To: "php-windows" <[email protected]>
> Date: Mon, Feb-28-2005 6:18 AM
> Subject: [PHP-WIN] Validation of Primary Key Datetime variable
>
> Hi, I wonder if anyone can help.
> 
> I have designed a newsblog which uses PHP and MySQL. Each news story 
> has
> a primary key which is the current date. The datatype used in MySQL is
> "datetime". When stories are extracted from the database the user can
> then navigate based on date order. 
> 
> When a user adds a news story to the database the current days date is
> shown in the form using 
> 
> <dt>
> <label for="publish_date"><?php echo $publish_datelabel ?></label></dt>
> <dd><input type="text" name="publish_date" id="publish_date"
> value="<?php echo date('Y-m-d H:i:s') ?>"/></dd>
> 
> 
> This is the date added to the DB by default. 
> 
> However, the user must be able to change the date so that they can set 
> a
> date sometime in the future when they want the story to be published.
> The only stories shown in the archive (and pulled through to the home
> page) are those which are before or on today's date.
> 
> My problem is that I am not sure how to validate any changes made to 
> the
> $publish_date so that it will conform to the required datetime range in
> MySQL and not give the useless answer 0000:00:00 00:00:00.
> 
> Does anyone know how to do this?
> Thanks
> 
> Steven Price 
> 
> 
> 
> 

--- End Message ---
--- Begin Message ---
Vaibhav Sibal wrote:
> Hi,
> I am not able to insert data into my mysql database using php even if
> i use a simple code as follows :
> <?php
> $link=mysql_connect("localhost","username","password");
> mysql_select_db("test_db");
> $query="INSERT INTO 'login' ('uname','access') VALUES ('try','super')";
> mysql_query($query,$link);
> ?>

ADD SOME ERROR CHECKING!!!

http://php.net/die

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---

Reply via email to