[PHP] Problem with set_time_limit() and uploading large files

2002-10-25 Thread derek fong
Hi,

I am having a major problem getting set_time_limit() to work at all 
with PHP 4.2.3 running as a CGI program under IIS for Windows 2000 (I 
originally posted this message to php-win, but am hoping someone here 
can shed some light on this).  I have a form that accepts large files 
for upload, with the following lines at the top of the form action 
script:

?php
// let this script take as long as it needs to complete its work
// and ignore if user hits stops button in his browser
set_time_limit(0);
ignore_user_abort(true);

// include site-wide configs and other include files
require_once('../includes/site.php');
...

If the file upload takes longer than 30 seconds, PHP bombs out with the 
following error:

Fatal error: Maximum execution time of 30 seconds exceeded in 
D:\InetPub\test.php on line 3

I've also tried adding:

ini_set('max_execution_time', 6);

before the set_time_limit() function, but to no avail.  PHP is not 
running in safe mode.  Does anyone have any ideas why this is not 
working as expected?  I'm sure it's something obvious, but I don't know 
what it is.

Thanks in advance,

-f


--
Derek Fong
Web Application Developer
subtitle designs inc. http://www.subtitled.com/

Mistakes are the portals of discovery. --James Joyce
GPG key/fingerprint available upon request 


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



Re: [PHP] Problem with set_time_limit() and uploading large files

2002-10-25 Thread derek fong
Thanks for the tips, but they all checked out in the end.  After 
reporting it as a bug, it turns out it *is* a bug with 4.2.3 (whether 
it's only with Win2000, I'm not sure), but has been fixed in CVS.  Now 
I can rest a little easier...  =)

-f


--
Derek Fong
Web Application Developer
subtitle designs inc. http://www.subtitled.com/

Mistakes are the portals of discovery. --James Joyce
GPG key/fingerprint available upon request 


On Friday, October 25, 2002, at 05:29  pm, @ Edwin wrote:

Hello,

Just a few ideas...

derek fong [EMAIL PROTECTED] wrote:


Hi,

I am having a major problem getting set_time_limit() to work at all
with PHP 4.2.3 running as a CGI program under IIS for Windows 2000 (I
originally posted this message to php-win, but am hoping someone here
can shed some light on this).  I have a form that accepts large files
for upload, with the following lines at the top of the form action
script:

?php
// let this script take as long as it needs to complete its work
// and ignore if user hits stops button in his browser
set_time_limit(0);


Try another number. Who knows? Might work... :)

...[snip]...


I've also tried adding:

ini_set('max_execution_time', 6);


+ Check whether ini_set() was successful.
+ I know you can change max_execution_time inside your script but try
changing it in php.ini and restart your server.
+ Perhaps, you can lower the number. (Is that 60,000 seconds?)

- E

...[snip]...






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




[PHP] Failed to initialize session module

2001-12-06 Thread derek fong

Hello,

I am trying to get session data written to a MySQL table using 
set_session_save_handler(), but am getting the following error when I 
issue session_register(varname) on a page:

Fatal error: Failed to initialize session module in 
/Library/WebServer/Documents/VirtualHosts/www/admin/en/login.php on 
line 4

I have set session.save_handler to user and session.save_path to 
mysql://USER:PASS@localhost/DB in my php.ini file.  File-based 
sessions seem to work fine with session.save_handler set to files and 
session.save_path to /tmp.  I am using the following code as my save 
handler (taken from Web Application Development With PHP 4.0 by 
Tobias Ratschiller and Till Gerken):

?php
$sess_mysql = array();
$sess_mysql[open_connection] = true;
$sess_mysql[hostname] = localhost;
$sess_mysql[user] = USER;
$sess_mysql[password] = PASS;
$sess_mysql[db] = DB;
$sess_mysql[table] = sessions;

function sess_mysql_open($save_path, $sess_name)
{
global $sess_mysql;

if ($sess_mysql[open_connection])
{
$link = mysql_pconnect($sess_mysql[hostname], 
$sess_mysql[user],
$sess_mysql[password]) or die(mysql_error());
}

return (true);
}


