php-general Digest 27 Sep 2007 14:30:48 -0000 Issue 5041

Topics (messages 262504 through 262526):

Re: counting with leading zeros
        262504 by: brian
        262506 by: Robert Cummings
        262508 by: brian
        262509 by: Robert Cummings
        262510 by: Jim Lucas
        262522 by: Robert Cummings
        262525 by: tedd
        262526 by: tedd

Re: PDOStatement execute memory issue?
        262505 by: Carlton Whitehead
        262507 by: Larry Garfield
        262512 by: Colin Guthrie

Re: trouble trying to connect to gmail server.
        262511 by: Tom Chubb

move_uploaded_file permission problem under php5
        262513 by: Torsten Rosenberger

freopen?
        262514 by: Per Jessen

problems with donwload
        262515 by: Hulf

languages and PHP
        262516 by: Angelo Zanetti
        262517 by: Paul Scott
        262518 by: Per Jessen
        262519 by: Angelo Zanetti
        262520 by: Angelo Zanetti
        262524 by: David Christopher Zentgraf

Re: Attachment Size and Memory limit with php and FC6 System]
        262521 by: edwardspl.ita.org.mo
        262523 by: Jim Lucas

Administrivia:

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

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

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Robert Cummings wrote:
On Wed, 2007-09-26 at 19:10 -0400, brian wrote:

If my response to that gave you the impression i was
complaining, i assure you that i wasn't. I was simply suggesting
that i was wondering if there was a *much* simpler way to do this, ie.
without using several functions to process the filename. Yes, your
version *does* have some improvements. I'm not disagreeing with you. Perhaps i could have been more forthright in my praise for said improvements (i'm even going to use some of them--how about that?!)


Well, I'm not looking for praise... but asking a concise question goes a
long way towards meeting your desires.

How was my question *not* concise? If anything, it was my first reply to you that i could have spent more time on. Once again: your reply was valid, your corrections were taken into consideration, *but* i was simply wondering if there was a more (yes) concise way to do what i wanted. My humble apologies (really).

IOW, i'm not stupid; i'm well aware that 100 comes after 99 and that it contains 3 digits, not 2, thanks very much.


Nope, 100 comes *before* 99 when lexically sorting.

You must be new around here.


Did i say anything there about lexically sorting? The query i posted here was about counting. That last comment? Yep, counting again. Now you're obviously just trying to be a dickhead. Well done.

You must be charming to work with.

brian

