Re: RE: [PHP] Check for open file

2011-03-03 Thread Peter Lind
On Mar 4, 2011 4:53 AM, "Ashley M. Kirchner"  wrote:
>
> > -Original Message-
> > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> > Sent: Thursday, March 03, 2011 2:03 PM
> > To: sstap...@mnsi.net
> > Cc: php-general@lists.php.net
> > Subject: RE: [PHP] Check for open file
> >
> >
> > As far as I was aware, if you're in the middle of writing to a file and
another
> > script was attempting to write to it, the OS would prevent that as you
had an
> > open lock on it.
> >
> > --
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
>
>And as it turned out, that was not the case.  I started copying a
200MiB file from my desktop machine onto the Samba share.  While that was
copying, I got onto the server and tried to copy the file to /tmp and it
happily did that for me without any indication that it was still being
written to (which is was by the way.)  So, that's not a good way of dealing
with this.
>
>I think I'm going to have to go with a time delay function here ...
>

If on Linux, you can check for open file with lsof, I think the command is
called.

Regards
Peter

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


RE: [PHP] Check for open file

2011-03-03 Thread Ashley M. Kirchner
> -Original Message-
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, March 03, 2011 2:03 PM
> To: sstap...@mnsi.net
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Check for open file
> 
> 
> As far as I was aware, if you're in the middle of writing to a file and 
> another
> script was attempting to write to it, the OS would prevent that as you had an
> open lock on it.
> 
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

And as it turned out, that was not the case.  I started copying a 
200MiB file from my desktop machine onto the Samba share.  While that was 
copying, I got onto the server and tried to copy the file to /tmp and it 
happily did that for me without any indication that it was still being written 
to (which is was by the way.)  So, that's not a good way of dealing with this.

I think I'm going to have to go with a time delay function here ...


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



Re: [PHP] Overriding session length in existing session?

2011-03-03 Thread Scott Baker
On 03/03/2011 04:31 PM, tedd wrote:
> At 2:58 PM -0800 3/3/11, Scott Baker wrote:
>> I have a global header.php file that sets up a bunch of stuff: DB,
>> global variables, and does session_start(). My header.php looks like
>> this:
>>
>> #header.php
>> $cookie_life = (86400 * 7); // Cookies last for seven days
>> session_set_cookie_params($cookie_life,"/",".domain.com",true);
>> session_start();
>>
>> This is called globally in *all* my scripts. In another script I'd
>> really like to set the session to expire after the browser closes if a
>> uses clicks "public terminal" or something.
>>
>> I thought I could just set the session cookie to expire after the
>> browser closes. Can I override the already started session by doing
>> something like this in my index.php:
>>
>> #index.php
>> include('header.php');
>> setcookie(session_name(), '', 0 ,"/",".domain.com");
>>
>> When I do this the session expires IMMEDIATELY. I must be missing
>> something?
> 
> Simple answer -- put session_start() at the start of your code -- first
> line.

Of index.php or header.php? You lost me.

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253

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



Re: [PHP] Overriding session length in existing session?

2011-03-03 Thread tedd

At 2:58 PM -0800 3/3/11, Scott Baker wrote:

I have a global header.php file that sets up a bunch of stuff: DB,
global variables, and does session_start(). My header.php looks like this:

#header.php
$cookie_life = (86400 * 7); // Cookies last for seven days
session_set_cookie_params($cookie_life,"/",".domain.com",true);
session_start();

This is called globally in *all* my scripts. In another script I'd
really like to set the session to expire after the browser closes if a
uses clicks "public terminal" or something.

I thought I could just set the session cookie to expire after the
browser closes. Can I override the already started session by doing
something like this in my index.php:

#index.php
include('header.php');
setcookie(session_name(), '', 0 ,"/",".domain.com");

When I do this the session expires IMMEDIATELY. I must be missing something?


Simple answer -- put session_start() at the start of your code -- first line.

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] executing external php script

2011-03-03 Thread tedd

At 5:14 PM +0900 3/2/11, ƒAƒ-ƒxƒ-ƒg wrote:

hi!

