php-general Digest 3 Jun 2010 07:07:35 -0000 Issue 6779

Topics (messages 305745 through 305767):

Re: regular expression
        305745 by: Richard Quadling

Preg Match Problem
        305746 by: Alice Wei
        305747 by: Peter Lind
        305748 by: Alice Wei
        305767 by: Simcha Younger

Re: php accelorator
        305749 by: Robert Cummings
        305751 by: Lester Caine
        305752 by: Robert Cummings
        305758 by: Lester Caine
        305759 by: Robert Cummings
        305761 by: Lester Caine
        305765 by: Ashley Sheridan
        305766 by: Nilesh Govindarajan

Parse info from 1,000 files to file
        305750 by: Sam Smith
        305757 by: Andre Polykanine

Re: Set up MySQL + Apache 2.2.4 on Win XP.
        305753 by: Shreyas

Inserting, storing, outputting dates and selections
        305754 by: David Mehler
        305755 by: Shreyas
        305756 by: Andre Polykanine

preg_replace insert newline
        305760 by: Sam Smith
        305762 by: Shawn McKenzie

Re: Set up MySQL + Apache 2.2.4 on Win XP
        305763 by: Shreyas
        305764 by: shiplu

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 2 June 2010 16:35, Jan G.B. <ro0ot.w...@googlemail.com> wrote:
> 2010/6/1 Peter Lind <peter.e.l...@gmail.com>:
>> On 1 June 2010 17:33, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
>>> On Tue, 2010-06-01 at 16:31 +0100, Richard Quadling wrote:
>>>
>>>> $re1 = '/^[a-z]++$/i';
>>>> $re2 = '/^[a-z ]++$/i';
>>>>
>>>>
>>>>
>>>> --
>>>> -----
>>>> Richard Quadling
>>>> "Standing on the shoulders of some very clever giants!"
>>>> EE : http://www.experts-exchange.com/M_248814.html
>>>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>>>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>>>> ZOPA : http://uk.zopa.com/member/RQuadling
>>>>
>>>
>>>
>>> Why the double ++ in the expressions there? Surely one + would match the
>>> 1 or more characters that you need and the second one would just be
>>> surplus?
>>>
>>
>> Equally important: why have three people already done this persons
>> homework. 5 minutes googling would have answered this ...
>>
>
> Even more important: No answer is correct, because f.e. "äüßćéâ" are
> also letters.
>
> Bye
>
> ;-)
>

So, would ...

/^[^\p{M}\p{Z}\p{N}\p{P}\p{S}\p{C}\d\s]++$/i

be ok?



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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

I have a code snippet here as in the following:

