|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Thu Mar 20 2008 - 08:57:28 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Mar 2008 13:57:28 -0000 Issue 5358
Topics (messages 271867 through 271886):
Re: selling gpl software?
271867 by: Larry Garfield
271869 by: Larry Garfield
271884 by: Colin Guthrie
Re: Fastest way to get table records' number
271868 by: Shelley
271871 by: Shelley
271874 by: Shelley
Re: MySQL Group?
271870 by: Chris
271872 by: John Taylor-Johnston
271873 by: Chris
Re: Sending multiple values from a form having same field names.
271875 by: Suamya Srivastava
Will the progress bar like Xupload add too much weight to the Apache server?
271876 by: Shelley
271879 by: Manuel Lemos
Problems with mime encoding of Japanese Characters in Subject and 'From:', 'Reply-to:', ... fields.
271877 by: Dietrich Bollmann
271880 by: Manuel Lemos
271881 by: Dietrich Bollmann
Re: Checking how many letters are in a string.
271878 by: Dotan Cohen
Re: fwrite/fclose troubles
271882 by: Peter Ford
Anyone using clsMsDocGenerator?
271883 by: George Pitcher
Re: Newbie question, Which way is best?
271885 by: Thiago Pojda
Playing around with strings
271886 by: Robin Vickery
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
On Wednesday 19 March 2008, Colin Guthrie wrote:
> Also as it's GPL and as you are "supplying" the modifications you make
> to your client, you are obliged to release the changes you make to the
> community. If this was a 100% internal development (e.g. you are
> employed directly by your client, not as a contractor), then you are not
> obliged to release the changes.
Not true. If you take an open source project, modify it, and give a copy to
your client, you are under no obligation to give anyone else in the world a
copy of your modified code. What you ARE required to do is give that
modified to code to your client under the GPL so that he can, if he wants to,
share it with the world, and anyone he gives a copy to can also share it with
the world if they want to, etc.
Removing any user-facing references to the original project is completely
legal. Whether or not it is polite or acting with the "spirit" of the
community, etc. is a question of community ethics, not law, and something
you'll have to decide for yourself.
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com 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
attached mail follows:
On Wednesday 19 March 2008, jeffry s wrote:
> what is the difference between gpl, gplv2 and gplv3 ?
http://www.fsf.org/licensing/licenses/quick-guide-gplv3.html
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com 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
attached mail follows:
Larry Garfield wrote:
> On Wednesday 19 March 2008, Colin Guthrie wrote:
>
>> Also as it's GPL and as you are "supplying" the modifications you make
>> to your client, you are obliged to release the changes you make to the
>> community. If this was a 100% internal development (e.g. you are
>> employed directly by your client, not as a contractor), then you are not
>> obliged to release the changes.
>
> Not true. If you take an open source project, modify it, and give a copy to
> your client, you are under no obligation to give anyone else in the world a
> copy of your modified code. What you ARE required to do is give that
> modified to code to your client under the GPL so that he can, if he wants to,
> share it with the world, and anyone he gives a copy to can also share it with
> the world if they want to, etc.
Is that true? I would have thought that by developing under contract and
then subsequently "supplying" your modifications to your client, this
constitutes "distribution" of the code. It is this "distribution" of the
code that I've always considered the trigger for "having" to share it
back to the community - e.g. if your changes are internal to your
company you don't need to share it. Earlier I wrote that whether he was
employed directly or as a contractor would have bearing and this
statement was based on the above understanding. Am I wrong?
Col
attached mail follows:
Nathan Nobbe wrote:
> On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <aballard
gmail.com> wrote:
>
>
>> That works; I'm just wondering why you went with a count on an 'ID' column
>> rather than COUNT(*).
>>
>
>
> ouch, it looks like im horribly wrong :O
> mysql> select count(*) from table;
> +----------+
> | count(*) |
> +----------+
> | 361724 |
> +----------+
> 1 row in set (0.90 sec)
>
> mysql> select count(id) from table;
> +------------+
> | count(did) |
> +------------+
> | 361724 |
> +------------+
> 1 row in set (4.56 sec)
>
> -nathan
>
>
Here is a further test with more records:
mysql> select count(*) from table1;
+----------+
| count(*) |
+----------+
| 20795139 |
+----------+
1 row in set (1 min 8.22 sec)
mysql> select count(id) from table1;
+-----------+
| count(id) |
+-----------+
| 20795139 |
+-----------+
1 row in set (1 min 1.45 sec)
mysql> select count(1) from table1;
+----------+
| count(1) |
+----------+
| 20795139 |
+----------+
1 row in set (56.67 sec)
count(1) wins.
--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )
attached mail follows:
Nathan Nobbe wrote:
> On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <aballard
gmail.com> wrote:
>
>
>> That works; I'm just wondering why you went with a count on an 'ID' column
>> rather than COUNT(*).
>>
>
>
> ouch, it looks like im horribly wrong :O
> mysql> select count(*) from table;
> +----------+
> | count(*) |
> +----------+
> | 361724 |
> +----------+
> 1 row in set (0.90 sec)
>
> mysql> select count(id) from table;
> +------------+
> | count(did) |
> +------------+
> | 361724 |
> +------------+
> 1 row in set (4.56 sec)
>
> -nathan
>
>
Hi nanthan,
Thanks.
This is my test results:
mysql> select count(*) from article;
+----------+
| count(*) |
+----------+
| 1065868 |
+----------+
1 row in set (1.30 sec)
mysql> select count(1) from article;
+----------+
| count(1) |
+----------+
| 1065868 |
+----------+
1 row in set (0.82 sec)
mysql> select count(*) from article;
+----------+
| count(*) |
+----------+
| 1065868 |
+----------+
1 row in set (0.81 sec)
mysql> select count(id) from article;
+-----------+
| count(id) |
+-----------+
| 1065868 |
+-----------+
1 row in set (0.85 sec)
mysql> select count(1) from article;
+----------+
| count(1) |
+----------+
| 1065868 |
+----------+
1 row in set (0.82 sec)
mysql> select count(*) from article;
+----------+
| count(*) |
+----------+
| 1065868 |
+----------+
1 row in set (0.81 sec)
mysql> select count(id) from article;
+-----------+
| count(id) |
+-----------+
| 1065868 |
+-----------+
1 row in set (0.85 sec)
mysql> select count(1) from article;
+----------+
| count(1) |
+----------+
| 1065868 |
+----------+
1 row in set (0.81 sec)
Seems that count(1) is always not a bad answer.
So, I determined to choose count(1).
Thank you all for your replies.
--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )
attached mail follows:
Nathan Nobbe wrote:
> On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <aballard
gmail.com> wrote:
>
>
>> That works; I'm just wondering why you went with a count on an 'ID' column
>> rather than COUNT(*).
>>
>
>
> ouch, it looks like im horribly wrong :O
> mysql> select count(*) from table;
> +----------+
> | count(*) |
> +----------+
> | 361724 |
> +----------+
> 1 row in set (0.90 sec)
>
> mysql> select count(id) from table;
> +------------+
> | count(did) |
> +------------+
> | 361724 |
> +------------+
> 1 row in set (4.56 sec)
>
> -nathan
>
>
The archive of my results was saved here:
http://phparch.cn/index.php/mysql/35-MySQL-programming/126-fastest-way-to-get-total-records-from-a-table
--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )
attached mail follows:
George J wrote:
> Hi John,
>
> "John Taylor-Johnston" <John.Taylor-Johnston
cegepsherbrooke.qc.ca> wrote in
> message news:64.F3.14744.358A1E74
pb1.pair.com...
>> Does anyone know of a good MySQL group?
>> I want to make a relational link from `data` to `shopping` so when I
>> insert a new record in `shopping`, I will see the contents of
>> `data`.`name` and `data`.`email` as a drop-down menu in `shopping`.
>>
>> Where does one go to get this kind of help?
>>
>> Thanks,
>> John
>>
>>
>> DROP TABLE IF EXISTS `data`;
>> CREATE TABLE `data` (
>> `id` int(5) NOT NULL auto_increment,
>> `name` varchar(255) NOT NULL,
>> `email` varchar(255) NOT NULL default '',
>> PRIMARY KEY (`id`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
>>
>> INSERT INTO `data` VALUES(1, 'Allen, Carolyn', 'nobody
jtjohnston.net');
>> INSERT INTO `data` VALUES(2, 'Atwood, Margaret',
>> 'someone
jtjohnston.net');
>>
>> DROP TABLE IF EXISTS `shopping`;
>> CREATE TABLE `shopping` (
>> `id` int(5) NOT NULL auto_increment,
>> `name` varchar(100) NOT NULL,
>> `address` varchar(100) NOT NULL,
>> `email` varchar(100) NOT NULL,
>> PRIMARY KEY (`id`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
>>
> I'm not certain but think you need to include a 'references
> table_name(field_name)' clause that sets up the Foreign key relationship
> between the 2 tables. I think the Reference clause would replace the
> auto_increment in your primary key of the referencing table.
The references goes into the secondary table, not the main one and it
definitely doesn't replace the auto_increment field.
You end up with something like this:
create table person
(
person_id int primary key,
name varchar(255),
email varchar(255)
) engine=innodb;
create table shopping
(
shopping_id int primary key,
person_id int,
foreign key (person_id) references person(person_id)
) engine=innodb;
insert into person(person_id,name,email)
values(1,'Name','email
address.com');
insert into shopping(shopping_id, person_id) values(1, 1);
The 'person' table still needs at least a unique field for the field
being referenced (the foreign key), usually a primary key (and if
necessary an auto_increment).
The secondary table uses that key to check:
- if that id exists:
insert into shopping(shopping_id, person_id) values (2,2);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key
constraint fails
- if it should delete that id (when using "on delete cascade")
mysql> delete from person where person_id=1;
Query OK, 1 row affected (0.00 sec)
mysql> select * from shopping;
Empty set (0.00 sec)
- if it needs to be updated (when using "on update cascade")
mysql> update person set person_id=2 where person_id=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from shopping;
+-------------+-----------+
| shopping_id | person_id |
+-------------+-----------+
| 1 | 2 |
+-------------+-----------+
1 row in set (0.00 sec)
See manual for more examples:
http://dev.mysql.com/doc/refman/4.1/en/innodb-foreign-key-constraints.html
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Thanks for getting me started. (Sorry, I'm a top quoter.) Below is some
working code for the archives.
What I've learned so far is that :
1) what I'm referring to in `person` has to be a key.
2) if I want to refer to more than one field from person in shopping, I
have to use unique keys.
I'm still discovering what keys are for.
John
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`person_id` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`email` varchar(255) default NULL,
PRIMARY KEY (`person_id`),
KEY `email` (`email`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 1, 'Name',
'email
address.com' ) ;
INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 2, 'second
Name', 'email
anotheraddress.com' ) ;
DROP TABLE IF EXISTS `shopping`;
CREATE TABLE IF NOT EXISTS `shopping` (
`shopping_id` int(11) NOT NULL,
`email` varchar(255) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`shopping_id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `name` (`name`),
FOREIGN KEY (`email`) REFERENCES `person` (`email`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
> You end up with something like this:
>
> create table person
> (
> person_id int primary key,
> name varchar(255),
> email varchar(255)
> ) engine=innodb;
>
> create table shopping
> (
> shopping_id int primary key,
> person_id int,
> foreign key (person_id) references person(person_id)
> ) engine=innodb;
>
> insert into person(person_id,name,email)
> values(1,'Name','email
address.com');
>
> insert into shopping(shopping_id, person_id) values(1, 1);
attached mail follows:
John Taylor-Johnston wrote:
> Thanks for getting me started. (Sorry, I'm a top quoter.) Below is some
> working code for the archives.
>
> What I've learned so far is that :
> 1) what I'm referring to in `person` has to be a key.
It should be a unique item rather than just a 'key' (indexed item).
If you add this data:
insert into person(name, email) values ('my name', 'my_email
address.com');
insert into person(name, email) values ('another name',
'my_email
address.com');
and I share an email address, and you use "email" as the foreign key,
which one is it going to link to?
Mysql should really throw an error if you try to reference a non-unique
field or combination of fields - every other db does.
A unique key can cover more than one field:
create table person
(
person_id int primary key,
name varchar(255),
email varchar(255),
unique key (name, email)
) engine=innodb;
So you can only have one combination of name & email then you can use
that as a foreign key:
create table shopping
(
shopping_id int primary key,
person_name varchar(255),
person_email varchar(255),
foreign key (person_name, person_email) references person(name,email)
) engine=innodb;
Though I'd suggest starting off with the person_id (primary key) as the
foreign key so you don't have data redundancy and integrity issues
(unless you use "on update cascade").
I'd also suggest getting an intro-to-sql book as this is all reasonably
basic stuff.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Hi,
Thanks all for the help.
I suffixed all the field names in the form with field id, like
name=field_name_fieldid and fetched it as an associative array.
Thanks,
Suamya
> Eric Butera wrote:
>> On Fri, Mar 14, 2008 at 6:02 AM, Zoltán Németh
>> <znemeth
alterationx.hu> wrote:
>>> 2008. 03. 14, péntek keltezéssel 14.08-kor Suamya Srivastava ezt
>>> írta:
>>>
>>>> Hi,
>>> >
>>> > How can I send multiple values from a form to be stored in a
>>> database, as
>>> > name of the fields is the same?
>>> >
>>> > For example:
>>> >
>>> > <?php
>>> > foreach ($field_data as $field) {
>>> >
>>> > $field_name=$field["field_name"];
>>> > $field_id=$field["field_id"];
>>> > $datatype=$field["datatype_name"];
>>> >
>>> > ?>
>>> > <input type="hidden" name="field_id" value="<?php echo $field_id;?>"
>>> />
>>> > <tr>
>>> > <td><strong><?php echo $field_name;?><strong></td>
>>> > <?php
>>> > if ($datatype=="text" || $datatype=="integer") {
>>> > echo "<td><input type=\"text\"
>>> name=\"field_data\"></td>";
>>>
>>> make field_data an array indexed by field_id
>>>
>>> <input type="text" name="field_data[<?php echo $field_id; ?>]"
>>>
>>> greets,
>>> Zoltán Németh
>>>
>>>
>>>
>>> > }
>>> > elseif ($datatype=="textarea") {
>>> > echo "<td><textarea rows=\"10\" cols=\"100\"
>>> > name=\"field_data\"></textarea><br></td>";
>>> > }
>>> > echo "</tr>";
>>> > }
>>> > ?>
>>> >
>>> > This creates a form with field names and text box or textarea box
>>> next to
>>> > each field name depending on the datatype. After the user enters the
>>> > values in the text or textarea and clicks submit, the values should
>>> get
>>> > stored in a database. But what is happening is that only the value
>>> entered
>>> > in the last field of the form is getting entered into the database.
>>> > This code is embedded in an application which is having an inbuilt
>>> > structure of taking the values from a form in a hash. Since key is
>>> the
>>> > same (i.e. field_id) everytime, the value gets overwritten and only
>>> the
>>> > last value gets stored in db. But I am not able to work out a
>>> solution for
>>> > this.
>>> > I hope I am able to make my problem clear enough.
>>> >
>>> > Thanks,
>>> > Suamya.
>>> >
>>> >
>>> >
>>> >
>>> > -----------------------------------------------------------------------------
>>> > DISCLAIMER:-
>>> > "The information in this e-mail is confidential, and is
>>> intended
>>> > solely for the addressee or addressees. If you are not the intended
>>> recipient,
>>> > please delete the mail and kindly notify the sender of misdelivery.
>>> Any
>>> > unauthorised use or disclosure of the contents of the mail is not
>>> permitted
>>> > and may be unlawful."
>>> > -----------------------------------------------------------------------------
>>> >
>>> > "Scanned By MailScanner"
>>> >
>>> >
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Since Zoltán give you the answer I might give you another fish. Which
>> one is more readable:
>>
>> <input type="hidden" name="field_id" value="<?php echo $field_id;?>" />
>> <tr>
>> <td><strong><?php echo $field_name;?><strong></td>
>> <?php
>> if ($datatype=="text" || $datatype=="integer") {
>> echo "<td><input type=\"text\" name=\"field_data\"></td>";
>> }
>> elseif ($datatype=="textarea") {
>> echo "<td><textarea rows=\"10\" cols=\"100\"
>> name=\"field_data\"></textarea><br></td>";
>> }
>> echo "</tr>";
>> }
>> ?>
>>
>>
>> <input type="hidden" name="field_id" value="<?php echo
>> htmlspecialchars($field_id); ?>" />
>> <tr>
>> <td><strong><?php echo htmlspecialchars($field_name); ?><strong></td>
>>
>> <?php if ($datatype=="text" || $datatype=="integer"): ?>
>> <td><input type="text" name="field_data"></td>
>> <?php elseif ($datatype=="textarea"): ?>
>> <td>
>> <textarea rows="10" cols="100" name="field_data"></textarea>
>> <br>
>> </td>
>> <?php endif; ?>
>>
>> </tr>
>
> This is more readable
>
> <?php
> while ( $row = mysql_fetch_row($result_set) ) {
>
> # Extract all data fields from result set
> list($datatype,$field_id,$field_name,etc...) = $row;
>
> # Initialize or clear variable
> $field = '';
>
> # Check to see if it requires a text field
> if ( $datatype == "text" || $datatype == "integer" ) {
>
> # Create Text field
> $field = '<input type="text" name="field_data[{$field_id}]" />';
>
> # Check to see if it requires a text area
> } elseif ( $datatype == "textarea" ) {
>
> # Create Text Area
> $field = '<textarea rows="10" cols="100"
> name="field_data[{$field_id}]">'.
> '</textarea>';
>
> }
> # Display it all
> echo <<<ROW
> <tr>
> <td><strong>{$field_name}</strong></td>
> <td>{$field}</td>
> </tr>
> ROW;
> }
> ?>
>
>
> --
> Jim Lucas
>
> "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
>
>
> -----------------------------------------------------------------------------
> DISCLAIMER:-
> "The information in this e-mail is confidential, and is intended
> solely for the addressee or addressees. If you are not the intended
> recipient,
> please delete the mail and kindly notify the sender of misdelivery. Any
> unauthorised use or disclosure of the contents of the mail is not
> permitted
> and may be unlawful."
> -----------------------------------------------------------------------------
>
> "Scanned By MailScanner"
>
>
-----------------------------------------------------------------------------
DISCLAIMER:-
"The information in this e-mail is confidential, and is intended
solely for the addressee or addressees. If you are not the intended recipient,
please delete the mail and kindly notify the sender of misdelivery. Any
unauthorised use or disclosure of the contents of the mail is not permitted
and may be unlawful."
-----------------------------------------------------------------------------
"Scanned By MailScanner"
attached mail follows:
Hi all,
Here is the Xupload progress bar link:
http://www.sibsoft.net/xupload.html
My question is:
Will the upload progress bar like that add too much weight to the Apache
server, especially to a server with millions of visitors each day?
Thanks in advance.
--
Regards,
Shelley ( PHP Architecture: http://phparch.cn )
attached mail follows:
Hello,
on 03/20/2008 03:32 AM Shelley said the following:
> My question is:
> Will the upload progress bar like that add too much weight to the Apache
> server, especially to a server with millions of visitors each day?
It is hard to tell. It seems to rely on a mod_perl script.
You may also want to try this forms generation and validation class that
comes with an upload progress plug-in that relies only on PHP:
http://www.phpclasses.org/formsgeneration
Here you can test it live:
http://www.meta-language.net/forms-examples.html?example=test_upload_progress
Here you can watch it live:
http://www.phpclasses.org/browse/video/1/package/1/section/plugin-upload-meter.html
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
Hi,
--- note ---
I sent a similar message already to php-i18n - but this list seems
not to be used very much (20 messages this year) so I am posting it
here again...
------------
I try to send messages written in Japanese (Kana/Kanji) with php.
Everything works fine - only when the subject (or the name of the
sender) becomes longer, there seems to be something wrong with the
encoding: Neither my nor the mail reader of other (Japanese) friends
decodes the mime string. At the place of the Japanese Characters,
the mime string itself is displayed in the subject (to, reply to)
field.
As this doesn't happen for other Japanese emails with even longer
subjects, I suppose I did something wrong ... but what?
Here how I convert the subject (the name is converted using the same
method and the sources are saved in UTF-8 using emacs):
$subjectJIS = mb_convert_encoding($subject, "ISO-2022-JP", "AUTO");
$subjectMIME = mb_encode_mimeheader($subjectJIS, "ISO-2022-JP", "B");
...snip...
mail($to, $subjectMIME, $bodyJIS, $headers);
Here part of the message as it is displayed by my mail program:
From:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?==?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?=(B <d.bollmann
tu-berlin.de>
...snip...
Subject:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?= =?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?= (B
...snip...
かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢
字かな漢字
And here part of the mail text itself:
...snip...
Subject:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?=
=?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?=
=?ISO-2022-JP?B?KEI=?=
MIME-Version: 1.0
From:
=?ISO-2022-JP?B?GyRCJCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7?= =?ISO-2022-JP?B?eiQrJEo0QTt6JCskSjRBO3okKyRKNEE7eiQrJEo0QTt6JCskSjRBO3ob?= =?ISO-2022-JP?B?KEI=?= <d.bollmann
tu-berlin.de>
...snip...
Content-Type: text/plain; charset=ISO-2022-JP
...snip...
かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字かな漢
字かな漢字
Here a part of another (spam) mail which is correctly displayed by my
mail program:
MIME-Version: 1.0
Subject:
=?ISO-2022-JP?B?GyRCIXolXSUkJXMlSBsoQjEwGyRCR1whdUF3TkEbKEI=?=
=?ISO-2022-JP?B?GyRCTDVOQSF6GyhCMSwwMDAbJEIxXyU4JWUbKEI=?=
=?ISO-2022-JP?B?GyRCJSglaiE8Qmc9ODlnISohWjNaRTchWxsoQg==?=
=?ISO-2022-JP?B?GyRCIUobKEIyMDA4LzAzLzE5?= =?ISO-2022-JP?B?KQ==?=
From: =?ISO-2022-JP?B?GyRCM1pFNztUPmwlOCVlJSglaiE8ISYlIhsoQg==?=
=?ISO-2022-JP?B?GyRCJS8lOyU1JWohPCVLJWUhPCU5GyhC?=
<jewelry
emagazine.rakuten.co.jp>
Displayed as:
From: 楽天市場ジュエリー・アクセサリーニュース
<jewelry
emagazine.rakuten.co.jp>
...snip...
Subject: ★ポイント10倍&送料無料★1,000円ジュエリー大集合!【楽天】
(2008/03/19)
If anybody can explain me the problem I would be most grateful :)
Thanks, Dietrich
---
PS: I appended a little example program which produces the problem.
The same program works correctly when using the following values:
$subject = "かな漢字";
$senderName = "かな漢字";
Thanks for your help :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8" />
<title>Contact Me</title>
</head>
<body>
<h1>かな漢字</h1>
<?php # Script 10.1 - email.php
function sendEmail($recipientEmailAddress, $subject, $body, $senderName,
$senderEmailAddress) {
// set current language to Japanese
mb_language("ja");
// encode subject
// - first using JIS (ISO-2022-JP)
// - after encoding the resulting JIS string with the MIME header
encoding scheme
$subjectJIS = mb_convert_encoding($subject, "ISO-2022-JP", "AUTO");
$subjectMIME = mb_encode_mimeheader($subjectJIS, "ISO-2022-JP",
"B");
// encode the name of the sender
// - first using JIS (ISO-2022-JP)
// - after encoding the resulting JIS string with the MIME header
encoding scheme
$senderNameJIS = mb_convert_encoding($senderName, "ISO-2022-JP",
"AUTO");
$senderNameMIME = mb_encode_mimeheader($senderNameJIS,
"ISO-2022-JP", "B");
// encode body
// - using JIS (ISO-2022-JP)
// - the used coding system had to be specified in the
Content-Type/charset header:
// Content-Type: text/plain; charset=ISO-2022-JP
$bodyJIS = mb_convert_encoding($body, "ISO-2022-JP", "AUTO");
// formatting the sender string
$senderMIME = sprintf("%s <%s>", $senderNameMIME,
$senderEmailAddress);
// formatting the mime header
$headers = "MIME-Version: 1.0\n" ;
$headers .= sprintf("From: %s\n", $senderMIME);
$headers .= sprintf("Reply-To: %s\n", $senderMIME);
$headers .= "Content-Type: text/plain; charset=ISO-2022-JP\n";
// send encoded mail
$result = mail($recipientEmailAddress, $subjectMIME, $bodyJIS,
$headers);
// return result
return $result;
}
$to = "snip
snip.snip";
$subject = "かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字
かな漢字かな漢字かな漢字かな漢字";
$body = "かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字
かな漢字かな漢字かな漢字かな漢字";
$senderName = "かな漢字かな漢字かな漢字かな漢字かな漢字かな漢字
かな漢字かな漢字かな漢字かな漢字";
$senderEmailAddress = "snip
snip.snip";
// send the email
sendEmail($to, $subject, $body, $senderName, $senderEmailAddress);
?>
</body>
</html>
attached mail follows:
Hello,
on 03/20/2008 04:06 AM Dietrich Bollmann said the following:
> Hi,
>
> --- note ---
> I sent a similar message already to php-i18n - but this list seems
> not to be used very much (20 messages this year) so I am posting it
> here again...
> ------------
>
> I try to send messages written in Japanese (Kana/Kanji) with php.
>
> Everything works fine - only when the subject (or the name of the
> sender) becomes longer, there seems to be something wrong with the
> encoding: Neither my nor the mail reader of other (Japanese) friends
> decodes the mime string. At the place of the Japanese Characters,
> the mime string itself is displayed in the subject (to, reply to)
> field.
>
> As this doesn't happen for other Japanese emails with even longer
> subjects, I suppose I did something wrong ... but what?
You may want to try this MIME message composing and sending class that
can send messages with encoded headers correctly using any character
set. Take a look at the test_multibyte_message.php example script:
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
Hi - in order to see the Japanese Characters in the previous mail
you might have to switch the "Character Encoding" of your Email reader
to Unicode (UTF-8). In my case (I am using the "Evolution" mail program
on Linux):
View > Character Encoding > Unicode (UTF-8)
Dietrich
On Thu, 2008-03-20 at 16:06 +0900, Dietrich Bollmann wrote:
> I try to send messages written in Japanese (Kana/Kanji) with php.
>
> Everything works fine - only when the subject (or the name of the
> sender) becomes longer, there seems to be something wrong with the
> encoding: Neither my nor the mail reader of other (Japanese) friends
> decodes the mime string. At the place of the Japanese Characters,
> the mime string itself is displayed in the subject (to, reply to)
> field.
>
> As this doesn't happen for other Japanese emails with even longer
> subjects, I suppose I did something wrong ... but what?
attached mail follows:
On 20/03/2008, tedd <tedd.sperling
gmail.com> wrote:
> At 9:29 PM +0200 3/19/08, Dotan Cohen wrote:
> >I am asking the second question: how many Hebrew characters in a
> >string that _very_likely_ contains other characters as well. The array
> >suggestion sounds about what I am doing: checking if each letter is a
> >Hebrew character.
> >
> >I will also look into the mb_ functions. I did not know about them
> >before. Thanks.
> >
> >Dotan Cohen
>
>
> Dotan:
>
> It really doesn't make any difference.
>
> If you have a single character that is not ASCII, then it's something
> beyond ASCII and you'll need to use the mb_functions.
>
> Unicode contains all known characters (code points) including ASCII
> with values equal to ASCII -- so there's no problem between code
> points and ASCII.
>
> The beyond ASCII string problem is basically what is a character? We
> all know what an "a" is, but what about "a" with a "~" above it? Is
> it one character or two? If it's a combination of two code points,
> then it's a grapheme.
>
> What about the character "fi" when it's combined? Is it one character
> or two? In this case, it's a ligature and is a single code point.
>
> So, when you are trying to count characters in a string, using ASCII
> based functions won't work because they might count one character as
> two and break the character in two parts. Or, the character might be
> actually two characters, but they should be counted as one. As such,
> mb_functions are designed to work with these types of problems where
> as standard string functions won't.
>
> The easy way to tell IF you should use mb_functions is if all the
> characters you're working with appear in the ASCII table, then
> standard string functions apply. However, if any of the characters
> are not found in ASCII, then you need to go another route.
>
> At least, that's my understanding.
>
>
> Cheers,
>
> tedd
Thank you Tedd, that was very helpful. After reading your mail from
yesterday I went to wikipedia to learn what graphemes and ligatures
are. Your example of "fi" was there, otherwise I would have had no
idea that those letters can be combined. In Hebrew and Arabic,
especially, I can see how the vowel points (Hebrew) and combinations
like "LA" (Arabic) can confuse the ASCII function. Thanks.
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
attached mail follows:
Mark Weaver wrote:
> Hi all,
>
> I've been lurking and reading now for some time, but have decided to
> come out of the shadows cause I've got an issue that's gonna drive me
> crazy!
>
> I'm developing an application and within this application is a class
> that is very simple and only serves a singular purpose - to make log
> entries to help with debugging. Problem is, now I'm debugging the damned
> logging class that is supposed to be helping me debug the application as
> I'm putting it together! <sigh> I've looked and looked all over the
> place, but I don't seem to be able to find an answer to this problem.
> The only information that I have found so far deals with permissions and
> I don't think that's the problem. At first I was getting an access
> denied error but since setting dir perms and log file perms so that both
> apache and my user can right to both the directory and the file that one
> has gone away.
>
> Log Directory permissions: /mystuff/logs rwx-rwx-rwx (777)
> Log file permissions : /mystuff/logs/run.log rwx-rwx-rwx
> (777)
>
> At any rate, the following is the information I'm getting in the apache
> error_log while working on this particular portion of the application:
>
> PHP Warning: fwrite(): supplied argument is not a valid stream resource
> in /mystuff/inc/Log.inc on line 22,
> PHP Warning: fclose(): supplied argument is not a valid stream resource
> in /mystuff/inc/Log.inc on line 23,
>
> The Log class:
> -----------------------------
> class Log{
> public $path, $entry, $logfile;
>
> public function Log(){}
>
> public function setLog($path,$file){
> $this->path = $path;
> $this->logfile = $file;
> }
>
> public function writeLog($entry){
> // open the file, in this case the log file
> $h = "$this->path/$this->logfile";
> fopen($h, 'a+');
> fwrite($h,$entry);
> fclose($h);
> }
> }
>
> Code snippet where attempting to write log entry from program:
> --------------------------------------------------------------------------------------------
>
> $pl_log = new Log;
> $pl_log->setLog($logpath,"run.log");
>
> $usernanme = $_POST['username'];
> $password = $_POST['secret'];
>
> /**
> * (debugging) logging incoming values from form:
> */
> $pl_log->writeLog("getDateTime(): Incoming values from Login Form:
> blah...blah...blah\n");
>
> Any help with this would be most appreciated. (be gentle... I'm a PERL
> program learning PHP OOP)
>
As Stut pointed out, you've misunderstood the difference between a file resource
and a file name.
Try something like:
public function writeLog($entry)
{
// open the file, in this case the log file
$fileName = $this->path.'/'.$this->logfile;
$h = fopen($fileName, 'a+');
fwrite($h,$entry);
fclose($h);
}
The file resource that fwrite and fclose need is the *result* of opening the
file, not the file name as you were doing.
Ideally, you would check the value of $h after the fopen call, to make sure that
it had successfully opened the file.
Also, I changed the way you were constructing the file name: interpolating the
variables in a string is slightly less efficient than concatenating the bits
together, and there are possible gotchas when using the $this->variable
structure in a string like that.
An alternative syntax is to escape the variables with braces:
$fileName = "{$this->path}/{$this->logfile}";
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
attached mail follows:
Hi,
If anyone is using clsMsDocGenerator to produce MSWord files without using
COM, I have a just one question (I tried the PHPClasses forum, but couldn't
get my forum post in).
How do you remove borders from tables?
I am preformatting a html string with att the data going into the document,
including tables, but they always show a fine border, even though border is
set to 0 in my <table> formatting.
Any suggestions?
Cheers
George
attached mail follows:
De: George J [mailto:georgejamieson
btconnect.com]
> So calling the script via the form works i.e it passes the
> neccessary variables to constrct the sql query for the next
> call.
As Shawn said, if you really need the query again add it to session, never,
NEVER give the user the ability to see/execute queries by himself (remember
POST data could be easily manipulated). Remember what Daniel said, adding a
DELETE FROM is not hard and veeery bad.
> If the user clicks one of the pagination links, that
> calls itself, all that is passed is the page=$i variable. I
> need to include the 'SELECT * FROM...' query either as a string
> or an array of seperate values for the changed query.
Ok, let me ask you something. Why post to itself? You could have a script
only to do form actions, that way you can:
1 Separate huge php validations with your html form.
2 Use functions to handle the incoming data and writing the new query (or
the old one again).
As it's built at server side, the user is never going to see your query or
[1]manipulate it as you're writing it all over again, just using your old
parameters (they could be added as hidden fields in the form if strictly
necessary).
> So, as I see it, the pagination links won't POST the form
> variables. How do I pass the 'SELECT * FROM mytable WHERE
> selection=option LIMIT start, range'
> query to the called script?
You should try building a default query where you only add the parameters
given by the user. If you can't seem to recover that, add them to $_SESSION
and you'll be fine next time you want them (if you don't overwrite it =] ).
> George
Welcome and keep asking :)
[1] As long as you treat the user input properly, as other said.
--
PHP General Mailing List (http://www.php.net/) To unsubscribe,
visit: http://www.php.net/unsub.php
attached mail follows:
Hiyah,
Here's a trick you can use to evaluate expressions within strings. It
may not be particularly useful, but I thought it was interesting.
It exploits two things:
1. If you interpolate an array element within a string, the index of
the element is evaluated as a php expression.
2. You can can make your own magic arrays by extending arrayObject.
<?php
class identityArrayObject extends arrayObject
{
public function offsetGet($index)
{
return $index;
}
}
$eval = new identityArrayObject;
print "The square root of {$eval[pow(2,2)]} is {$eval[sqrt(4)]} \n";
print "Price: $price GBP ({$eval[$price * 1.175]} GBP including tax) \n";
?>
You can extend it to add your own formatting elements:
<?php
class uppercaseArrayObject extends arrayObject
{
public function offsetGet($index)
{
return strtoupper($index);
}
}
$U = new uppercaseArrayObject;
$city = 'edinburgh';
print "The capital of Scotland is $U[$city] \n";
?>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]