php-general Digest 20 Jul 2006 16:17:59 -0000 Issue 4249

Topics (messages 239604 through 239635):

Re: ROZ pdf
        239604 by: Chris

Re: Open Source mailinglist?
        239605 by: Paul Scott

doubt - session file size
        239606 by: suresh kumar
        239607 by: Robert Cummings
        239608 by: Chris
        239634 by: Jochem Maas

Re: session_start/session_write_close creates multiple sessioncookieheaders. 
How to fix this.
        239609 by: Mathijs
        239610 by: Mathijs

Re: Return XML using PHP and Content-Type with UTF-8 breaks the UTF-8
        239611 by: Mathijs
        239612 by: Mathijs
        239613 by: nicolas figaro

search string
        239614 by: weetat

Re: Basic PHP knowledge test
        239615 by: Finner, Doug
        239618 by: Joe Wollard
        239619 by: John Nichel
        239620 by: John Nichel
        239621 by: John Meyer
        239624 by: Ray Hauge
        239625 by: Jochem Maas
        239626 by: Austin Denyer
        239627 by: Robert Cummings

Difference between 2 time entries
        239616 by: Chris Grigor
        239617 by: nicolas figaro
        239622 by: Chris Grigor
        239623 by: John Meyer

Session breaks when form data submitted
        239628 by: Jeffrey
        239629 by: Ray Hauge

headers and newline at end of script
        239630 by: Martin Marques
        239631 by: Jochem Maas
        239632 by: John Nichel
        239633 by: Robert Cummings

Setting cookie on one domain for an other domain
        239635 by: Peter Lauri

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

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


----------------------------------------------------------------------
--- Begin Message ---
weetat wrote:
Hi all,

I am using EZpdf class to create pdf in mysql database . The Ezpdf class is open source tool for auto-creation of pdf in php , the link is http://sourceforge.net/projects/pdf-php

I have the problem with tool , the pdf page is blank , eventhough have some data in my MySQL database .

Ask on their forums.

http://sourceforge.net/forum/?group_id=45168

We don't know the code so have no idea what's going on.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Wed, 2006-07-19 at 17:03 -0500, Jay Blanchard wrote:
> I can't seem to find any place on the net where you can discuss Open 
> Source-related questions in general???
> [/snip]
> 
> Don't Sourceforge and Freshmeat have lists?
> 

You could also join your local LUG, or a site like http://fsiu.uwc.ac.za
which is focused on PHP, Free Software and capacity building in Africa.
http://avoir.uwc.ac.za is similar, although tending more towards the
capacity and skills building side of things.

There are/should be mailing lists for most open projects that people
really don't mind you lurking on. Choose one and have some fun.

--Paul

All Email originating from UWC is covered by disclaimer  
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

--- End Message ---
--- Begin Message ---
Hi,
     I am having one doubt,i am using session variable for storing details.but 
i am afraid if there is around 10000 users,wherether session will be able to 
store all the  datas of 10000 users,as i know  abt session is that a temporary 
file will be created in /tmp directory with session id name,i dont know how 
much data that the session file will handle.
   
                                                                    A.suresh

                                
---------------------------------
 Find out what India is talking about on Yahoo! Answers India.
 Send FREE SMS from New Yahoo! Messenger to Mobile: Download NOW!

--- End Message ---
--- Begin Message ---
On Thu, 2006-07-20 at 01:03, suresh kumar wrote:
> Hi,
> I am having one doubt,i am using session variable for storing details.
> but i am afraid if there is around 10000 users,wherether session will
> be able to store all the  datas of 10000 users,as i know  abt session
> is that a temporary file will be created in /tmp directory with
> session id name,i dont know how much data that the session file will
> handle.