what I want to do is execute php script and don't  wait for output.
found something like this
-
> /dev/null 2>&1 &`;

?>


text



-

it works but I 'm curious about php syntax ,is it correct way to do that?
or maybe there is better solution.

Thanks for any advice.

Best regards,
Albert



Albert:

Sure, try this:

http://www.webbytedd.com/bb/php-run-php/

The code is there.

Cheers,

tedd


--
---
http://sperling.com/

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



[PHP] Overriding session length in existing session?

2011-03-03 Thread Scott Baker
I have a global header.php file that sets up a bunch of stuff: DB,
global variables, and does session_start(). My header.php looks like this:

#header.php
$cookie_life = (86400 * 7); // Cookies last for seven days
session_set_cookie_params($cookie_life,"/",".domain.com",true);
session_start();

This is called globally in *all* my scripts. In another script I'd
really like to set the session to expire after the browser closes if a
uses clicks "public terminal" or something.

I thought I could just set the session cookie to expire after the
browser closes. Can I override the already started session by doing
something like this in my index.php:

#index.php
include('header.php');
setcookie(session_name(), '', 0 ,"/",".domain.com");

When I do this the session expires IMMEDIATELY. I must be missing something?

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



Re: [PHP] something about dates in mysql

2011-03-03 Thread Webforlaget.dk
In this case $mth, $day, $year is userinput that needs to be validated 
before use. thanks for all help, the quotes proved helpfull


Med venlig hilsen

Rolf Brejner
Web-forlaget.dk
- Original Message - 
From: "Richard Quadling" 

To: "Alex" 
Cc: 
Sent: Thursday, March 03, 2011 2:13 PM
Subject: Re: [PHP] something about dates in mysql


On 3 March 2011 12:33, Alex  wrote:
Just a correction, dates in mysql are not strings by any means, they are 
stored in 3 bytes (date and time or 8 bytes for datetime) and that's 
nowhere enough for a string, however the representation of the date is a 
formatted string, so for all intents and purposes any comparison to a date 
field should be using quotes like mentioned already.

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Nathan Rixham  wrote:

Richard Quadling wrote: > On 3 March 2011 10:09, Webforlaget.dk 
 wrote: >> I need help to know Why this dont work ? 
 >> >>_
>> $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year)); >> >> $sql 
>> = "SELECT id,case,startdate,enddate FROM table WHERE 
>> startdate<=$thisdate AND enddate>=$thisdate ORDER BY startdate"; >> 
>>  >>_
>> The result should be an array whith open cases at $thisdate, but 
>> nothing appear. >> >> Is it something about dates in mysql ? >> >> 
>> Thanks for any advice. >> >> Best regards, >> >> Venlige hilsner >> 
>>  >> Rolf Brejner > > I think that dates in SQL statements need to be 
>> in the quotes as they > are strings and not integers. > > So, try ... 
>>  > > $sql = "SELECT id,case,startdate,enddate FROM table WHERE > 
>> startdate<='$thisdate' AND enddate>='$thisdate' ORDER BY startdate"; 
>>  > > I'm surprised you don't get an error > > Ah. As it stands, 
>> the SQL is something like ... > > WHERE startdate <= 2010 - 3 - 3 > > 
>> So, probably the actual test that is being executed is  > > WHERE 
>> startdate <= 2004 > > Which, for a date stamp will never return 
>> anything sensible. yes, and remember the DATE and FROM_UNIXTIME mysql 
>> functions too. -- PHP General Mailing List (http://www.php.net/) To 
>> unsubscribe, visit: http://www.php.net/unsub.php





I didn't intend to suggest that dates in mysql were STORED as strings,
just that in the SQL Statement they were treated as strings.



--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
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] Check for open file

2011-03-03 Thread Ashley M. Kirchner
> As far as I was aware, if you're in the middle of writing to a file and 
> another
> script was attempting to write to it, the OS would prevent that as you had an
> open lock on it.
> 
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

I guess I would have to test that.


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



Re: [PHP] Somewhat OT - Stored Procedures

2011-03-03 Thread Nathan Nobbe
On Thu, Mar 3, 2011 at 12:59 PM, Paul M Foster wrote:

> On Thu, Mar 03, 2011 at 11:30:49AM -0700, Nathan Nobbe wrote:
>
> > Hey gang,
> >
> > (Yes Tedd, I like your style, when it pertains to how you address the
> list
> > :))
> >
> > I have a new curiosity that's arisen as a result of a new contract I'm
> > working on, I'd like to bounce around some thoughts off the list and see
> > what you folks think if interested.
> >
> > The topic at hand is stored procedures.  Frankly, I've hardly ever even
> seen
> > these in use, and what I'm trying to figure out are good rules of thumb
> as
> > to where / when / how they are best used in application development.
> >
> > Also, bear in mind that personally I tend to favor OO paradigms for
> > application development so would prefer feedback that incorporates that
> > tendency.
> >
> > Initial thoughts are
> >
> > Bad:
> > . Not well suited for ORM, particularly procedures which return multiple
> > result sets consisting of columns from multiple tables
> > . Greater potential for duplicated logic, I think this comes down to a
> well
> > defined set of rules for any given application, read: convention required
> > for success
> > . Scripting languages are vendor specific, and likely most application
> > developers have a limited understanding thereof
> >
> > Good:
> > . Better performance
> > . 
> >
> > I've also done some reading on MSSQL vs. MySQL and found that the former
> > offers much more features.  I've also read that most databases only see
> > roughly 40% of the feature sets being used for typical applications in
> the
> > wild, and would agree from personal experience it is accurate.
> >
> > >>From my standpoint MySQL is popular because the features it offers are
> the
> > features folks are really looking, one of those 80/20 things...
> >
> > I stumbled into this link on a google search, it's from '04 but looks to
> be
> > relevant to this day
> >
> >
> http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
> >
> > Your thoughts appreciated,
>
> I've done a lot of work with databases, and never used stored
> procedures. I'm not quite sure why anyone would graft a bunch of
> computational gear on top of a database engine designed to store and
> retrieve data. Let the engine do what it does best. Leave PHP or C to
> Python to do the other stuff.
>

Paul, I tend to agree with you here.  The one exception that makes sense to
me is super huge data sets.  I used to ride the bus w/ a guy who was
scripting Oracle for a big insurance company.


> Another point: I once had a boss tell me that programmers were typically
> weak on database. I suspect they would gain some expertise if they were
> forced to consider database architecture and SQL in writing apps. Stored
> procedures would tend to make the database more opaque.
>

I think there is merit to this.  But by the time you've got some triggers
and views going I'm not so sure the procedures are worth it.  It seems to me
like things are starting to get heavy on the db side of the fence at that
point, but of course that opinion is arbitrary.  A couple companies back we
were pretty heavy into cascading deletes and triggers, and I gained an
appreciation for them in terms of application development.

It seems that part of the impetus for stored procedures is the horror
> that DBAs have of random programmers issuing hack-laden SQL to their
> precious databases. My question: you've got backups, right? And any bad
> SQL should be taken care of before an app goes out the door. It's the
> programmer's responsibility to ensure that nothing he does can hack up
> the database. That includes parameterizing queries and vetting user data
> properly.
>

I think it's nice to have a full-fledged DBA if the biz can afford one.  I
tend to also worry about the other way round on this one, namely if the DBA
folks are getting their hands into application logic albiet stored
procedures.  That sort of arrangement is nothing short of disturbing to me.

Anyway, just some thoughts. Also, please consider PostgreSQL in addition
> to MySQL and MSSQL.
>

I've often discussed Postgre, but end up considering it for specific needs
more than anything.  Best use I ever had for it was a backend for Bind with
a php front-end

http://antdns.sourceforge.net/

Needed a little hacking to get it going, but it was pretty sweet!  We also
chose Postgre for a data warehouse at one company with a large dataset.  I
had nothing to do w/ that one though ;)

-nathan


RE: [PHP] Check for open file

2011-03-03 Thread Ashley Sheridan
On Thu, 2011-03-03 at 15:29 -0500, Steve Staples wrote:

> On Thu, 2011-03-03 at 13:23 -0700, Ashley M. Kirchner wrote:
> > > Write the file with a temporary name and extension. Once the file is
> > closed,
> > > change the name to the pattern your server is looking for. Once you finish
> > > processing it, either change the name again, or move it to a different
> > > directory. Don't reuse the same file name, but add a numeric value which
> > > increases every time you create it. Keep a log of which files have been
> > > processed and any errors each one produced.
> > > 
> > > Bob McConnell
> > 
> > I can't require nor expect those copying the files into the share folder to
> > do this.  No, they will simply be grabbing a set of image files from one
> > network share and drag them into this Samba share, as is.  I'm not worried
> > with what happens when PHP picks it up (name changes, moving to a diff
> > folder, etc., etc.)  I'm only concerned with the first step ... picking up
> > the file only *after* it's done copying.
> > 
> > I can run PHP as a timed crontask, but I need to figure out a safe way for
> > it to either grab a file or leave it alone because it's not done yet.
> > 
> > 
> 
> If i recall correctly, with FTP, the file is copied into the directory,
> but it is not "ready" for use... I have an application that reads the
> contents of a FTP directory, looking for files there... i've never had
> any issues where it only got a part of the file (that i know of
> anyways)... maybe the samba does the same thing?
> 
> how large are these files (or how large would the largest file typically
> be) ?   would it be worth looking at the "time" of the file, and waiting
> until that file is at least (say) 5 mintues old, then do something with
> it?  if it only takes < 1 minute to put these files on teh share, then
> maybe you can reduce that time... 
> 
> Just thinking of alternatives...
> 
> Steve
> 
> 


As far as I was aware, if you're in the middle of writing to a file and
another script was attempting to write to it, the OS would prevent that
as you had an open lock on it.

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




Re: [PHP] Somewhat OT - Stored Procedures

2011-03-03 Thread Nathan Nobbe
On Thu, Mar 3, 2011 at 12:23 PM, Steve Staples  wrote:

> On Thu, 2011-03-03 at 11:30 -0700, Nathan Nobbe wrote:
> > Hey gang,
> >
> > (Yes Tedd, I like your style, when it pertains to how you address the
> list
> > :))
> >
> > I have a new curiosity that's arisen as a result of a new contract I'm
> > working on, I'd like to bounce around some thoughts off the list and see
> > what you folks think if interested.
> >
> > The topic at hand is stored procedures.  Frankly, I've hardly ever even
> seen
> > these in use, and what I'm trying to figure out are good rules of thumb
> as
> > to where / when / how they are best used in application development.
> >
> > Also, bear in mind that personally I tend to favor OO paradigms for
> > application development so would prefer feedback that incorporates that
> > tendency.
> >
> > Initial thoughts are
> >
> > Bad:
> > . Not well suited for ORM, particularly procedures which return multiple
> > result sets consisting of columns from multiple tables
> > . Greater potential for duplicated logic, I think this comes down to a
> well
> > defined set of rules for any given application, read: convention required
> > for success
> > . Scripting languages are vendor specific, and likely most application
> > developers have a limited understanding thereof
> >
> > Good:
> > . Better performance
> > . 
> >
> > I've also done some reading on MSSQL vs. MySQL and found that the former
> > offers much more features.  I've also read that most databases only see
> > roughly 40% of the feature sets being used for typical applications in
> the
> > wild, and would agree from personal experience it is accurate.
> >
> > >From my standpoint MySQL is popular because the features it offers are
> the
> > features folks are really looking, one of those 80/20 things...
> >
> > I stumbled into this link on a google search, it's from '04 but looks to
> be
> > relevant to this day
> >
> >
> http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
> >
> > Your thoughts appreciated,
> >
> > -nathan
>

Hi Steve,

Thanks for the response.


> Would this not be a better suited question for the mysql mailing list?
>

Well they may be able to share some more database-centric advantages with
me, however, I'm interested in the merit of stored procedures from an
application perspective.  Something that Paul touched on for example would
be who is writing these procedures.  In my experience having DBA's get their
hands into application design is bad.  Also, if 1 out of 10 devs is decent
at writing stored procedures, doesn't that jeopardize the stability /
effectiveness of the team?


> regardless, I use stored procedures and functions on my mysql server
> here at work, in regards to our radius accounting packets.
>
> I will say, that it was WAY easier to send the packet dump to mysql in a
> "call()" statement, than it was to try and do all the programming
> necessary to insert the packet, calculate user usage, is the packet
> there already, etc etc etc on the radius server.  Doing it this way, we
> have 4 radius servers that just fire the same thing over to the mysql,
> and if there is a change, i do it on the mysql server, and not have to
> do the same thing on 4 different servers.
>

That makes a lot of sense in the context of Radius / MySQL communication.
 Why add another layer there, and it is food for thought in future
endeavors.  I'm more interested in how they might fit into a LAMP stack
running some hosted application though.


> views, stored procedures, triggers and functions really do have their
> purpose within mysql/mssql (and whichever sql server you are using if
> they support them), and most of the times they are forgotten about
> and/or overlooked.
>

I have seen how these tools, in particular triggers and views fit into the
equation in an application design.  Again, I think this is something which
can be marginalized if there is not a solid convention in place describing
what is to be implemented in the database layer as opposed to the
application layer.

take a look at this article:
> http://www.tonymarston.net/php-mysql/stored-procedures-are-evil.html
>

Will do.


> Good luck, and I think you may get more response from
> my...@lists.mysql.com


Considering this as well, thanks for the response!

-nathan


RE: [PHP] Check for open file

2011-03-03 Thread Steve Staples
On Thu, 2011-03-03 at 13:23 -0700, Ashley M. Kirchner wrote:
> > Write the file with a temporary name and extension. Once the file is
> closed,
> > change the name to the pattern your server is looking for. Once you finish
> > processing it, either change the name again, or move it to a different
> > directory. Don't reuse the same file name, but add a numeric value which
> > increases every time you create it. Keep a log of which files have been
> > processed and any errors each one produced.
> > 
> > Bob McConnell
> 
> I can't require nor expect those copying the files into the share folder to
> do this.  No, they will simply be grabbing a set of image files from one
> network share and drag them into this Samba share, as is.  I'm not worried
> with what happens when PHP picks it up (name changes, moving to a diff
> folder, etc., etc.)  I'm only concerned with the first step ... picking up
> the file only *after* it's done copying.
> 
> I can run PHP as a timed crontask, but I need to figure out a safe way for
> it to either grab a file or leave it alone because it's not done yet.
> 
> 

If i recall correctly, with FTP, the file is copied into the directory,
but it is not "ready" for use... I have an application that reads the
contents of a FTP directory, looking for files there... i've never had
any issues where it only got a part of the file (that i know of
anyways)... maybe the samba does the same thing?

how large are these files (or how large would the largest file typically
be) ?   would it be worth looking at the "time" of the file, and waiting
until that file is at least (say) 5 mintues old, then do something with
it?  if it only takes < 1 minute to put these files on teh share, then
maybe you can reduce that time... 

Just thinking of alternatives...

Steve


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



RE: [PHP] Check for open file

2011-03-03 Thread Ashley M. Kirchner

> Write the file with a temporary name and extension. Once the file is
closed,
> change the name to the pattern your server is looking for. Once you finish
> processing it, either change the name again, or move it to a different
> directory. Don't reuse the same file name, but add a numeric value which
> increases every time you create it. Keep a log of which files have been
> processed and any errors each one produced.
> 
> Bob McConnell

I can't require nor expect those copying the files into the share folder to
do this.  No, they will simply be grabbing a set of image files from one
network share and drag them into this Samba share, as is.  I'm not worried
with what happens when PHP picks it up (name changes, moving to a diff
folder, etc., etc.)  I'm only concerned with the first step ... picking up
the file only *after* it's done copying.

I can run PHP as a timed crontask, but I need to figure out a safe way for
it to either grab a file or leave it alone because it's not done yet.


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



RE: [PHP] Check for open file

2011-03-03 Thread Bob McConnell
From: Ashley M. Kirchner

> Is there a clean or reliable way of checking to see if a
> file is still being written to before doing anything with it?
> 
> Here's the scenario: we have a Samba share that we can copy
> files to (from within Windows or Macs).  The server picks up
> the file and does some processing of said file.  At the moment
> this is all a manual process: we copy a file into the Samba
> share, wait for that to finish then go to a web page (on the
> server) and tell it to process the file that was just copied
> into the Samba share.  I'm trying to see if there is a way to
> automate this where a file, or multiple files, get copied into
> the share and the server picks them up and process automatically
> without needing any interaction.
> 
> Can PHP detect this, or should I look into some delayed
> process of checking the file's modified time stamp versus current
> time and not touch the file till a certain threshold has been
> reached (say 30 seconds difference?).

Write the file with a temporary name and extension. Once the file is
closed, change the name to the pattern your server is looking for. Once
you finish processing it, either change the name again, or move it to a
different directory. Don't reuse the same file name, but add a numeric
value which increases every time you create it. Keep a log of which
files have been processed and any errors each one produced.

Bob McConnell

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



[PHP] Check for open file

2011-03-03 Thread Ashley M. Kirchner
 

Is there a clean or reliable way of checking to see if a
file is still being written to before doing anything with it?

 

Here's the scenario: we have a Samba share that we can copy
files to (from within Windows or Macs).  The server picks up the file and
does some processing of said file.  At the moment this is all a manual
process: we copy a file into the Samba share, wait for that to finish then
go to a web page (on the server) and tell it to process the file that was
just copied into the Samba share.  I'm trying to see if there is a way to
automate this where a file, or multiple files, get copied into the share and
the server picks them up and process automatically without needing any
interaction.

 

Can PHP detect this, or should I look into some delayed
process of checking the file's modified time stamp versus current time and
not touch the file till a certain threshold has been reached (say 30 seconds
difference?).

 

Ideas, suggestions, comments .



Re: [PHP] Somewhat OT - Stored Procedures

2011-03-03 Thread Paul M Foster
On Thu, Mar 03, 2011 at 11:30:49AM -0700, Nathan Nobbe wrote:

> Hey gang,
> 
> (Yes Tedd, I like your style, when it pertains to how you address the list
> :))
> 
> I have a new curiosity that's arisen as a result of a new contract I'm
> working on, I'd like to bounce around some thoughts off the list and see
> what you folks think if interested.
> 
> The topic at hand is stored procedures.  Frankly, I've hardly ever even seen
> these in use, and what I'm trying to figure out are good rules of thumb as
> to where / when / how they are best used in application development.
> 
> Also, bear in mind that personally I tend to favor OO paradigms for
> application development so would prefer feedback that incorporates that
> tendency.
> 
> Initial thoughts are
> 
> Bad:
> . Not well suited for ORM, particularly procedures which return multiple
> result sets consisting of columns from multiple tables
> . Greater potential for duplicated logic, I think this comes down to a well
> defined set of rules for any given application, read: convention required
> for success
> . Scripting languages are vendor specific, and likely most application
> developers have a limited understanding thereof
> 
> Good:
> . Better performance
> . 
> 
> I've also done some reading on MSSQL vs. MySQL and found that the former
> offers much more features.  I've also read that most databases only see
> roughly 40% of the feature sets being used for typical applications in the
> wild, and would agree from personal experience it is accurate.
> 
> >>From my standpoint MySQL is popular because the features it offers are the
> features folks are really looking, one of those 80/20 things...
> 
> I stumbled into this link on a google search, it's from '04 but looks to be
> relevant to this day
> 
> http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
> 
> Your thoughts appreciated,

I've done a lot of work with databases, and never used stored
procedures. I'm not quite sure why anyone would graft a bunch of
computational gear on top of a database engine designed to store and
retrieve data. Let the engine do what it does best. Leave PHP or C to
Python to do the other stuff.

Another point: I once had a boss tell me that programmers were typically
weak on database. I suspect they would gain some expertise if they were
forced to consider database architecture and SQL in writing apps. Stored
procedures would tend to make the database more opaque.

It seems that part of the impetus for stored procedures is the horror
that DBAs have of random programmers issuing hack-laden SQL to their
precious databases. My question: you've got backups, right? And any bad
SQL should be taken care of before an app goes out the door. It's the
programmer's responsibility to ensure that nothing he does can hack up
the database. That includes parameterizing queries and vetting user data
properly.

Anyway, just some thoughts. Also, please consider PostgreSQL in addition
to MySQL and MSSQL.

Paul

-- 
Paul M. Foster
http://noferblatz.com


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



RE: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-03 Thread Bob McConnell
From: Brian Dunning

> My merchant provider levies monthly fines based on
> how many of their security restrictions you fail to
> follow. I follow as many as are reasonably practical,
> but I think it's virtually impossible to follow them
> all, such as absurdly expensive (and probably unnecessary)
> hardware. IMHO, some of the restrictions are based less
> on reality and more on their security consulting firm's
> ability to frighten them. Their consulting firm's
> disclosed commissions on the fines creates an inherent
> conflict of interest. 
> 
> Goofily, my provider's fine structure does not
> differentiate between transactions that are merely
> processed on my server with no storage, and
> transactions originating from a card number stored
> on my server. 
> 
> So I have to constantly weigh the monthly fines vs.
> the cost of the upgrades vs. the amount of money that
> my various services bring in. There is no perfect
> solution.
> 
> Nevertheless, I'm very open to any suggestions
> people have for transactions requiring that I
> keep the card number (in this case, recurring
> monthly charges where the customers choose not to
> use PayPal etc. and where too many customers would
> flake or get frustrated if forced to re-enter their
> card info every month for an annoyingly small
> transaction).
> 
> Sorry this is getting a little off-topic for PHP.

Seems to me we have had similar discussions in the past, and not
necessarily on Friday.

First of all, you probably want to talk to your lawyer about the
potential conflict of interest. That may need to be forwarded to a
regulatory office or Attorney General for investigation.

Second, do their rules conform to the OWASP recommendations and standard
PCI guidelines? If they are deviating from those, or adding ridiculous
requirements simply to squeeze a few extra pesos out of you, you might
also want to ask your lawyer about them.

Next, do they have a storage vault for credit card numbers that you can
access. There shouldn't be any need for you to store them. We put
numbers in our processor's vault and they give us a hash index to access
them in the future. We use that for recurring charges and as a
convenience so customers don't have to enter them every time they make a
payment.

And finally, even if they do follow the PCI regulations, you have to
remember that the primary purpose of those regulations is to deflect
liability from them to you when there is a problem. All they need to do
is document one instance where you don't follow the rules and they are
off the hook for damages. Guess where that puts you.

Bob McConnell

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



Re: [PHP] Somewhat OT - Stored Procedures

2011-03-03 Thread Steve Staples
On Thu, 2011-03-03 at 11:30 -0700, Nathan Nobbe wrote:
> Hey gang,
> 
> (Yes Tedd, I like your style, when it pertains to how you address the list
> :))
> 
> I have a new curiosity that's arisen as a result of a new contract I'm
> working on, I'd like to bounce around some thoughts off the list and see
> what you folks think if interested.
> 
> The topic at hand is stored procedures.  Frankly, I've hardly ever even seen
> these in use, and what I'm trying to figure out are good rules of thumb as
> to where / when / how they are best used in application development.
> 
> Also, bear in mind that personally I tend to favor OO paradigms for
> application development so would prefer feedback that incorporates that
> tendency.
> 
> Initial thoughts are
> 
> Bad:
> . Not well suited for ORM, particularly procedures which return multiple
> result sets consisting of columns from multiple tables
> . Greater potential for duplicated logic, I think this comes down to a well
> defined set of rules for any given application, read: convention required
> for success
> . Scripting languages are vendor specific, and likely most application
> developers have a limited understanding thereof
> 
> Good:
> . Better performance
> . 
> 
> I've also done some reading on MSSQL vs. MySQL and found that the former
> offers much more features.  I've also read that most databases only see
> roughly 40% of the feature sets being used for typical applications in the
> wild, and would agree from personal experience it is accurate.
> 
> >From my standpoint MySQL is popular because the features it offers are the
> features folks are really looking, one of those 80/20 things...
> 
> I stumbled into this link on a google search, it's from '04 but looks to be
> relevant to this day
> 
> http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
> 
> Your thoughts appreciated,
> 
> -nathan

Would this not be a better suited question for the mysql mailing list?

regardless, I use stored procedures and functions on my mysql server
here at work, in regards to our radius accounting packets.

I will say, that it was WAY easier to send the packet dump to mysql in a
"call()" statement, than it was to try and do all the programming
necessary to insert the packet, calculate user usage, is the packet
there already, etc etc etc on the radius server.  Doing it this way, we
have 4 radius servers that just fire the same thing over to the mysql,
and if there is a change, i do it on the mysql server, and not have to
do the same thing on 4 different servers.

views, stored procedures, triggers and functions really do have their
purpose within mysql/mssql (and whichever sql server you are using if
they support them), and most of the times they are forgotten about
and/or overlooked.

take a look at this article:
http://www.tonymarston.net/php-mysql/stored-procedures-are-evil.html

Good luck, and I think you may get more response from
my...@lists.mysql.com

Steve.


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



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-03 Thread Brian Dunning
That's a great suggestion. I will try this and report back. It's also been 
suggested to me that I should have base64_encoded the encryptions before 
storing them in MySQL, so I'll try this option at the same time.

On Mar 1, 2011, at 2:04 PM, Ashley Sheridan wrote:

> Onto the problem of the data you already have. Do you have a test-case that 
> causes the problem? Try running a bunch of fictitious numbers against your 
> code and store the results in your DB. For a decent test, you'll want to test 
> it against a lot of numbers, store each one in plain format in the DB (use 
> the same character encoding as you already have to see if that's part of the 
> issue) alongside the encrypted version, then retrieve the encrypted value and 
> test it against the original. It may take only a few dozen numbers to show 
> the problem, it may take a thousand, but just let it run until it finds a 
> problem.



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



Re: [PHP] Help! Made a boo-boo encrypting credit cards

2011-03-03 Thread Brian Dunning
My merchant provider levies monthly fines based on how many of their security 
restrictions you fail to follow. I follow as many as are reasonably practical, 
but I think it's virtually impossible to follow them all, such as absurdly 
expensive (and probably unnecessary) hardware. IMHO, some of the restrictions 
are based less on reality and more on their security consulting firm's ability 
to frighten them. Their consulting firm's disclosed commissions on the fines 
creates an inherent conflict of interest. 

Goofily, my provider's fine structure does not differentiate between 
transactions that are merely processed on my server with no storage, and 
transactions originating from a card number stored on my server. 

So I have to constantly weigh the monthly fines vs. the cost of the upgrades 
vs. the amount of money that my various services bring in. There is no perfect 
solution.

Nevertheless, I'm very open to any suggestions people have for transactions 
requiring that I keep the card number (in this case, recurring monthly charges 
where the customers choose not to use PayPal etc. and where too many customers 
would flake or get frustrated if forced to re-enter their card info every month 
for an annoyingly small transaction).

Sorry this is getting a little off-topic for PHP.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Somewhat OT - Stored Procedures

2011-03-03 Thread Nathan Nobbe
Hey gang,

(Yes Tedd, I like your style, when it pertains to how you address the list
:))

I have a new curiosity that's arisen as a result of a new contract I'm
working on, I'd like to bounce around some thoughts off the list and see
what you folks think if interested.

The topic at hand is stored procedures.  Frankly, I've hardly ever even seen
these in use, and what I'm trying to figure out are good rules of thumb as
to where / when / how they are best used in application development.

Also, bear in mind that personally I tend to favor OO paradigms for
application development so would prefer feedback that incorporates that
tendency.

Initial thoughts are

Bad:
. Not well suited for ORM, particularly procedures which return multiple
result sets consisting of columns from multiple tables
. Greater potential for duplicated logic, I think this comes down to a well
defined set of rules for any given application, read: convention required
for success
. Scripting languages are vendor specific, and likely most application
developers have a limited understanding thereof

Good:
. Better performance
. 

I've also done some reading on MSSQL vs. MySQL and found that the former
offers much more features.  I've also read that most databases only see
roughly 40% of the feature sets being used for typical applications in the
wild, and would agree from personal experience it is accurate.

>From my standpoint MySQL is popular because the features it offers are the
features folks are really looking, one of those 80/20 things...

I stumbled into this link on a google search, it's from '04 but looks to be
relevant to this day

http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

Your thoughts appreciated,

-nathan


Re: [PHP] Delaying $(document).ready() in jQuery until php script finish OT

2011-03-03 Thread Richard Quadling
On 3 March 2011 17:25, Ashley Sheridan  wrote:
> "Jay Blanchard"  wrote:
>
>>[snip]
>>What I don't get about the question is, is the document.ready()
>>shouldn't fire, until the page has completely loaded, and if the PHP
>>script is still running, the "document" shouldn't be "ready" yet,
>>should
>>it?
>>[/snip]
>>
>>The document ready function fires once the DOM is loaded - which might
>>not be the entire page (images could still be loading, etc.)
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>
> That should still be after php has done its stuff, as php is all on the 
> server, javascript is on the client.
>
>
> Thanks
> Ash
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can push content using flush() so that the browser can get some
content before the script has finished.

You can use this technique as a poor-mans way of passing the top part
of a page with a "Loading" message which is hidden once the remaining
content is ready.

Different browsers and servers will require a certain amount or will
buffer things anyway, so YMMV.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish OT

2011-03-03 Thread Ashley Sheridan
"Jay Blanchard"  wrote:

>[snip]
>What I don't get about the question is, is the document.ready()
>shouldn't fire, until the page has completely loaded, and if the PHP
>script is still running, the "document" shouldn't be "ready" yet,
>should
>it?
>[/snip]
>
>The document ready function fires once the DOM is loaded - which might
>not be the entire page (images could still be loading, etc.)
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

That should still be after php has done its stuff, as php is all on the server, 
javascript is on the client.


Thanks
Ash
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish OT

2011-03-03 Thread Jay Blanchard
[snip]
What I don't get about the question is, is the document.ready()
shouldn't fire, until the page has completely loaded, and if the PHP
script is still running, the "document" shouldn't be "ready" yet, should
it?
[/snip]

The document ready function fires once the DOM is loaded - which might
not be the entire page (images could still be loading, etc.)

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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread HallMarc Websites


-Original Message-
From: Steve Staples [mailto:sstap...@mnsi.net] 
Sent: Thursday, March 03, 2011 11:00 AM
To: php-general@lists.php.net
Subject: RE: [PHP] Delaying $(document).ready() in jQuery until php script 
finish

On Thu, 2011-03-03 at 10:42 -0500, HallMarc Websites wrote:
>> Maybe I misread this and it seems to me he is asking how they could 
>> trigger the jQuery event after the necessary PHP script is called. 
>> Maybe it is being over-thought, have you tried placing the javascript 
>> call after the PHP script? Maybe wrap it in a conditional statement 
>> that isn't satisfied until whatever necessary condition is met?

>Could also echo the jQuery at the bottom of the PHP script, so that way, no 
>matter what, when the PHP is done, it will echo out (even if
>buffered) once the script is completed is "thing".

>What I don't get about the question is, is the document.ready() shouldn't 
>fire, until the page has completely loaded, and if the PHP script is still 
>>running, the "document" shouldn't be "ready" yet, should it?

>Steve

Well, at this point that is a JavaScript question and best left to the 
appropriate list. 





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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread Steve Staples
On Thu, 2011-03-03 at 10:42 -0500, HallMarc Websites wrote:
> Maybe I misread this and it seems to me he is asking how they could trigger
> the jQuery event after the necessary PHP script is called. Maybe it is being
> over-thought, have you tried placing the javascript call after the PHP
> script? Maybe wrap it in a conditional statement that isn't satisfied until
> whatever necessary condition is met?

Could also echo the jQuery at the bottom of the PHP script, so that way,
no matter what, when the PHP is done, it will echo out (even if
buffered) once the script is completed is "thing".

What I don't get about the question is, is the document.ready()
shouldn't fire, until the page has completely loaded, and if the PHP
script is still running, the "document" shouldn't be "ready" yet, should
it?

Steve




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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread HallMarc Websites
Maybe I misread this and it seems to me he is asking how they could trigger
the jQuery event after the necessary PHP script is called. Maybe it is being
over-thought, have you tried placing the javascript call after the PHP
script? Maybe wrap it in a conditional statement that isn't satisfied until
whatever necessary condition is met?
 


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



RE: [PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread Jay Blanchard
[snip]
Just one: ask on a jQuery list.  Just because PHP is running
somewhere in the mix doesn't mean it's appropriate for this list.
[/snip]

Agreed. The list for jQuery is http://forum.jquery.com

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



Re: [PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread Daniel Brown
On Thu, Mar 3, 2011 at 09:52, Richard Sharp  wrote:
> I have been banging my head trying to figure out how to delay
> $(document).ready() command until my php script finish running and load
> data into a csv file.  Any ideas

Just one: ask on a jQuery list.  Just because PHP is running
somewhere in the mix doesn't mean it's appropriate for this list.

-- 

Network Infrastructure Manager
http://www.php.net/

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



[PHP] Delaying $(document).ready() in jQuery until php script finish

2011-03-03 Thread Richard Sharp
I have been banging my head trying to figure out how to delay
$(document).ready() command until my php script finish running and load
data into a csv file.  Any ideas

 

Thanks

 

Richard Sharp

Database Administrator

PH: 316-942-8604 ext 108

 

Tenderness is what love looks like in private, Justice is what love
looks like in public - Cornel West

I am what I am because of who we all are - Ubuntu

 

 



[PHP] PHP 5.3.6RC2 Released for Testing

2011-03-03 Thread Johannes Schlüter
The second release candidates of 5.3.6 was just released for testing and
can be downloaded here:

http://downloads.php.net/johannes/php-5.3.6RC2.tar.bz2 (md5sum:
f870685b8715600e056d2dbb22920576)
http://downloads.php.net/johannes/php-5.3.6RC2.tar.gz (md5sum:
32e88f8a2dd1e756d386b7fe625c7e8b)

The windows binaries are available at: http://windows.php.net/qa/
Windows users please mind that we don't provide VS6 builds anymore.

This is a step in the release process of this versions and goal
is having a final version by next week. Majority of the changes are of
the "bug fix" variety. To ensure that the release is solid, please test
this RC against your code base and report any problems that you
encounter.

Johannes Schlüter
PHP 5.3 Release Master



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



Re: [PHP] something about dates in mysql

2011-03-03 Thread Richard Quadling
On 3 March 2011 12:33, Alex  wrote:
> Just a correction, dates in mysql are not strings by any means, they are 
> stored in 3 bytes (date and time or 8 bytes for datetime) and that's nowhere 
> enough for a string, however the representation of the date is a formatted 
> string, so for all intents and purposes any comparison to a date field should 
> be using quotes like mentioned already.
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
> Nathan Rixham  wrote:
>
> Richard Quadling wrote: > On 3 March 2011 10:09, Webforlaget.dk 
>  wrote: >> I need help to know Why this dont work ? >> 
> >>_
>>> >> $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year)); >> >> $sql = 
>>> >> "SELECT id,case,startdate,enddate FROM table WHERE startdate<=$thisdate 
>>> >> AND enddate>=$thisdate ORDER BY startdate"; >> 
>>> >> >>_
>>> >> The result should be an array whith open cases at $thisdate, but nothing 
>>> >> appear. >> >> Is it something about dates in mysql ? >> >> Thanks for 
>>> >> any advice. >> >> Best regards, >> >> Venlige hilsner >> >> Rolf Brejner 
>>> >> > > I think that dates in SQL statements need to be in the quotes as 
>>> >> they > are strings and not integers. > > So, try ... > > $sql = "SELECT 
>>> >> id,case,startdate,enddate FROM table WHERE > startdate<='$thisdate' AND 
>>> >> enddate>='$thisdate' ORDER BY startdate"; > > I'm surprised you don't 
>>> >> get an error > > Ah. As it stands, the SQL is something like ... > > 
>>> >> WHERE startdate <= 2010 - 3 - 3 > > So, probably the actual test that is 
>>> >> being executed is  > > WHERE startdate <= 2004 > > Which, for a date 
>>> >> stamp will never return anything sensible. yes, and remember the DATE 
>>> >> and FROM_UNIXTIME mysql functions too. -- PHP General Mailing List 
>>> >> (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I didn't intend to suggest that dates in mysql were STORED as strings,
just that in the SQL Statement they were treated as strings.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] something about dates in mysql

2011-03-03 Thread Gerardo Benitez
Hi Webforlaget!

$thisdate is today?

$today = date('Y-m-d");

else

why, you dont use $thisdate as:
$thisdate = "$year-$mth-$day" ?

use quotes for $thisdate in sql query.

Regards.
Gerardo


On Thu, Mar 3, 2011 at 7:09 AM, Webforlaget.dk  wrote:

> I need help to know Why this dont work ?
>
> -
>
>  $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year));
>
>  $sql  = "SELECT id,case,startdate,enddate FROM table WHERE
> startdate<=$thisdate AND enddate>=$thisdate ORDER BY startdate";
>
> -
>
> The result should be an array whith open cases at $thisdate, but nothing
> appear.
>
> Is it something about dates in mysql ?
>
> Thanks for any advice.
>
> Best regards,
>
> Venlige hilsner
>
> Rolf Brejner




-- 
Gerardo Benitez
-
www.webseficientes.com.ar
Diseño web, programación, Seo


Re: [PHP] something about dates in mysql

2011-03-03 Thread Alex
Just a correction, dates in mysql are not strings by any means, they are stored 
in 3 bytes (date and time or 8 bytes for datetime) and that's nowhere enough 
for a string, however the representation of the date is a formatted string, so 
for all intents and purposes any comparison to a date field should be using 
quotes like mentioned already. 
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Nathan Rixham  wrote:

Richard Quadling wrote: > On 3 March 2011 10:09, Webforlaget.dk 
 wrote: >> I need help to know Why this dont work ? >> 
>>_
>> >> $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year)); >> >> $sql = 
>> >> "SELECT id,case,startdate,enddate FROM table WHERE startdate<=$thisdate 
>> >> AND enddate>=$thisdate ORDER BY startdate"; >> 
>> >> >>_
>> >> The result should be an array whith open cases at $thisdate, but nothing 
>> >> appear. >> >> Is it something about dates in mysql ? >> >> Thanks for any 
>> >> advice. >> >> Best regards, >> >> Venlige hilsner >> >> Rolf Brejner > > 
>> >> I think that dates in SQL statements need to be in the quotes as they > 
>> >> are strings and not integers. > > So, try ... > > $sql = "SELECT 
>> >> id,case,startdate,enddate FROM table WHERE > startdate<='$thisdate' AND 
>> >> enddate>='$thisdate' ORDER BY startdate"; > > I'm surprised you don't get 
>> >> an error > > Ah. As it stands, the SQL is something like ... > > 
>> >> WHERE startdate <= 2010 - 3 - 3 > > So, probably the actual test that is 
>> >> being executed is  > > WHERE startdate <= 2004 > > Which, for a date 
>> >> stamp will never return anything sensible. yes, and remember the DATE and 
>> >> FROM_UNIXTIME mysql functions too. -- PHP General Mailing List 
>> >> (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 



Re: [PHP] something about dates in mysql

2011-03-03 Thread Nathan Rixham

Richard Quadling wrote:

On 3 March 2011 10:09, Webforlaget.dk  wrote:

I need help to know Why this dont work ?

-

 $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year));

 $sql  = "SELECT id,case,startdate,enddate FROM table WHERE startdate<=$thisdate AND 
enddate>=$thisdate ORDER BY startdate";

-

The result should be an array whith open cases at $thisdate, but nothing appear.

Is it something about dates in mysql ?

Thanks for any advice.

Best regards,

Venlige hilsner

Rolf Brejner


I think that dates in SQL statements need to be in the quotes as they
are strings and not integers.

So, try ...

$sql  = "SELECT id,case,startdate,enddate FROM table WHERE
startdate<='$thisdate' AND enddate>='$thisdate' ORDER BY startdate";

I'm surprised you don't get an error

Ah. As it stands, the SQL is something like ...

WHERE startdate <= 2010 - 3 - 3

So, probably the actual test that is being executed is 

WHERE startdate <= 2004

Which, for a date stamp will never return anything sensible.


yes, and remember the DATE and FROM_UNIXTIME mysql functions too.

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



Re: [PHP] something about dates in mysql

2011-03-03 Thread Richard Quadling
On 3 March 2011 10:09, Webforlaget.dk  wrote:
> I need help to know Why this dont work ?
>
> -
>
>  $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year));
>
>  $sql  = "SELECT id,case,startdate,enddate FROM table WHERE 
> startdate<=$thisdate AND enddate>=$thisdate ORDER BY startdate";
>
> -
>
> The result should be an array whith open cases at $thisdate, but nothing 
> appear.
>
> Is it something about dates in mysql ?
>
> Thanks for any advice.
>
> Best regards,
>
> Venlige hilsner
>
> Rolf Brejner

I think that dates in SQL statements need to be in the quotes as they
are strings and not integers.

So, try ...

$sql  = "SELECT id,case,startdate,enddate FROM table WHERE
startdate<='$thisdate' AND enddate>='$thisdate' ORDER BY startdate";

I'm surprised you don't get an error

Ah. As it stands, the SQL is something like ...

WHERE startdate <= 2010 - 3 - 3

So, probably the actual test that is being executed is 

WHERE startdate <= 2004

Which, for a date stamp will never return anything sensible.

Regards,

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



[PHP] something about dates in mysql

2011-03-03 Thread Webforlaget.dk
I need help to know Why this dont work ?

-

 $thisdate =date("Y-m-d",mktime(0,0,0,$mth, $day, $year)); 

 $sql  = "SELECT id,case,startdate,enddate FROM table WHERE 
startdate<=$thisdate AND enddate>=$thisdate ORDER BY startdate";

-

The result should be an array whith open cases at $thisdate, but nothing appear.

Is it something about dates in mysql ?

Thanks for any advice.

Best regards,
 
Venlige hilsner

Rolf Brejner