function sess_mysql_read($sess_id)
{
global $sess_mysql;
$result = mysql_db_query($sess_mysql[db], SELECT data FROM 
.$sess_mysql[table] . WHERE id = 
'$sess_id') or
die(mysql_error());

if (mysql_num_rows($result) == 0)
{
return ();
}

$row = mysql_fetch_array($result);
mysql_free_result($result);

return ($row[data]);
}


function sess_mysql_write($sess_id, $val)
{
global $sess_mysql;

$result = mysql_db_query($sess_mysql[db], REPLACE INTO 
.$sess_mysql[table] . VALUES 
('$sess_id', '$val', null)) or
die(mysql_error());

return (true);
}


function sess_mysql_destroy($sess_id)
{
global $sess_mysql;

$result = mysql_db_query($sess_mysql[db], DELETE FROM 
.$sess_mysql[table] . WHERE id = 
'$sess_id') or
die(mysql_error());

return (true);
}


function sess_mysql_gc($max_lifetime)
{
global $sess_mysql;

$old = time() - $max_lifetime;

$result = mysql_db_query($sess_mysql[db], DELETE FROM 
.$sess_mysql[table] . WHERE 
UNIX_TIMESTAMP(t_stamp)  $old) or
die(mysql_error());

return (true);
}

session_set_save_handler(sess_mysql_open, , sess_mysql_read, 
sess_mysql_write,
sess_mysql_destroy, sess_mysql_gc);
?


I have also tried Sam Johnston's PEAR Custom Session Handler for PHP4 
(http://sourceforge.net/projects/pearsession/), but I get the same 
error.  Like I said, file-based sessions are working fine, but any 
custom handler bombs with the error I noted above.  This is all 
running under Mac OS X 10.1.1, PHP 4.0.6 using the PEAR DB libraries 
(among others) and MySQL 3.23.43.

What could be causing the error?  I've searched and searched but 
can't seem to find any answers.  Thanks in advance,

-f


-- 
Derek Fong
Web Application Developer
subtitle designs inc. http://www.subtitled.com/

Mistakes are the portals of discovery. --James Joyce
 GPG key/fingerprint available upon request 


Re: [PHP] Mixing PHP code with phplib templates... possible?

2001-02-06 Thread derek fong

At 11:16 am +0300 2.6.01, Max A. Derkachev wrote:
df I need
df to run all hyperlinks through a function in order to maintain state
df and pass other variables from script to script.  I figure this must
df be possible, but I'm new at using phplib, so I'm not all that clear
df on it...

Set the links as template variables and then substitute them with
values using Template's set_var().

Hi Max,

Thanks for the reply.  Unfortunately, the solution you suggest means 
that I would have to do a set_var on all hyperlinks (i.e., define all 
hyperlinks everywhere on the site), which is a huge amount of 
maintenance.  What I thought about yesterday was creating some sort 
of token (e.g., {@}) that could be tacked onto the end of 
hyperlinks that I want to add session info to.  Maybe there's a 
better way...  I don't know!  :(


---
Derek Fong
web://developer
Zero-Knowledge Systems [http://www.zeroknowledge.com/]

PGP Fingerprint  2D4F 89F0 EAC1 FBFB 97B5  0B94 FA05 C29E D23B 0A4E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Mixing PHP code with phplib templates... possible?

2001-02-05 Thread derek fong

Hi,

Is there a way to embed PHP code in phplib's template files?  I need 
to run all hyperlinks through a function in order to maintain state 
and pass other variables from script to script.  I figure this must 
be possible, but I'm new at using phplib, so I'm not all that clear 
on it...

Any ideas?


---
Derek Fong
web://developer
Zero-Knowledge Systems [http://www.zeroknowledge.com/]

PGP Fingerprint  2D4F 89F0 EAC1 FBFB 97B5  0B94 FA05 C29E D23B 0A4E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]