See your php.ini for setting the path to where you want session files
stored. I don't believe there's a limit to the size of your session
files, that said, there IS a limit as to how much memory PHP is allowed
to consume, and this obviously places an implicit limit on the size of
the session files.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Thu, 2006-07-20 at 01:03, suresh kumar wrote:
Hi,
I am having one doubt,i am using session variable for storing details.
but i am afraid if there is around 10000 users,wherether session will
be able to store all the  datas of 10000 users,as i know  abt session
is that a temporary file will be created in /tmp directory with
session id name,i dont know how much data that the session file will
handle.

See your php.ini for setting the path to where you want session files
stored. I don't believe there's a limit to the size of your session
files, that said, there IS a limit as to how much memory PHP is allowed
to consume, and this obviously places an implicit limit on the size of
the session files.

There could also be a limit on the number of files you can have per directory..

Maybe it's better to use your own custom session handler and store everything in a database.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
> Robert Cummings wrote:
>> On Thu, 2006-07-20 at 01:03, suresh kumar wrote:
>>> Hi,
>>> I am having one doubt,i am using session variable for storing details.
>>> but i am afraid if there is around 10000 users,wherether session will
>>> be able to store all the  datas of 10000 users,as i know  abt session
>>> is that a temporary file will be created in /tmp directory with
>>> session id name,i dont know how much data that the session file will
>>> handle.
>>
>> See your php.ini for setting the path to where you want session files
>> stored. I don't believe there's a limit to the size of your session
>> files, that said, there IS a limit as to how much memory PHP is allowed
>> to consume, and this obviously places an implicit limit on the size of
>> the session files.
> 
> There could also be a limit on the number of files you can have per
> directory..

maybe there could be a limit to the number of emails the OP is allowed
to send without ever replying to anyone who offers a possible answer to
his question. :-)

> 
> Maybe it's better to use your own custom session handler and store
> everything in a database.
> 

--- End Message ---
--- Begin Message ---
Chris wrote:
Mathijs wrote:
Chris wrote:
Mathijs wrote:
Hello again,

I Use session_write_close() so the page loads quicker because i use session on multiple place.
This because session has protection for race conditions.

Now it works very well and i don't have any problems at all.
I only see that there are multiple session cookie headers set.
I Personally think that one is enough :P.

How can i make it so that it just sets just one and not set this header every time i call session_start or session_write_close.
Because i don't know when the cookie is set.

I think this will be an either/or situation.

Either it only sends one session cookie header and you don't use session_write_close all over the place..

or, it sends multiple cookies and you do use session_write_close all over the place.

The internals of php would set this behaviour, not something you can change without changing the C code.


Hmmm...
I find it kinda strange that it sets the same uniqueId with the same session name more then once. It would be logical to just have one.. And overwrite the previous session cookie.
Any other thing would be an programmers fault in my opinion.
Because you can't have more then one session id per session cookie name.
Also, the browser won't send all the cookies back.
This is just useless overhead.

But it seems that i have to live with it (for now).
I think ill report this as an bug to PHP.

Doubt you'll get very far.

I could open 10 tabs in firefox and I'll have the same session id in each one, but they'll all be on different pages doing different things.

Even in IE, if I open a new page I'll get the same session id in both browser windows.

That is a good thing.
But the problem is that there are like 5 or 6 headers for one request.


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0629-1, 07/19/2006
Tested on: 7/20/2006 8:56:33 AM
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Chris wrote:
Mathijs wrote:
Chris wrote:
Mathijs wrote:
Hello again,

I Use session_write_close() so the page loads quicker because i use session on multiple place.
This because session has protection for race conditions.

Now it works very well and i don't have any problems at all.
I only see that there are multiple session cookie headers set.
I Personally think that one is enough :P.

How can i make it so that it just sets just one and not set this header every time i call session_start or session_write_close.
Because i don't know when the cookie is set.

I think this will be an either/or situation.

Either it only sends one session cookie header and you don't use session_write_close all over the place..

or, it sends multiple cookies and you do use session_write_close all over the place.

The internals of php would set this behaviour, not something you can change without changing the C code.