--- End Message ---
--- Begin Message ---
On Wed, 2007-09-26 at 22:39 -0400, brian wrote:
> Robert Cummings wrote:
> > On Wed, 2007-09-26 at 19:10 -0400, brian wrote:
> > 
> >>If my response to that gave you the impression i was
> >>complaining, i assure you that i wasn't. I was simply suggesting
> >>that i was wondering if there was a *much* simpler way to do this, ie.
> >>without using several functions to process the filename. Yes, your
> >>version *does* have some improvements. I'm not disagreeing with you. 
> >>Perhaps i could have been more forthright in my praise for said 
> >>improvements (i'm even going to use some of them--how about that?!)
> > 
> > 
> > Well, I'm not looking for praise... but asking a concise question goes a
> > long way towards meeting your desires.
> 
> How was my question *not* concise? If anything, it was my first reply to 
> you that i could have spent more time on. Once again: your reply was 
> valid, your corrections were taken into consideration, *but* i was 
> simply wondering if there was a more (yes) concise way to do what i 
> wanted. My humble apologies (really).
> 
> >>IOW, i'm not stupid; i'm well aware that 100 comes after 
> >>99 and that it contains 3 digits, not 2, thanks very much.
> > 
> > 
> > Nope, 100 comes *before* 99 when lexically sorting.
> > 
> > You must be new around here.
> > 
> 
> Did i say anything there about lexically sorting? The query i posted 
> here was about counting. That last comment? Yep, counting again. Now 
> you're obviously just trying to be a dickhead. Well done.

When you use sort() the default behaviour is a lexical sort. This is why
the 100th index breaks your system. I'm not trying to be a dickhead,
just pointing out the flaw in your logic. You may be well aware that in
counting 100 comes after 99, but it would seem you are not well aware
that in a lexical sort 100 will come first.

> You must be charming to work with.

Quite.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
When you use sort() the default behaviour is a lexical sort. This is why
the 100th index breaks your system. I'm not trying to be a dickhead,
just pointing out the flaw in your logic. You may be well aware that in
counting 100 comes after 99, but it would seem you are not well aware
that in a lexical sort 100 will come first.


I realise that this has been going on for some time now but i did say that this app will not--cannot--reach to 100. If it were to do so, my "system" would have become broken *long* before it reached sort(). Lexical sorting of '99' & '100' has nothing to do with this.

Just pointing out the flaw in your persistence with this.

b

--- End Message ---
--- Begin Message ---
On Thu, 2007-09-27 at 00:23 -0400, brian wrote:
> Robert Cummings wrote:
> > When you use sort() the default behaviour is a lexical sort. This is why
> > the 100th index breaks your system. I'm not trying to be a dickhead,
> > just pointing out the flaw in your logic. You may be well aware that in
> > counting 100 comes after 99, but it would seem you are not well aware
> > that in a lexical sort 100 will come first.
> > 
> 
> I realise that this has been going on for some time now but i did say 
> that this app will not--cannot--reach to 100. If it were to do so, my 
> "system" would have become broken *long* before it reached sort(). 
> Lexical sorting of '99' & '100' has nothing to do with this.
> 
> Just pointing out the flaw in your persistence with this.

Actually your original message said the following:

    "Note that there almost certainly will never be more
     than 99 images to a series. In any case, i don't care
     about there being more than one leading zero. One is
     what i want."

"Almost certainly" last time I checked does not equal "will not".

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
brian wrote:
I have a directory that contains many images (no, not pr0n, unfortunately) and i'm working on an admin script for adding to it. I've got something that works alright but i'm wondering if there's a Better Way.

Each image is named like: foo_01.jpg, foo_02.jpg, bar_01.jpg, and so on. When adding a new image it should be assigned the next number in the series (the prefix is known). Thus, given the prefix 'bar' i do something like:

function getNextImage($path, $prefix)
{
  $pattern = "/^${prefix}_([0-9]{2})\.[a-z]{3}$/";

  $filenames = glob("${path}${prefix}*");
if (is_array($filenames) && sizeof($filenames))
  {
    sort($filenames);

    /* eg. 'foo_32.jpg'
     */
    $last = basename(array_pop($filenames));

    /* pull the number from the filename
     */
    $count = intval(preg_replace($pattern, '$1', $last));

    /* increment, format with leading zero again if necessary,
     * and return it
     */
    return sprintf('%02d', ++$count)
  }
  else
  {
    return '01';
  }
}

Note that there almost certainly will never be more than 99 images to a series. In any case, i don't care about there being more than one leading zero. One is what i want.

brian



Well, I didn't want to get into the middle of this cat fight, but now that the talks have completely gotten off topic. I will interject...

Here is a function that is a bit simpler then either of yours.

Now, if you plan to delete any images in the list, this will not work.

But if you don't expect to delete any images in the list and always want the ($total_images + 1), then follow along.

<?php

function getNextImage($path, $prefix) {
  $filelist = glob("${path}${prefix}*") or return '01';
  return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT);
}

?>

This should work, I don't have a setup to test it on, but you should get the idea...

...

now remember...

if glob fails, it will return '01'
if glob returns and empty array, it will return '01'
if glob succeeds, it will return the array length + 1 padded (if needed) by one zero

You asked for less function calls in your function, here you go

Jim

--- End Message ---
--- Begin Message ---
On Wed, 2007-09-26 at 21:56 -0700, Jim Lucas wrote:
>
> Now, if you plan to delete any images in the list, this will not work.
> 
> But if you don't expect to delete any images in the list and always want 
> the ($total_images + 1), then follow along.
> 
> <?php
> 
> function getNextImage($path, $prefix) {
>    $filelist = glob("${path}${prefix}*") or return '01';
>    return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT);
> }
> 
> ?>

Nice :)

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
At 3:58 PM -0400 9/26/07, brian wrote:
Well, this is almost precisely the same thing i have, save for using POSIX character classes, str_pad instead of sprintf(), and incrementing elsewhere. What i was really wondering is if there was a *much simpler* way to do this, not just re-arranging things.


Rob just gave you code that works better than what you did and you're bitching about it?

Look, none of us are on your payroll so appreciate what you're given.

My advice, says thanks and if the code doesn't meet your expectations then learn how to better phrase your question next time.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

 Robert Cummings wrote:
Suit yourself. But better programmer's don't just wave their hands in
the air and hope for the best.

Ah crap -- there's another technique I have to cross off my list.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message --- No, the faxes aren't 4GB. Most of the faxes are less than 50KB, although they can be as large as a few MB. 4GB is a ridiculous amount of memory to try to allocate for this. 4GB is the max that 32bit versions of Windows can see. Is something causing the memory allocation to loop until it reaches this maximum value?

When I execute the same SQL in the MS SQL management studio interface, I get the expected resultset.

When I change the where clause portion in the prepared statement from "WHERE id = :id AND attid = :attid" to contain "WHERE id = 119085977300014 AND attid = 0" and comment out my bindValue() lines, I get the exact same memory allocation error in my PHP script.

I have isolated the problem to the query against the attdata column. If I remove the attdata column from the query, the query executes just fine. It may be worth noting this is an 'image' type column.

Could this be some bug in the way PHP, PDO, ODBC, and/or MS SQL are communicating? Maybe 'image' columns aren't being handled correctly? I'm fairly certain my code is correct. I appreciate all of your comments.

Has anyone even tried querying an 'image' type column out of MS SQL 2005 using PDO ODBC?

Regards,
Carlton Whitehead

Jeffery Fernandez wrote:
On Thursday 27 September 2007 04:21, Carlton Whitehead wrote:
Hi everyone,

I'm working on a script that downloads archived fax images (TIFFs and PDFs)
from a MS SQL Server using the PDO ODBC driver. I get the below error
regardless of which fax I try to get from the database. Each fax is a
different size, and both of the memory allocation numbers are always the
same:

Fatal error: Out of memory (allocated 262144) (tried to allocate 4294967295
bytes) in C:\Inetpub\wwwroot\FMarchive\library\faxInbound.php on line 81

Ho big are those faxes? 4294967295 bytes = 4GB

have you tried executing that SQL directly into the database? Does it return the right results?

The above error happened when querying a fax with a size of 17723 bytes. According to my phpinfo(); page, the memory_limit is 128MB.

My machine has the below specs:
Windows Server 2003 SP2
IIS 6
2GB RAM
Microsoft SQL Server 2005 SP2
PHP 5.2.4

Here is the excerpt from my code:

        public function downloadFax($id, $attid, $attsize)
        {
                try
                {
                                $stmt = 'SELECT filename, attdata FROM 
fm_faxin_att WHERE id = :id AND
attid = :attid'; $pstmt = $this->db->prepare($stmt);
                                $pstmt->bindValue(':id', $id);
                                $pstmt->bindValue(':attid', $attid);
                                $pstmt->execute(); // this is the Line 81 
referenced by the error
message $pstmt->bindColumn('filename', $filename, PDO::PARAM_STR);
                                $pstmt->bindColumn('attdata', $data, 
PDO::PARAM_LOB);
                                $pstmt->fetch(PDO::FETCH_BOUND);

                                return array('attdata' => $data, 'filename' => 
$filename);
                }
                catch (PDOException $e)
                {
                                die($e->getMessage());
                }
        }

Any ideas?

Regards,
Carlton Whitehead


--- End Message ---
--- Begin Message ---
On Wednesday 26 September 2007, Carlton Whitehead wrote:

> Could this be some bug in the way PHP, PDO, ODBC, and/or MS SQL are
> communicating?  Maybe 'image' columns aren't being handled correctly?
> I'm fairly certain my code is correct.  I appreciate all of your comments.
>
> Has anyone even tried querying an 'image' type column out of MS SQL 2005
> using PDO ODBC?
>
> Regards,
> Carlton Whitehead

Try isolating the problem.  If you have a literal query through PDO that 
fails, in isolation, try the same query using the old-skool odbc routines; 
just a trivial test script.  If that works but the same test script converted 
to minimal PDO fails, you've found a bug.  If it fails in both cases, I'd 
start blaming something else.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
Carlton Whitehead wrote:
> Is something causing the memory allocation
> to loop until it reaches this maximum value?

I don't think so as the 4GB value is mentioned in the error message.
Usually when memory is exhausted in a loop it will say "(tried to
allocate 100 bytes)" - e.g. a little amount.

This appears to do it in one chunk.