[CODE]
$keywords = preg_split("/[\s,]+/", $day);
$count = count($keywords);
  if(preg_match("(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])) { //line 40
   $day_query ="start_time.day='12345' AND end_time.day='12345'";  
   }  
   if(preg_match("Sat/i", $keywords[$i])) { //line 43
   $day_query = "start_time.Sat_route != 'NULL' AND end_time.Sat_route != 
'NULL'";
   }  
   else {
   echo $keywords[i] . " is not a term that exists in the database. Make sure 
the pattern looks like <b>Mon, Tue</b><br />";
   footer();
   exit;
   }
[/CODE]

For some reason, when I type in Mon, Tue

It gives me this: 

Warning: preg_match() [function.preg-match]: Unknown modifier '/' in line 40
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric 
or backslash on line 43
is not a term that exists in the database. Make sure the pattern looks like 
Mon, Tue

Have I done something wrong here?
Thanks for your help.
                                          
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

--- End Message ---
--- Begin Message ---
On 2 June 2010 18:14, Alice Wei <aj...@alumni.iu.edu> wrote:
>
> Hi,
>
> I have a code snippet here as in the following:
>
> [CODE]
> $keywords = preg_split("/[\s,]+/", $day);
> $count = count($keywords);
>  if(preg_match("(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])) { //line 40

You're lacking the starting delimiter '/'

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>

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

> From: peter.e.l...@gmail.com
> Date: Wed, 2 Jun 2010 18:17:00 +0200
> Subject: Re: [PHP] Preg Match Problem
> To: aj...@alumni.iu.edu
> CC: php-gene...@lists.php.net
> 
> On 2 June 2010 18:14, Alice Wei <aj...@alumni.iu.edu> wrote:
> >
> > Hi,
> >
> > I have a code snippet here as in the following:
> >
> > [CODE]
> > $keywords = preg_split("/[\s,]+/", $day);
> > $count = count($keywords);
> >  if(preg_match("(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])) { //line 40
> 
> You're lacking the starting delimiter '/'
> 
> Regards
> Peter
> 

Thanks, that did the trick. 

Alice

> -- 
> <hype>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> </hype>
                                          
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

--- End Message ---
--- Begin Message ---
On Wed, 2 Jun 2010 12:14:47 -0400
Alice Wei <aj...@alumni.iu.edu> wrote:

> 
> Hi, 
> 
> I have a code snippet here as in the following:
> 
> [CODE]
> $keywords = preg_split("/[\s,]+/", $day);
> $count = count($keywords);
>   if(preg_match("(Mon|Tue|Wed|Thu|Fri)/i", $keywords[$i])) { //line 40
>    $day_query ="start_time.day='12345' AND end_time.day='12345'";  
>    }  
>    if(preg_match("Sat/i", $keywords[$i])) { //line 43
>    $day_query = "start_time.Sat_route != 'NULL' AND end_time.Sat_route != 
> 'NULL'";
>    }  
>    else {
>    echo $keywords[i] . " is not a term that exists in the database. Make sure 
> the pattern looks like <b>Mon, Tue</b><br />";
>    footer();
>    exit;
>    }
> [/CODE]
> 
> For some reason, when I type in Mon, Tue
> 
> It gives me this: 
> 
> Warning: preg_match() [function.preg-match]: Unknown modifier '/' in line 40
> Warning: preg_match() [function.preg-match]: Delimiter must not be 
> alphanumeric or backslash on line 43
> is not a term that exists in the database. Make sure the pattern looks like 
> Mon, Tue

You need a leading slash as a delimiter, eg
"/Sat/i"
also note that you will match any phrase that contains 'sun', 'mon' etc, which 
can also have irrelevant text, eg 'Mars Jupiter Saturn' will match, but thats 
probably not what you want
-- 
Simcha Younger <sim...@syounger.com>

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
Robert Cummings wrote:
Dan Joseph wrote:
Hi,

Are any of you using any of the php accelorators such as Zend,
Ioncube, or
any others? Any idea which is the "best"?
I am partial to eAccelerator for *nixes. And wincache for Windows.

eAccelerator works fine for me ... on linux and windows ...

I don't recall that eAccelerator works with PHP FastCGI in a windows environment -- the recommended configuration for PHP in a Windows environment.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
Lester Caine wrote:
Robert Cummings wrote:
Dan Joseph wrote:
Hi,

Are any of you using any of the php accelorators such as Zend,
Ioncube, or
any others? Any idea which is the "best"?
I am partial to eAccelerator for *nixes. And wincache for Windows.

eAccelerator works fine for me ... on linux and windows ...

I don't recall that eAccelerator works with PHP FastCGI in a windows
environment -- the recommended configuration for PHP in a Windows
environment.

That may be what people are trying to ram down our throuts! But I have had eaccelerator running on PHP5.x for many years without any problem and I do not intend changing that configuration for anybody. I have a matching setup on my linux servers as my windows servers and will maintain that even if it does mean ditching PHP5.3 in production ;)

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/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

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
Robert Cummings wrote:
Lester Caine wrote:
Robert Cummings wrote:
Dan Joseph wrote:
Hi,

Are any of you using any of the php accelorators such as Zend,
Ioncube, or
any others? Any idea which is the "best"?
I am partial to eAccelerator for *nixes. And wincache for Windows.
eAccelerator works fine for me ... on linux and windows ...
I don't recall that eAccelerator works with PHP FastCGI in a windows
environment -- the recommended configuration for PHP in a Windows
environment.

That may be what people are trying to ram down our throuts! But I have had eaccelerator running on PHP5.x for many years without any problem and I do not intend changing that configuration for anybody. I have a matching setup on my linux servers as my windows servers and will maintain that even if it does mean ditching PHP5.3 in production ;)

I use FastCGI and the NTS version of PHP in Windows because that is the configuration recommended by PHP on their website. After experiencing the instability of PHP as relates to the module version in Windows (using eAccelerator at the time), I switched to FastCGI NTS as recommended and then had to hunt down an appropriate accelerator. Wincache was in beta at the time and worked very well. As such it is my recommended accelerator for Windows since it works with PHP FastCGI and works well.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
I use FastCGI and the NTS version of PHP in Windows because that is the
configuration recommended by PHP on their website. After experiencing
the instability of PHP as relates to the module version in Windows
(using eAccelerator at the time), I switched to FastCGI NTS as
recommended and then had to hunt down an appropriate accelerator.
Wincache was in beta at the time and worked very well. As such it is my
recommended accelerator for Windows since it works with PHP FastCGI and
works well.

Well I have no problem with my own configuration being unstable - in some 5 years of use. So that would appear to suggest you are using something that has a problem which I am not. I also have only ever used TS version again without any stability problems.

Part of the problem here is people saying "It does not work" but not actually helping to identify WHAT does not work :(

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/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

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
Robert Cummings wrote:
I use FastCGI and the NTS version of PHP in Windows because that is the
configuration recommended by PHP on their website. After experiencing
the instability of PHP as relates to the module version in Windows
(using eAccelerator at the time), I switched to FastCGI NTS as
recommended and then had to hunt down an appropriate accelerator.
Wincache was in beta at the time and worked very well. As such it is my
recommended accelerator for Windows since it works with PHP FastCGI and
works well.

Well I have no problem with my own configuration being unstable - in some 5 years of use. So that would appear to suggest you are using something that has a problem which I am not. I also have only ever used TS version again without any stability problems.

Part of the problem here is people saying "It does not work" but not actually helping to identify WHAT does not work :(

I just realized btw... I haven't mentioned that the recommendation is for IIS in Windows... bleh. I don't think the problem exists when using Apache under windows. We were forced to use IIS in this particular case due to Government department policy.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
Lester Caine wrote:
Robert Cummings wrote:
I use FastCGI and the NTS version of PHP in Windows because that is the
configuration recommended by PHP on their website. After experiencing
the instability of PHP as relates to the module version in Windows
(using eAccelerator at the time), I switched to FastCGI NTS as
recommended and then had to hunt down an appropriate accelerator.
Wincache was in beta at the time and worked very well. As such it is my
recommended accelerator for Windows since it works with PHP FastCGI and
works well.

Well I have no problem with my own configuration being unstable - in
some 5 years of use. So that would appear to suggest you are using
something that has a problem which I am not. I also have only ever
used TS version again without any stability problems.

Part of the problem here is people saying "It does not work" but not
actually helping to identify WHAT does not work :(

I just realized btw... I haven't mentioned that the recommendation is
for IIS in Windows... bleh. I don't think the problem exists when using
Apache under windows. We were forced to use IIS in this particular case
due to Government department policy.

You have my sympathies ;)

We established early on that IIS was unsuitable for the type of sites were run and have never had any problem convincing customers of the facts. MANY of them have now moved the web servers to Linux simply to remove windows from the equation, and THEY were insisting that Windows servers were not negotiable 5 years ago! How times change ....

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/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

--- End Message ---
--- Begin Message ---
On Wed, 2010-06-02 at 22:38 +0100, Lester Caine wrote:

> Robert Cummings wrote:
> > Lester Caine wrote:
> >> Robert Cummings wrote:
> >>> I use FastCGI and the NTS version of PHP in Windows because that is the
> >>> configuration recommended by PHP on their website. After experiencing
> >>> the instability of PHP as relates to the module version in Windows
> >>> (using eAccelerator at the time), I switched to FastCGI NTS as
> >>> recommended and then had to hunt down an appropriate accelerator.
> >>> Wincache was in beta at the time and worked very well. As such it is my
> >>> recommended accelerator for Windows since it works with PHP FastCGI and
> >>> works well.
> >>
> >> Well I have no problem with my own configuration being unstable - in
> >> some 5 years of use. So that would appear to suggest you are using
> >> something that has a problem which I am not. I also have only ever
> >> used TS version again without any stability problems.
> >>
> >> Part of the problem here is people saying "It does not work" but not
> >> actually helping to identify WHAT does not work :(
> >
> > I just realized btw... I haven't mentioned that the recommendation is
> > for IIS in Windows... bleh. I don't think the problem exists when using
> > Apache under windows. We were forced to use IIS in this particular case
> > due to Government department policy.
> 
> You have my sympathies ;)
> 
> We established early on that IIS was unsuitable for the type of sites were 
> run 
> and have never had any problem convincing customers of the facts. MANY of 
> them 
> have now moved the web servers to Linux simply to remove windows from the 
> equation, and THEY were insisting that Windows servers were not negotiable 5 
> years ago! How times change ....
> 
> -- 
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/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
> 

<off-topic/>

It's odd sometimes how a lot of public sectors seem to shy away from
open source software for one reason or another. I've heard people say
they don't trust free software as there's nobody to call when something
goes wrong (by someone arguing the merits of MS Office over OpenOffice,
because MS have never done anything that locked people out of their own
protected documents before
http://www.channelregister.co.uk/2009/07/31/office_for_mac_service_pack_woes/ )

I've even heard people say Firefox wasn't trustworthy software, and was
essentially a trojan (this from a school ICT technician) for malware.

I'm not sure who's feeding this disinformation to the public sector, but
I could take a few guesses...

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Thu, Jun 3, 2010 at 6:01 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Wed, 2010-06-02 at 22:38 +0100, Lester Caine wrote:
>
>> Robert Cummings wrote:
>> > Lester Caine wrote:
>> >> Robert Cummings wrote:
>> >>> I use FastCGI and the NTS version of PHP in Windows because that is the
>> >>> configuration recommended by PHP on their website. After experiencing
>> >>> the instability of PHP as relates to the module version in Windows
>> >>> (using eAccelerator at the time), I switched to FastCGI NTS as
>> >>> recommended and then had to hunt down an appropriate accelerator.
>> >>> Wincache was in beta at the time and worked very well. As such it is my
>> >>> recommended accelerator for Windows since it works with PHP FastCGI and
>> >>> works well.
>> >>
>> >> Well I have no problem with my own configuration being unstable - in
>> >> some 5 years of use. So that would appear to suggest you are using
>> >> something that has a problem which I am not. I also have only ever
>> >> used TS version again without any stability problems.
>> >>
>> >> Part of the problem here is people saying "It does not work" but not
>> >> actually helping to identify WHAT does not work :(
>> >
>> > I just realized btw... I haven't mentioned that the recommendation is
>> > for IIS in Windows... bleh. I don't think the problem exists when using
>> > Apache under windows. We were forced to use IIS in this particular case
>> > due to Government department policy.
>>
>> You have my sympathies ;)
>>
>> We established early on that IIS was unsuitable for the type of sites were 
>> run
>> and have never had any problem convincing customers of the facts. MANY of 
>> them
>> have now moved the web servers to Linux simply to remove windows from the
>> equation, and THEY were insisting that Windows servers were not negotiable 5
>> years ago! How times change ....
>>
>> --
>> Lester Caine - G8HFL
>> -----------------------------
>> Contact - http://lsces.co.uk/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
>>
>
> <off-topic/>
>
> It's odd sometimes how a lot of public sectors seem to shy away from
> open source software for one reason or another. I've heard people say
> they don't trust free software as there's nobody to call when something
> goes wrong (by someone arguing the merits of MS Office over OpenOffice,
> because MS have never done anything that locked people out of their own
> protected documents before
> http://www.channelregister.co.uk/2009/07/31/office_for_mac_service_pack_woes/ 
> )
>
> I've even heard people say Firefox wasn't trustworthy software, and was
> essentially a trojan (this from a school ICT technician) for malware.
>
> I'm not sure who's feeding this disinformation to the public sector, but
> I could take a few guesses...
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

<off-topic>

Yeah Yeah, I know some such samplepieces. Such people are usually
found in very rich households, at least in my country (India).
Recently my friend's dad's computer was infected with virus it seems,
and he was using QuickHeal antivirus which is worst !
And he says, he doesn't trust free products when I suggested use of
Avast one of the best !
That was big OMG for me !!

-- 
Nilesh Govindarajan
Facebook: nilesh.gr
Twitter: nileshgr
Website: www.itech7.com
Cheap and Reliable VPS Hosting: http://j.mp/arHk5e

--- End Message ---
--- Begin Message ---
Can someone briefly point me to the functions I'll need to parse some
information from thousands of files in a single directory and then
prepare the extracted info into a single file for SQL import?

Like file() or readfile() and some regex and writefile??

Thanks

--- End Message ---
--- Begin Message ---
Hello Sam,

Consider using opendir(), readdir(), fopen(), file_get_contents(),
fwrite().
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Sam Smith <s...@ssmith.com>
To: php-gene...@lists.php.net <php-gene...@lists.php.net>
Date: Wednesday, June 2, 2010, 9:24:20 PM
Subject: [PHP] Parse info from 1,000 files to file

Can someone briefly point me to the functions I'll need to parse some
information from thousands of files in a single directory and then
prepare the extracted info into a single file for SQL import?

Like file() or readfile() and some regex and writefile??

Thanks

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


--- End Message ---
--- Begin Message ---
Bob,

That was a separate installer. It was nothing to do with another software.

--Shreyas

On Wed, Jun 2, 2010 at 7:19 PM, Bob McConnell <r...@cbord.com> wrote:

> From: Shreyas
>
> > What would be the exact installer which will let me have the MySQL
> Server
> > and the Query browser? I know this is the wrong forum but I am just
> giving
> > it a shot. When I do Start -> All Programs -> MYSQL, I used to get
> only
> > above options. I have lost the installer and the actual MySQL website
> has
> > quite a lot of things.
>
> I don't know anything about the MySQL toy, but from scanning this thread
> you already have a server installed if your java app is talking to it on
> port 3306. You are now trying to install a second server on the same
> computer, which can only be done if you change the port number.
>
> How did you install the first server? Was it part of the java install or
> did one of the other packages you installed put it there? Do you still
> have the documents for that package with the default users and
> passwords?
>
> Bob McConnell
>



-- 
Regards,
Shreyas

--- End Message ---
--- Begin Message ---
Hello,
I've got two questions which are probably fairly simple, my issue is
i'm staring at this so long it's blurring together.
        I'm working on a form to insert data in to a mysql database. I've got
a startdate and and enddate field in the database both of type DATE,
i'm needing this as i'm wanting to do a calculation against the date
and only display records greater than or equal to the current date. My
understanding is dates have to be entered as 2010-06-02 with this
format.
        I'm having several issues: the first of which is I entered a date as
probably a user would as June 2, 2010 and on the display page got all
zeroes, is there a way i can be more flexible with my data entry,
enter it, then store it in the format mysql needs?
My second issue is that the startdate field is NOT NULL while the
enddate field is. On submission I only want those forms that are
actually in the post data to get inserted in to the database, and
displayed, i.e. if enddate was not entered I shouldn't see all zeroes
in the field in the database, if using the mysql commandline client,
or all zeroes in displayed output. I'm not sure how to conditionally
insert or display a field based on whether it's set.
My last issue, not on dates, is on a selection box. I've got two
choices to choose from, choice1 and choice2 just for this example. If
a user goes through and selects nothing I want choice1 to be
automatically selected on form submission, if a user selects choice2
then the form should go with that. Here's my code.

<div>
<label for="txtchoose">Choose*:</label>
<select name="Choice for Selection">
<option> - choice1 - </option>
<option> - choice2 - </option>
</select>
</div>

On form submission the php script processes it and enters an empty
field in the database if the user doesn't select an option.
Thanks.
Dave.

--- End Message ---
--- Begin Message ---
I can try to answer the second one but would wait for the PHP gurus to chime
in.

Can't you have Choice=1 with selected="true" by default? On the PHP end, you
can get the value of whatever was selected.

Regards,
Shreyas

On Thu, Jun 3, 2010 at 1:50 AM, David Mehler <dave.meh...@gmail.com> wrote:

> Hello,
> I've got two questions which are probably fairly simple, my issue is
> i'm staring at this so long it's blurring together.
>        I'm working on a form to insert data in to a mysql database. I've
> got
> a startdate and and enddate field in the database both of type DATE,
> i'm needing this as i'm wanting to do a calculation against the date
> and only display records greater than or equal to the current date. My
> understanding is dates have to be entered as 2010-06-02 with this
> format.
>        I'm having several issues: the first of which is I entered a date as
> probably a user would as June 2, 2010 and on the display page got all
> zeroes, is there a way i can be more flexible with my data entry,
> enter it, then store it in the format mysql needs?
> My second issue is that the startdate field is NOT NULL while the
> enddate field is. On submission I only want those forms that are
> actually in the post data to get inserted in to the database, and
> displayed, i.e. if enddate was not entered I shouldn't see all zeroes
> in the field in the database, if using the mysql commandline client,
> or all zeroes in displayed output. I'm not sure how to conditionally
> insert or display a field based on whether it's set.
> My last issue, not on dates, is on a selection box. I've got two
> choices to choose from, choice1 and choice2 just for this example. If
> a user goes through and selects nothing I want choice1 to be
> automatically selected on form submission, if a user selects choice2
> then the form should go with that. Here's my code.
>
> <div>
> <label for="txtchoose">Choose*:</label>
> <select name="Choice for Selection">
> <option> - choice1 - </option>
> <option> - choice2 - </option>
> </select>
> </div>
>
> On form submission the php script processes it and enters an empty
> field in the database if the user doesn't select an option.
> Thanks.
> Dave.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas

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

Let's look and see)
1. You can re-format your date so that it will fit the needed format
for MySql:
$_POST['EndDate']=date("Y-m-d", $_POST['EndDate']);

                                                 2. There's a PHP
                                                 function called
                                                 isset() that checks
                                                 whether a variable is
                                                 set. But you probably
                                                 will find this one
                                                 much handier:
if (!empty($_POST['EndDate'])) {
// blahblah, inserting into database
}

3. This is quite simple, I think. You write:
<option>Choice 1</option>
What would you like PHP to write in the DB? It has nothing to write at
all) You should do this instead:
<option value=1>Choice 1</option>
<option value=2>Choice 2</option>

So now you have values to insert)
Hope I could help you!)

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: David Mehler <dave.meh...@gmail.com>
To: php-general <php-gene...@lists.php.net>
Date: Wednesday, June 2, 2010, 11:20:55 PM
Subject: [PHP] Inserting, storing, outputting dates and selections

Hello,
I've got two questions which are probably fairly simple, my issue is
i'm staring at this so long it's blurring together.
        I'm working on a form to insert data in to a mysql database. I've got
a startdate and and enddate field in the database both of type DATE,
i'm needing this as i'm wanting to do a calculation against the date
and only display records greater than or equal to the current date. My
understanding is dates have to be entered as 2010-06-02 with this
format.
        I'm having several issues: the first of which is I entered a date as
probably a user would as June 2, 2010 and on the display page got all
zeroes, is there a way i can be more flexible with my data entry,
enter it, then store it in the format mysql needs?
My second issue is that the startdate field is NOT NULL while the
enddate field is. On submission I only want those forms that are
actually in the post data to get inserted in to the database, and
displayed, i.e. if enddate was not entered I shouldn't see all zeroes
in the field in the database, if using the mysql commandline client,
or all zeroes in displayed output. I'm not sure how to conditionally
insert or display a field based on whether it's set.
My last issue, not on dates, is on a selection box. I've got two
choices to choose from, choice1 and choice2 just for this example. If
a user goes through and selects nothing I want choice1 to be
automatically selected on form submission, if a user selects choice2
then the form should go with that. Here's my code.

<div>
<label for="txtchoose">Choose*:</label>
<select name="Choice for Selection">
<option> - choice1 - </option>
<option> - choice2 - </option>
</select>
</div>

On form submission the php script processes it and enters an empty
field in the database if the user doesn't select an option.
Thanks.
Dave.

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


--- End Message ---
--- Begin Message ---
$string = 'text with no newline';
$pattern = '/(.*)/';
$replacement = '${1}XX\nNext line';
$string = preg_replace($pattern, $replacement, $string);
echo $string;

Outputs:
text with no newlineXX\nNext line
Instead of:
text with no newlineXX
Next line

How does one insert a newline with preg_replace?

Thanks

--- End Message ---
--- Begin Message ---
On 06/02/2010 04:28 PM, Sam Smith wrote:
> $string = 'text with no newline';
> $pattern = '/(.*)/';
> $replacement = '${1}XX\nNext line';
> $string = preg_replace($pattern, $replacement, $string);
> echo $string;
> 
> Outputs:
> text with no newlineXX\nNext line
> Instead of:
> text with no newlineXX
> Next line
> 
> How does one insert a newline with preg_replace?
> 
> Thanks

http://us.php.net/manual/en/language.types.string.php

Pay attention to single and double.

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

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

Finally, the 28th reply seems to have brought this thread to an end. Yes,
persistence finally got me there! Special thanks to Ash.

I am able to run both my Java code and php code on the same port (though
nothing database conversations are happening) from the same machine.

Here's the set-up :

MySQL Server 5.1 + Query Browser : port 3306. This has a schema called as NS
which is referenced by my Java code.

EasyPHP : This is running in a diferent location with its stack in C:\.

Fix : I knew all I had to do was a drop of my NS schema to a folder called
data and from nowhere I crashed into this : C:\Documents and Settings\All
Users\Application Data\MySQL\MySQL Server 5.1\data.

I dropped my NS schema there; checked the query browser and there it was!
Compiled my Java code and I was able to get back to my previous
environment.

So, no port conflicts, no different usernames. So far so good. Talk to you
all soon as I am gearing up with programming questions now.

--Shreyas

On Thu, Jun 3, 2010 at 1:02 AM, Shreyas <shreya...@gmail.com> wrote:

> Bob,
>
> That was a separate installer. It was nothing to do with another software.
>
> --Shreyas
>
>
> On Wed, Jun 2, 2010 at 7:19 PM, Bob McConnell <r...@cbord.com> wrote:
>
>> From: Shreyas
>>
>> > What would be the exact installer which will let me have the MySQL
>> Server
>> > and the Query browser? I know this is the wrong forum but I am just
>> giving
>> > it a shot. When I do Start -> All Programs -> MYSQL, I used to get
>> only
>> > above options. I have lost the installer and the actual MySQL website
>> has
>> > quite a lot of things.
>>
>> I don't know anything about the MySQL toy, but from scanning this thread
>> you already have a server installed if your java app is talking to it on
>> port 3306. You are now trying to install a second server on the same
>> computer, which can only be done if you change the port number.
>>
>> How did you install the first server? Was it part of the java install or
>> did one of the other packages you installed put it there? Do you still
>> have the documents for that package with the default users and
>> passwords?
>>
>> Bob McConnell
>>
>
>
>
> --
> Regards,
> Shreyas
>



-- 
Regards,
Shreyas

--- End Message ---
--- Begin Message ---
Actually you just restore your NS schema in the new EasyPHP stack.

Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--- End Message ---

Reply via email to