Hmmm...
I find it kinda strange that it sets the same uniqueId with the same session name more then once. It would be logical to just have one.. And overwrite the previous session cookie.
Any other thing would be an programmers fault in my opinion.
Because you can't have more then one session id per session cookie name.
Also, the browser won't send all the cookies back.
This is just useless overhead.

But it seems that i have to live with it (for now).
I think ill report this as an bug to PHP.

Doubt you'll get very far.

I could open 10 tabs in firefox and I'll have the same session id in each one, but they'll all be on different pages doing different things.

Even in IE, if I open a new page I'll get the same session id in both browser windows.

That is a good thing.
But the problem is that there are like 5 or 6 headers for one request.



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0629-1, 07/19/2006
Tested on: 7/20/2006 8:56:39 AM
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Ray Hauge wrote:
On Wednesday 19 July 2006 09:27, Mathijs wrote:
Hello there,

I Have an problem with UTF-8 and XML.

I Output perfect XML (according to IE, Opera and Firefox).
I use the Content-Type header with "text/xml; charset=utf-8".
For some reason this breaks UTF-8 output.
When i remove it it works. But i need the text/xml header.

If i save an document as .xml with the same contents as UTF-8 it works.

Is this a known problem?

Thx in advanced.

I would try just specifying UTF-8 in the XML header, and remove the charset from the content-type header, and just have the text/xml.

<?xml version="1.0" encoding="utf-8"?>

HTH


I have tryed this. But this also breaks the UTF-8.
When i put it back to text/html it works like it should :S.

I Realy have no clue anymore.


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0629-1, 07/19/2006
Tested on: 7/20/2006 8:57:39 AM
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Ray Hauge wrote:
On Wednesday 19 July 2006 09:27, Mathijs wrote:
Hello there,

I Have an problem with UTF-8 and XML.

I Output perfect XML (according to IE, Opera and Firefox).
I use the Content-Type header with "text/xml; charset=utf-8".
For some reason this breaks UTF-8 output.
When i remove it it works. But i need the text/xml header.

If i save an document as .xml with the same contents as UTF-8 it works.

Is this a known problem?

Thx in advanced.

I would try just specifying UTF-8 in the XML header, and remove the charset from the content-type header, and just have the text/xml.

<?xml version="1.0" encoding="utf-8"?>

HTH


I have tryed this. But this also breaks the UTF-8.
When i put it back to text/html it works like it should :S.

I Realy have no clue anymore.



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0629-1, 07/19/2006
Tested on: 7/20/2006 8:57:42 AM
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Mathijs a écrit :
Hello there,

I Have an problem with UTF-8 and XML.

I Output perfect XML (according to IE, Opera and Firefox).
I use the Content-Type header with "text/xml; charset=utf-8".
For some reason this breaks UTF-8 output.
When i remove it it works. But i need the text/xml header.

Hi,
could you check which encoding your script is saved with ?
I saw some strange things when printing some iso-8859 strings with a php script
saved in utf-8.

N F
If i save an document as .xml with the same contents as UTF-8 it works.

Is this a known problem?

Thx in advanced.



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

 I am using php4.3.2,MYSQL and RedHat
 I have a sql text as shown below:


SELECT DISTINCT(tbl_chassis.serial_no),tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,tbl_chassis.city,tbl_chassis.building, tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3 from tbl_chassis tbl_chassis,tbl_card tbl_card
WHERE tbl_chassis.serial_no = tbl_card.serial_no
AND tbl_chassis.chasis_model LIKE '%WS-C5500%'
AND lower(country) = lower(trim('Malaysia'))
ORDER BY country,city,building,other


I need to extract the "tbl_chassis.chasis_model LIKE '%WS-C5500%'" and "lower(country) = lower(trim('Malaysia'))" and join them to new string.

Anyone have any suggestion how to do this?

Thanks
-weetat