I wonder if this is trying to allocate memory for the maximum potential
size of your field in the DB? Perhaps read up on PDO/ODBC/MSSQL and how
they treat BLOBs.... (I don't know myself).

Col

--- End Message ---
--- Begin Message ---
This may not be relevant as I'm only glancing over this as I have to
leave for a meeting, but you have to enable POP access in Gmail before
you can download to another email client like Thunderbird or Outlook,
so maybe the same applies?
Anyway, I'm looking to find a way of accessing my gmail as I am unable
to access it at work as the Gmail site is blocked so please let me
know if you find a successful way of connecting!
Thanks,

Tom

On 27/09/2007, Fábio Generoso <[EMAIL PROTECTED]> wrote:
> *Hi Cris,*
>
> *I have tried to use:*
>
> *$mbox = 
> imap_open('{**pop.gmail.com:995/pop3}INBOX<http://pop.gmail.com:995/pop3%7DINBOX>
> **<**http://pop.gmail.com:995/pop3%7DINBOX**>',*
>
> *> '<my_login>@**gmail.com**', <my_pass>');*
>
>  *As you suggest but it didn't work. *
>
>
>
> *The time out is not for the function:*
>
> *imap_num_recent($mbox);*
>
> *It is for the function:*
>
> *imap_open('{pop.gmail.com:995/pop3}INBOX', '<my_login>@**gmail.com**',
> <my_pass>'**);*
>
>
>
> *In order to confirm that, I have created a new account with just 5 e-mails
> and I have gotten the same problem.*
>
> *And... I also check that using the code without the function*:
> imap_num_recent($mbox); *as* *bellow:*
>
> *$mbox = imap_open('{pop.gmail.com:995/pop3}INBOX','[EMAIL PROTECTED]',
> 'O3S/4o1*');*
>
> *print_r(imap_alerts());*
>
> *print_r(imap_errors());*
>
>
>
> *I got the same message error:*
>
> *Warning**: imap_open(): Couldn't open stream
> {pop.gmail.com:995/pop3}INBOXin c:\arquivos
> de programas\easyphp1-8\www\index.php on line 4
>
> Fatal error: Maximum execution time of 30 seconds exceeded in c:\arquivos de
> programas\easyphp1-8\www\index.php on line 4
>
> Notice: (null)(): POP3 connection broken in response (errflg=2) in
> Unknownon line
> 0*
>
> * *
>
> *So I have tried to use the function* *set_time_limit(0);* *to suppress  the
> time out but it still didn't work:*
>
> *set_time_limit(0);*
>
> *$mbox = imap_open('{pop.gmail.com:995/pop3}INBOX','[EMAIL PROTECTED]',
> 'O3S/4o1*');*
>
> *print_r(imap_alerts());*
>
> *print_r(imap_errors());*
>
>
>
> *I got these errors:*
>
> *Warning**: imap_open(): Couldn't open stream
> {pop.gmail.com:995/pop3}INBOXin c:\arquivos
> de programas\easyphp1-8\www\index.php on line 4
> Array ( [0] => POP3 connection broken in response )*
>
>
>
> *Looks like I have reached the gmail server but for same configuration or
> network issue, I'm not able to receive the answer. *
>
> *Any suggestion?*
>
> * *
>
> *Tks.*
>
>
> On 9/24/07, Chris <[EMAIL PROTECTED]> wrote:
> >
> >
> > > Array ( [0] => Host not found (#11001): pop3.gmail.com )
> >
> > So pop3.gmail.com doesn't exist.
> >
> > > <?
> > > $mbox = imap_open('{pop.gmail.com:995/pop3}INBOX<
> > http://pop.gmail.com:995/pop3%7DINBOX>',
> > > '<my_login>@gmail.com', <my_pass>');
> > > print_r(imap_alerts());
> > > print_r(imap_errors());
> > > $num_mens_not_read = imap_num_recent($mbox);
> > > imap_close($mbox);
> > > ?>
> > >
> > > I get these errors:
> > >
> > > Warning: imap_open(): Couldn't open stream {
> > > pop.gmail.com:995/pop3}INBOX<http://pop.gmail.com:995/pop3%7DINBOX>in
> > > c:\arquivos de programas\easyphp1-8\www\index.php on line 4
> > > Fatal error: Maximum execution time of 30 seconds exceeded in
> > c:\arquivos de
> > > programas\easyphp1-8\www\index.php on line 4
> > > Notice: (null)(): POP3 connection broken in response (errflg=2) in
> > Unknown
> > > on line 0
> > >
> > >
> > > This second code looks like ok for me, but for some reason I get this
> > time
> > > out. Do you have any idea what's going on? Did I miss some
> > configuration?
> >
> > Line 4 is
> >
> > $num_mens_not_read = imap_num_recent($mbox);
> >
> > so it's taking too long to work out how many are recent.
> >
> > How many unread messages are there in your account? How many messages in
> > total?
> >
> > --
> > Postgresql & php tutorials
> > http://www.designmagick.com/
> >
>


-- 
Tom Chubb
[EMAIL PROTECTED]
07912 202846

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

when i upload a file with the move_uploaded_file function the perm on
the uploaded file is 0600
the same work with copy the result ist 0644

with php4 the result was always the same and know with php5 it is
diffrent

i serached in the bug list and found this in the link below
and it is not a bug ?
http://bugs.php.net/bug.php?id=41255

BR/Torsten

--- End Message ---
--- Begin Message ---
Is there no freopen function in php?

I need to redirect stdin to a filename - outside of a shell so I can't
use a plain < redirect).


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
Under the results there are 3 files to download. Some users are getting an 
uable to read or corrupt message.

http://vps.aztechost.co.uk/~trisco/index.php


and 3 here

http://vps.aztechost.co.uk/~trisco/rankings.php


The upload script is similar


if(isset($_POST['_upload'])  && $_FILES['userfile']['size'] > 0)
{


$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}


$id= $_POST['id'];
/*$query = "UPDATE results SET title='$title', file_name='$fileName', 
size='$fileSize', type='$fileType',  content='$content', 
last_updated=CURDATE() WHERE id=$id";*/

$query ="INSERT INTO results (title, content, file_name, size, type, 
last_updated) VALUES ('$title', '$content', '$fileName', '$fileSize', 
'$fileType', CURDATE())";

mysql_query($query);
echo mysql_error();

}


and the download....

<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
include("/home/trisco/public_html/secure/scripts/connect.php");

$id    = $_GET['id'];
$query = "SELECT file_name, type, size, content FROM results WHERE id = 
'$id'";

$result = mysql_query($query) or die(mysql_error());;
list($file_name, $type, $size, $content) = 
mysql_fetch_array($result);

/*echo $file_name;
echo $type;
echo $size;*/


header("Content-Type: $type");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: ".filesize($file));
header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-encoding: binary");

echo $content;
exit;

}

?>


I  can open them on my desktop and laptop. Any clue why this is happening? 
Permissions?


Thanks,


R. 

--- End Message ---
--- Begin Message ---
Hi all.

this is more of a general question but Im sure some people will have experience and also it will be useful to others who are looking for the same answers as I am.

What are the implications of having a site that has many different languages, including latin and non latin characters?

Firstly, can a mysql database handle these characters normally? or would you have to have a table for each language and set a different CHARSET for each language depending on the type of language?

Secondly, PHP and displaying the information: Is there anything that needs to change with regards to PHP and handling of these characters? OR is it able to handle all characters fine?

HTML: I assume the charset changes in the metatag in the <head> of the document?

Is there anything else that I might be missing or other problems that I should be aware of?

Thanks in advance.


--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------

*Telephone:* +27 (021) 552 9799
*Mobile:*       +27 (0) 72 441 3355
*Fax:*            +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

--- End Message ---
--- Begin Message ---
On Thu, 2007-09-27 at 12:15 +0200, Angelo Zanetti wrote:
> What are the implications of having a site that has many different 
> languages, including latin and non latin characters?

Keep everything as universal (UTF-8) as possible, and make sure that you
code for right-to-left languages as well.

--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 ---
Paul Scott wrote:

> 
> On Thu, 2007-09-27 at 12:15 +0200, Angelo Zanetti wrote:
>> What are the implications of having a site that has many different
>> languages, including latin and non latin characters?
> 
> Keep everything as universal (UTF-8) as possible, and make sure that
> you code for right-to-left languages as well.
> 

Also be careful about how you use setlocale().  When/if you change it, 
make sure that your mysql connections has the same locale as your PHP
code.  Also don't make assumptions about the locale setting, but always
set it explicitly.  
Something similar goes for timezone I believe.  setlocale() caused me
all kinds of grief 2-3 years ago. 



/Per Jessen, Zürich

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


Paul Scott wrote:
On Thu, 2007-09-27 at 12:15 +0200, Angelo Zanetti wrote:
What are the implications of having a site that has many different languages, including latin and non latin characters?

Keep everything as universal (UTF-8) as possible, and make sure that you
code for right-to-left languages as well.

Thanks Paul,

How do you code for that? do you just align right or do you have to do some other wonderful stuff?
--Paul




------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------

*Telephone:* +27 (021) 552 9799
*Mobile:*       +27 (0) 72 441 3355
*Fax:*            +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>


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


Per Jessen wrote:
Paul Scott wrote:

On Thu, 2007-09-27 at 12:15 +0200, Angelo Zanetti wrote:
What are the implications of having a site that has many different
languages, including latin and non latin characters?
Keep everything as universal (UTF-8) as possible, and make sure that
you code for right-to-left languages as well.


Also be careful about how you use setlocale(). When/if you change it, make sure that your mysql connections has the same locale as your PHP
code.  Also don't make assumptions about the locale setting, but always
set it explicitly. Something similar goes for timezone I believe. setlocale() caused me all kinds of grief 2-3 years ago.
Thanks will keep this in mind. Very much appreciated.




/Per Jessen, Zürich


--
------------------------------------------------------------------------
Angelo Zanetti
Systems developer
------------------------------------------------------------------------

*Telephone:* +27 (021) 552 9799
*Mobile:*       +27 (0) 72 441 3355
*Fax:*            +27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

--- End Message ---
--- Begin Message --- Your biggest problem will be if you accept any kind of user input which could be in any kind of language. Depending on your server configuration you'll probably have some serious cleaning and filtering to do.
I often have to employ this line for example:
foreach (array_keys($_POST) as $key) $clean[$key] = mb_convert_encoding($_POST[$key], "UTF-8");

Trying to make sure that you'll receive UTF-8 helps as well:
<form action="form.php" method="post" enctype="multipart/form-data" accept-charset="utf-8">

Magic-Quotes can be a mayor pain in the rear, especially if you're on a host where you can't turn them off.

Other than that I concur, keep everything in UTF-8, explicitly check everything you're not sure about for UTF-8 compliance and explicitly set all your database connections to use UTF-8 and store stuff in UTF-8.

Cheers.

UTF-8, UTF-8

On  27. Sep 2007, at 19:15, Angelo Zanetti wrote:

Hi all.

this is more of a general question but Im sure some people will have experience and also it will be useful to others who are looking for the same answers as I am.

What are the implications of having a site that has many different languages, including latin and non latin characters?

Firstly, can a mysql database handle these characters normally? or would you have to have a table for each language and set a different CHARSET for each language depending on the type of language?

Secondly, PHP and displaying the information: Is there anything that needs to change with regards to PHP and handling of these characters? OR is it able to handle all characters fine?

HTML: I assume the charset changes in the metatag in the <head> of the document?

Is there anything else that I might be missing or other problems that I should be aware of?

Thanks in advance.

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:

>[EMAIL PROTECTED] wrote:
>  
>
>>Jim Lucas wrote:
>>
>>    
>>
>>>[EMAIL PROTECTED] wrote:
>>>
>>>      
>>>
>>>>post_max_size = 10M
>>>>max_execution_time = 3600 ; Maximum execution time of each script, in
>>>>seconds
>>>>max_input_time = 3600 ; Maximum amount of time each script may spend
>>>>parsing request data
>>>>memory_limit = 512M ; Maximum amount of memory a script may consume
>>>>file_uploads = On
>>>>upload_max_filesize = 8M
>>>>
>>>>But For IMP Display result :
>>>>
>>>>1, Maximum Attachment Size: 2,097,152 bytes ( only 2MB ??? )
>>>>        
>>>>
>>>Not sure what Maximum Attachment Size is referring to. Never heard of
>>>that setting
>>>
>>>Where are you getting #1 reading from? Are you sure that isn't a
>>>preset limit in Horde?
>>>
>>>      
>>>
>>>>2, Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
>>>>allocate 1519127 bytes) in
>>>>/home/itawm/html/horde/lib/Horde/MIME/Part.php on line 1027 ( limit 8MB
>>>>??? )
>>>>        
>>>>
>>>your file upload was larger then 8MB... ?? What is confusing about this?
>>>
>>>      
>>>
>>>>Mine is Linux FC6 System...
>>>>
>>>>Many thanks your help !
>>>>
>>>>Edward.
>>>>
>>>>        
>>>>
>>Hello Jim,
>>
>>Are you using the imp with FC6 also ?
>>    
>>
>
>no
>
>  
>
>>If so, have you meet this kind of problem ?
>>    
>>
>
>no
>
>  
>
>>Any more help or idea for me ?
>>    
>>
>
>Not at this time since you didn't answer my questions about Horde.
>
>  
>
>>Many thanks !
>>
>>Edward.
>>    
>>
>
>it looks like PHP is doing exactly what it should be doing.  I read that you 
>tried uploading a file
>that was larger then the 8MB limit.  That is a PHP error you showed us.
>
>How and where is the #1 error show to you?
>
>Never mind, I took 30 seconds and had Google tell me.
>
>http://www.google.com/search?q=imp+%22maximum+attachment+size%22+site%3Awiki.horde.org
>
>Check it out here
>
>http://wiki.horde.org/FAQ/Admin/Config?referrer=FAQ%2FAdmin#
>
>About two thirds the way down the page it will give you the answer the my 
>initial question.
>
>" How can I configure IMP's maximum attachment size? "
>
>*  man they should insert anchor tags so someone can link directly to what we 
>are referring to
>
>It is not PHP that is setting the limit.  2MB is the default for the "maximum 
>attachment size"
>  
>
Hello Jim,