--- End Message ---
--- Begin Message ---
>>My advice, give the candidates problems and see how they solve them.
Even if they don't finish, you get an idea of how they think.
>>tedd

I like this idea! 

Do you expect them to be able to work with code written by others?  If
so, hand them some of your existing code (good examples and not so good)
and ask them to figure out what it does and recommend changes.

I really really like the 'give them a problem and have them solve it'
idea...

Doug
_______________________________________________________________________
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

--- End Message ---
--- Begin Message --- To refine that a bit, you may want to give them some code that has been intentionally broken (simple things for the entry level position, such as missing semicolons or curly braces etc) and watch to see how they go about discovering the parse errors. To me, it would be better to hire someone that can solve problems quickly, not someone who can simply tell you what a piece of code is doing. Just a thought though - good luck!

-Joe

On Jul 20, 2006, at 7:20 AM, Finner, Doug wrote:

My advice, give the candidates problems and see how they solve them.
Even if they don't finish, you get an idea of how they think.
tedd

I like this idea!

Do you expect them to be able to work with code written by others?  If
so, hand them some of your existing code (good examples and not so good)
and ask them to figure out what it does and recommend changes.

I really really like the 'give them a problem and have them solve it'
idea...

Doug
______________________________________________________________________ _
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

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


--- End Message ---
--- Begin Message ---
Please reply to the list.

jekillen wrote:

On Jul 19, 2006, at 8:31 AM, John Nichel wrote:

We're looking to hire an entry level php programmer here, and I've been tasked with writing the test to evaluate the potential candidates. Being the lazy guy that I am, I naturally turned to Google to see if I could find some tests that I could use. After clicking thru many links, and finding mostly 'basic php tutorials', I've come here to ask you people to do my homework for me. ;) Does anyone have any links/resources for a basic php knowledge test? If not, I'll have to write one from scratch myself, and mess up the rest of my day of goofing off/sleeping.

What does $_POST['x'] mean?
What does $ in front of a string of chars without quotes mean?
That does register globals mean?
Is it possible to run php as a cgi script?
When it is necessary to use 'var' in php
code?
If you can't answer these questions how are you going to
know if someone is giving you the right answers?
There are tons of basic to advance books on the
commercial market about php.
I've gone the distance and shelled out literally 1,000 of
dollars buying books and hours learning the stuff. If you want answers
to your questions spend a little time so you will know if
someone has passed a test or not.

I've spent the past 8+ years 'going the distance' in PHP (quite a bit longer when you count in things like Perl, PASCAL, COBOL, etc), and shelled out about $25 on one PHP book. The web is a far better, cheaper, and more up-to-date learning source. However, I'm a geek, not some college kid who writes up documents so that HR can have a pretty piece of paper saying this guy knows the difference between '==' and '==='.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Finner, Doug wrote:
My advice, give the candidates problems and see how they solve them.
Even if they don't finish, you get an idea of how they think.
tedd

I like this idea!
Do you expect them to be able to work with code written by others?  If
so, hand them some of your existing code (good examples and not so good)
and ask them to figure out what it does and recommend changes.


Most definitely. This position isn't going to really require the person to write their own apps. Most of the stuff he/she will be doing is maintaining code already in place. Plenty of it will be my code, but prior to me starting here three years ago, they used to just get people on a contract basis, and there's some pretty messed up code. They even contracted a job out to a couple of Russian programmers; code's pretty clean, but all the comments are in Russian. ;) I like the idea of giving them a piece of our existing code and getting them to do something with it...I'll just have to get HR to accept my word on how they did on it (they really want a question and answer sheet that they can 'grade').

I really really like the 'give them a problem and have them solve it'
idea...


Yeah, one of my earliest thoughts on this was to have them write something simple like connecting to a db, selecting multiple rows, parsing our the result, and displaying it in some fashion.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
John Nichel wrote:

What does $_POST['x'] mean?
What does $ in front of a string of chars without quotes mean?
That does register globals mean?
Is it possible to run php as a cgi script?
When it is necessary to use 'var' in php
code?

I would probably agree that a problem would be better. Here's an idea, have one of your HR people take some existing code and do something to it to give it a bug, then have the guy fix it, and see how close he comes to what's there.
--- End Message ---
--- Begin Message ---
On Thursday 20 July 2006 07:23, John Nichel wrote:
> Yeah, one of my earliest thoughts on this was to have them write
> something simple like connecting to a db, selecting multiple rows,
> parsing our the result, and displaying it in some fashion.

Don't forget making it secure.  Here is one of my questions people can use if 
they like.  Feel free to re-word it.  I'm a programmer, not a writer ;)

What change(s) would you make to the following code to make it more secure?

$id = $_GET['id'];
mysql_query(“DELETE FROM myTbl WHERE id = $id”);

I like this question, because they have to know at least the fundamentals of 
PHP security.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

--- End Message ---
--- Begin Message ---
Ray Hauge wrote:
> On Thursday 20 July 2006 07:23, John Nichel wrote:
>> Yeah, one of my earliest thoughts on this was to have them write
>> something simple like connecting to a db, selecting multiple rows,
>> parsing our the result, and displaying it in some fashion.
> 
> Don't forget making it secure.  Here is one of my questions people can use if 
> they like.  Feel free to re-word it.  I'm a programmer, not a writer ;)
> 
> What change(s) would you make to the following code to make it more secure?
> 
> $id = $_GET['id'];
> mysql_query(“DELETE FROM myTbl WHERE id = $id”);

/*
// removed security flaw
$id = $_GET['id'];
mysql_query(“DELETE FROM myTbl WHERE id = $id”);
//*/

;-)

> 
> I like this question, because they have to know at least the fundamentals of 
> PHP security.
> 

--- End Message ---
--- Begin Message ---
Ray Hauge wrote:
> 
> Don't forget making it secure.  Here is one of my questions people can use if 
> they like.  Feel free to re-word it.  I'm a programmer, not a writer ;)
> 
> What change(s) would you make to the following code to make it more secure?
> 
> $id = $_GET['id'];
> mysql_query(“DELETE FROM myTbl WHERE id = $id”);

Believe it or not, I've lost count of how many times I've seen things
like this in Real Life.  SQL Injection waiting to happen...

> I like this question, because they have to know at least the fundamentals of 
> PHP security.

Agreed.

One thing I would add is to make sure they're familiar with the PHP
version you use.

Regards,
Austin.


Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
On Thu, 2006-07-20 at 09:19, Jochem Maas wrote:
> Ray Hauge wrote:
> > On Thursday 20 July 2006 07:23, John Nichel wrote:
> >> Yeah, one of my earliest thoughts on this was to have them write
> >> something simple like connecting to a db, selecting multiple rows,
> >> parsing our the result, and displaying it in some fashion.
> > 
> > Don't forget making it secure.  Here is one of my questions people can use 
> > if 
> > they like.  Feel free to re-word it.  I'm a programmer, not a writer ;)
> > 
> > What change(s) would you make to the following code to make it more secure?
> > 
> > $id = $_GET['id'];
> > mysql_query(“DELETE FROM myTbl WHERE id = $id”);
> 
> /*
> // removed security flaw
> $id = $_GET['id'];
> mysql_query(“DELETE FROM myTbl WHERE id = $id”);
> //*/
> 
> ;-)

You removed a lot more than the security flaw. No job for U!

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure....



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris

--- End Message ---
--- Begin Message ---
Chris Grigor a écrit :
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??
IMHO, the best is to generate a timestamp using mktime for each date.
you can the calculate the difference of timestamps and convert it back using date.

$tm_start = mktime(substr($start,0,2),substr($start,3,2), substr($start,5,2)); $tm_finish = mktime(substr($finish,0,2),substr($finish,3,2), substr($finish,5,2));

$tm_diff = $tm_finish -tm_start;

print date("H:i",$tm_diff);

I don't know if date accepts negative timestamps, so be sure $finish is later than $start (you can also put the day in case $finish = "00:00:12" and $start ="15:00:00").

hope this'll help

N F
I have looked at using the following but am not to sure....



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris



        
Nicolas Figaro <http://www.sdv.fr> <[EMAIL PROTECTED] <mailto:[EMAIL 
PROTECTED]>>
SDV plurimédia


--- End Message ---
--- Begin Message ---
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure....



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris

--- End Message ---
--- Begin Message ---
|Found this on the PHP web site,
you can add the conversions as the first lines in the functions.

function callDuration($dateTimeBegin,$dateTimeEnd) {
$dif=$dateTimeEnd - $dateTimeBegin;

    $hours = floor($dif / 3600);
    $temp_remainder = $dif - ($hours * 3600);
$minutes = floor($temp_remainder / 60);
    $temp_remainder = $temp_remainder - ($minutes * 60);
$seconds = $temp_remainder; // leading zero's - not bothered about hours
    $min_lead=':';
    if($minutes <=9)
      $min_lead .= '0';
    $sec_lead=':';
    if($seconds <=9)
      $sec_lead .= '0';
// difference/duration returned as Hours:Mins:Secs e.g. 01:29:32

 return $hours.$min_lead.$minutes.$sec_lead.$seconds;
}
|
Chris Grigor wrote:
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure....



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris


--- End Message ---
--- Begin Message --- We have a site which requires users log in. Once they do so a session is created (session_start), some data is saved as session data, particularly data which identifies the user, their privileges, etc. If the session ends, breaks, etc. The user must log in again.

There are also forms on the site. When a user submits a form, data, both posted and session, is saved to a MySQL database.

If a session breaks when a user submits data via the form, the result is that the user must log in again, the data is lost and the user unhappy. This happens rarely - but when it does, it can upset the user who has put effort into completing the form.

Is there a simple yet secure way of preventing this problem - for example passing the session id with the form and resurrecting the session if it has broken?

Thanks,

Jeff

--- End Message ---
--- Begin Message ---
On Thursday 20 July 2006 09:09, Jeffrey wrote:
> We have a site which requires users log in. Once they do so a session is
> created (session_start), some data is saved as session data,
> particularly data which identifies the user, their privileges, etc. If
> the session ends, breaks, etc. The user must log in again.
>
> There are also forms on the site. When a user submits a form, data, both
> posted and session, is saved to a MySQL database.
>
> If a session breaks when a user submits data via the form, the result is
> that the user must log in again, the data is lost and the user unhappy.
> This happens rarely - but when it does, it can upset the user who has
> put effort into completing the form.
>
> Is there a simple yet secure way of preventing this problem - for
> example passing the session id  with the form and resurrecting the
> session if it has broken?
>
> Thanks,
>
> Jeff

To my knowledge, this particular behavior is by design.  After the time limit 
for a session has been reached, then the garbage collection will usually 
clean it up.  The only way to not break a session is to never clean up the 
session files, or set the timeout to a day or so.

I wouldn't suggest sending the PHPSESSID via a form.  That leads to people 
being able to hijack sessions....

<from file='php.ini'>
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
</from>

HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

--- End Message ---
--- Begin Message ---
I'm looking for an opinion on programming style.

Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This last one puts all the HTML away from the PHP code, which has made life much easier.

Now, sometimes I warning messages like this one:

PHP Warning:  Cannot modify header information - headers already sent in

I know what it means, so I just look for newlines at the end of my PHP scripts, especially after the closing ?> and delete them.

Now, my question is: Is it a bad practice to "NOT" close the script with the PHP closing "?>"? I mean, just leave the script without a closing PHP simbols, as this scripts are included?

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués         |   SELECT 'mmarques' ||
Centro de Telemática        |       '@' || 'unl.edu.ar';
Universidad Nacional        |   DBA, Programador,
    del Litoral             |   Administrador