I have ever tried to set upload_max_filesize = 8MB...
But it is still Maximum Attachment Size: 2,097,152 bytes

Many thanks for your help !

Edward.

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Jim Lucas wrote:

[EMAIL PROTECTED] wrote:
Jim Lucas wrote:

[EMAIL PROTECTED] wrote:

post_max_size = 10M
max_execution_time = 3600 ; Maximum execution time of each script, in
seconds
max_input_time = 3600 ; Maximum amount of time each script may spend
parsing request data
memory_limit = 512M ; Maximum amount of memory a script may consume
file_uploads = On
upload_max_filesize = 8M

But For IMP Display result :

1, Maximum Attachment Size: 2,097,152 bytes ( only 2MB ??? )
Not sure what Maximum Attachment Size is referring to. Never heard of
that setting

Where are you getting #1 reading from? Are you sure that isn't a
preset limit in Horde?

2, Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 1519127 bytes) in
/home/itawm/html/horde/lib/Horde/MIME/Part.php on line 1027 ( limit 8MB
??? )
your file upload was larger then 8MB... ?? What is confusing about this?

Mine is Linux FC6 System...

Many thanks your help !

Edward.

Hello Jim,

Are you using the imp with FC6 also ?
no

If so, have you meet this kind of problem ?
no

Any more help or idea for me ?
Not at this time since you didn't answer my questions about Horde.