---------------------------------------------------------

--- End Message ---
--- Begin Message ---
Martin Marques wrote:
> I'm looking for an opinion on programming style.
> 
> Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This
> last one puts all the HTML away from the PHP code, which has made life
> much easier.
> 
> Now, sometimes I warning messages like this one:
> 
> PHP Warning:  Cannot modify header information - headers already sent in
> 
> I know what it means, so I just look for newlines at the end of my PHP
> scripts, especially after the closing ?> and delete them.
> 
> Now, my question is: Is it a bad practice to "NOT" close the script with
> the PHP closing "?>"? I mean, just leave the script without a closing
> PHP simbols, as this scripts are included?

I never add the final closing '?>' in any script for this very reason.

whether it's bad practice or I don't know (can't be any worse than the
flamewar on internals@lists.php.net though ;-)

> 
> -- 
>  21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
> ---------------------------------------------------------
> Lic. Martín Marqués         |   SELECT 'mmarques' ||
> Centro de Telemática        |       '@' || 'unl.edu.ar';
> Universidad Nacional        |   DBA, Programador,
>     del Litoral             |   Administrador
> ---------------------------------------------------------
> 

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Martin Marques wrote:
I'm looking for an opinion on programming style.

Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This
last one puts all the HTML away from the PHP code, which has made life
much easier.

Now, sometimes I warning messages like this one:

PHP Warning:  Cannot modify header information - headers already sent in

I know what it means, so I just look for newlines at the end of my PHP
scripts, especially after the closing ?> and delete them.

Now, my question is: Is it a bad practice to "NOT" close the script with
the PHP closing "?>"? I mean, just leave the script without a closing
PHP simbols, as this scripts are included?

I never add the final closing '?>' in any script for this very reason.


'Cause you're a SLACKER!!!

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
On Thu, 2006-07-20 at 11:30, John Nichel wrote:
> Jochem Maas wrote:
> > Martin Marques wrote:
> >> I'm looking for an opinion on programming style.
> >>
> >> Basicaly, I make systems using PEAR::DB and PEAR::HTML_Template_IT. This
> >> last one puts all the HTML away from the PHP code, which has made life
> >> much easier.
> >>
> >> Now, sometimes I warning messages like this one:
> >>
> >> PHP Warning:  Cannot modify header information - headers already sent in
> >>
> >> I know what it means, so I just look for newlines at the end of my PHP
> >> scripts, especially after the closing ?> and delete them.
> >>
> >> Now, my question is: Is it a bad practice to "NOT" close the script with
> >> the PHP closing "?>"? I mean, just leave the script without a closing
> >> PHP simbols, as this scripts are included?
> > 
> > I never add the final closing '?>' in any script for this very reason.
> > 
> 
> 'Cause you're a SLACKER!!!

Some of the best coders are slackers... because they find better ways to
code to prevent having to write so much code :) But to answer the
question...

http://marc.theaimsgroup.com/?l=php-dev&m=106896286829744&w=2
http://marc.theaimsgroup.com/?l=php-dev&m=106896382030183&w=2

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Best group member,

 

When a user does a specific action on domain1.com I want a cookie to be set
so that domain1.com and domain2.com can reach it. Ok, after reading the
manual for setcookie() I tried this:

 

setcookie("thevariable", "thevalue", time()+60*60*24*30, "/",
".domain1.com");

setcookie("thevariable", "thevalue", time()+60*60*24*30, "/",
".domain2.com");

 

However, I can not detect the cookie at domain2.com.

 

A solution would be to just make a redirect to the other domain where the
cookie is set and then return.

 

Question is: Can I not set a cookie at domain1.com to work at domain2.com?

 

Best regards,

Peter Lauri

 

 


--- End Message ---

Reply via email to