Many thanks !

Edward.
it looks like PHP is doing exactly what it should be doing.  I read that you 
tried uploading a file
that was larger then the 8MB limit.  That is a PHP error you showed us.

How and where is the #1 error show to you?

Never mind, I took 30 seconds and had Google tell me.

http://www.google.com/search?q=imp+%22maximum+attachment+size%22+site%3Awiki.horde.org

Check it out here

http://wiki.horde.org/FAQ/Admin/Config?referrer=FAQ%2FAdmin#

About two thirds the way down the page it will give you the answer the my 
initial question.

" How can I configure IMP's maximum attachment size? "

*  man they should insert anchor tags so someone can link directly to what we 
are referring to

It is not PHP that is setting the limit.  2MB is the default for the "maximum 
attachment size"
Hello Jim,

I have ever tried to set upload_max_filesize = 8MB...
But it is still Maximum Attachment Size: 2,097,152 bytes

Many thanks for your help !

Edward.

Ok, let me explain this last time.

the 8MB limit is set in php

the 2MB limit is set in horde

if you do not run your own server, your ISP probably set the PHP setting

And the horde 2MB limit is the default attachment size

I wasn't going to say it earlier, but google your friend.

http://us2.php.net/manual/en/ini.core.php#ini.upload-max-filesize

The default for upload_max_filesize is 2MB, so someone must have changed it at some point. And if you didn't change/set it, I'm going to guess you are using an ISP that did.

--
Jim Lucas


    "Perseverance is not a long race;
        it is many short races one after the other"

Walter Elliot



    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---

Reply via email to