php-windows Digest 15 Feb 2001 02:29:58 -0000 Issue 446 Topics (messages 5563 through 5572): Re: pdflib put a image to a pdf file 5563 by: Jason Hoover 5564 by: Tom Mathews Bug in mktime-function ? 5565 by: Dirk.Dinger.dignos.com 5566 by: Pablo Vera 5567 by: Ignatius Teo 5568 by: Pablo Vera 5572 by: Ignatius Teo date conversion 5569 by: Vasu 5571 by: Andreas Lange Re: assigning variable names on the fly, backed myself in to a corner 5570 by: Nold, Mark 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] ----------------------------------------------------------------------
Rainer, Here is sample code for placing a .jpg image in pdf. Anyone out there get .gif images to work. I tried the code below without results (PHP Version 4.0.4pl1 running as cgi on Win NT). $fp = fopen("test.pdf", "w"); // pdf file to be created $pdfObject = PDF_open($fp); // creation of pdf oblject PDF_begin_page($pdfObject, $pageWidth, $pageHeight); // Start First Page PDF_add_outline($pdfObject, "Page 1"); // Add Bookmark for Indexing // JPG example $im = PDF_open_jpeg($pdfObject, "imageName.jpg"); // Assign image to variable pdf_place_image($pdfObject, $im, 100, 300, 1); // Place image pdf_close_image($pdfObject, $im); // close image // GIF example $im = PDF_open_gif($pdfObject, "apache_pb.gif"); // Assign image to variable pdf_place_image($pdfObject, $im, 100, 300, 1); // Place image pdf_close_image($pdfObject, $im); // close image PDF_end_page($pdfObject); // End Page PDF_close($pdfObject); // Close PDF Object fclose($fp); // Close PDF File Jason Hoover Web Application Programmer Entolo 2299 Territorial Road St. Paul, MN 55114 Phone: 763.847.8022 Fax: 763.642.1600 [EMAIL PROTECTED] www.entolo.com -----Original Message----- From: Rainer Schaaf [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 4:06 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: [PHP-WIN] Re: pdflib put a image to a pdf file > Hallo! > I got this problem, I can't insert a image to the pdf > document. I useing " pdf_place_image($pdfdoc, "test.gif", 100, 100, 1); " > Is it anybody got a tip.. > You should first open the image with pdf_open_image_file pdf_place_image expects a handle to an already opend image. The PDFlib manual which comes with the PDFlib sourcedistribution contains some examples. > Best regards. > //Glenn > > ................................................................ > 80.000 svenskar har nu gratis e-post på Sverige.nu! > -- Rainer Schaaf [EMAIL PROTECTED] http://www.pdflib.com _______PDFlib - a library for generating PDF on the fly________
I've never tried, but I'm wandering if it is related to the GIF licensing issue that forced GIF's out of the GD libraries - does anyone know if the same happenned to the PDF libraries? Tom Jason Hoover wrote: > Rainer, > > Here is sample code for placing a .jpg image in pdf. Anyone out there get > .gif images to work. I tried the code below without results (PHP Version > 4.0.4pl1 running as cgi on Win NT). > > $fp = fopen("test.pdf", "w"); // pdf file to be > created > $pdfObject = PDF_open($fp); // creation > of pdf oblject > PDF_begin_page($pdfObject, $pageWidth, $pageHeight); // Start First Page > PDF_add_outline($pdfObject, "Page 1"); // Add Bookmark for > Indexing > > // JPG example > $im = PDF_open_jpeg($pdfObject, "imageName.jpg"); // Assign image to > variable > pdf_place_image($pdfObject, $im, 100, 300, 1); // Place image > pdf_close_image($pdfObject, $im); // close image > > // GIF example > $im = PDF_open_gif($pdfObject, "apache_pb.gif"); // Assign image to variable > pdf_place_image($pdfObject, $im, 100, 300, 1); // Place image > pdf_close_image($pdfObject, $im); // close image > > PDF_end_page($pdfObject); // End Page > PDF_close($pdfObject); // Close PDF Object > fclose($fp); // Close PDF File > > Jason Hoover > Web Application Programmer > > Entolo > 2299 Territorial Road > St. Paul, MN 55114 > Phone: 763.847.8022 > Fax: 763.642.1600 > [EMAIL PROTECTED] > www.entolo.com > > -----Original Message----- > From: Rainer Schaaf [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 14, 2002 4:06 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: [PHP-WIN] Re: pdflib put a image to a pdf file > > > Hallo! > > I got this problem, I can't insert a image to the pdf > > document. I useing " pdf_place_image($pdfdoc, "test.gif", 100, 100, 1); " > > Is it anybody got a tip.. > > > You should first open the image with pdf_open_image_file pdf_place_image > expects a handle to an already opend image. The PDFlib manual which > comes with the PDFlib sourcedistribution contains some examples. > > > Best regards. > > //Glenn > > > > ................................................................ > > 80.000 svenskar har nu gratis e-post på Sverige.nu! > > > > -- > Rainer Schaaf [EMAIL PROTECTED] http://www.pdflib.com > _______PDFlib - a library for generating PDF on the fly________ > > -- > PHP Windows 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]
Hello PHP-users, given the following code snippet to convert ISO-date-strings to localized date-strings: <?php $stringArray = explode("-", "1985-01-01"); $month = $stringArray[1]; $day = $stringArray[2]; $year = $stringArray[0]; $date = mktime(0,0,0,$month,$day,$year); $value = strftime("%d.%m.%Y", $date); echo $value; ?> This code works fine as long as I use dates after 1970, all earlier dates result in an empty value. According to the docs, mktime is supposed to work fine with 4-digit dates. What is the problem here... Greetings, Dirk
Dirk: Date/time values in PHP are handled as UNIX timestamps, that is, the number of seconds since what they call the UNIX Epoch (whatever it means), in other words, 1970. Before that, nothing existed, so no need for time. Saludos, Pablo _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Wednesday, February 14, 2001, 10:29:36 AM, Dirk wrote: DDdc> Hello PHP-users, DDdc> given the following code snippet to convert ISO-date-strings to localized DDdc> date-strings: DDdc> <?php DDdc> $stringArray = explode("-", "1985-01-01"); DDdc> $month = $stringArray[1]; DDdc> $day = $stringArray[2]; DDdc> $year = $stringArray[0]; DDdc> $date = mktime(0,0,0,$month,$day,$year); DDdc> $value = strftime("%d.%m.%Y", $date); DDdc> echo $value; ?>> DDdc> This code works fine as long as I use dates after 1970, all earlier DDdc> dates result in an empty value. DDdc> According to the docs, mktime is supposed to work fine with 4-digit DDdc> dates. DDdc> What is the problem here... DDdc> Greetings, DDdc> Dirk
RXIuLi5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o+IA0KPiAtLSANCj4gUEhQIFdpbmRvd3MgTWFpbGluZyBM aXN0IChodHRwOi8vd3d3LnBocC5uZXQvKQ0KPiBUbyB1bnN1YnNjcmliZSwgZS1tYWlsOiBwaHAt d2luZG93cy11bnN1YnNjcmliZUBsaXN0cy5waHAubmV0DQo+IEZvciBhZGRpdGlvbmFsIGNvbW1h bmRzLCBlLW1haWw6IHBocC13aW5kb3dzLWhlbHBAbGlzdHMucGhwLm5ldA0KPiBUbyBjb250YWN0 IHRoZSBsaXN0IGFkbWluaXN0cmF0b3JzLCBlLW1haWw6IA0KPiBwaHAtbGlzdC1hZG1pbkBsaXN0 cy5waHAubmV0DQo+IA==
We do exist, but on a different time frame, something like a parallel universe ... just kidding ;-) Pablo. Wednesday, February 14, 2001, 5:01:24 PM, Ignatius wrote: IT> Er...does this mean that those of us born before the advent of Unix don't exist? :-) IT> Ignatius >> -----Original Message----- >> From: Pablo Vera [mailto:[EMAIL PROTECTED]] >> Sent: Thursday, 15 February 2001 04:30 >> To: [EMAIL PROTECTED] >> Subject: Re: [PHP-WIN] Bug in mktime-function ? >> >> >> Dirk: >> >> Date/time values in PHP are handled as UNIX timestamps, that is, the >> number of seconds since what they call the UNIX Epoch (whatever it >> means), in other words, 1970. Before that, nothing existed, so no >> need for time. >> >> Saludos, >> Pablo >> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >> >> Wednesday, February 14, 2001, 10:29:36 AM, Dirk wrote: >> >> >> DDdc> Hello PHP-users, >> >> DDdc> given the following code snippet to convert >> ISO-date-strings to localized >> DDdc> date-strings: >> >> DDdc> <?php >> >> DDdc> $stringArray = explode("-", "1985-01-01"); >> DDdc> $month = $stringArray[1]; >> DDdc> $day = $stringArray[2]; >> DDdc> $year = $stringArray[0]; >> >> DDdc> $date = mktime(0,0,0,$month,$day,$year); >> DDdc> $value = strftime("%d.%m.%Y", $date); >> >> DDdc> echo $value; >> ?>> >> >> DDdc> This code works fine as long as I use dates after 1970, >> all earlier >> DDdc> dates result in an empty value. >> DDdc> According to the docs, mktime is supposed to work fine >> with 4-digit >> DDdc> dates. >> >> DDdc> What is the problem here... >> >> DDdc> Greetings, >> >> DDdc> Dirk >> >> >> >> >> -- >> PHP Windows 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] >>
SXMgaXQgbWUgb3IgSSBhbSB0aGUgb25seSBvbmUgZ2V0dGluZyB0d28gY29waWVzIG9mIHRoZSBz YW1lIG1lc3NhZ2U/DQoNCkRpcmssIHRoaXMgYXMgYWxyZWFkeSBhbnN3ZXJlZCBieSBzb21lb25l IGVsc2Ugb24gdGhlIGxpc3QuIG1rdGltZSAoYWNjb3JkaW5nIHRvIHRoZSBQSFAgbWFudWFsKSAi Li4ucmV0dXJucyB0aGUgVW5peCB0aW1lc3RhbXAgY29ycmVzcG9uZGluZyB0byB0aGUgYXJndW1l bnRzIGdpdmVuLiBUaGlzIHRpbWVzdGFtcCBpcyBhIGxvbmcgaW50ZWdlciBjb250YWluaW5nIHRo ZSBudW1iZXIgb2Ygc2Vjb25kcyBiZXR3ZWVuIHRoZSBVbml4IEVwb2NoIChKYW51YXJ5IDEgMTk3 MCkgYW5kIHRoZSB0aW1lIHNwZWNpZmllZCIuDQoNCi4uLiJZZWFyIG1heSBiZSBhIHR3byBvciBm b3VyIGRpZ2l0IHZhbHVlLCB3aXRoIHZhbHVlcyBiZXR3ZWVuIDAtNjkgbWFwcGluZyB0byAyMDAw LTIwNjkgYW5kIDcwLTk5IHRvIDE5NzAtMTk5OSAob24gc3lzdGVtcyB3aGVyZSB0aW1lX3QgaXMg YSAzMmJpdCBzaWduZWQgaW50ZWdlciwgYXMgbW9zdCBjb21tb24gdG9kYXksIHRoZSB2YWxpZCBy YW5nZSBmb3IgeWVhciBpcyBzb21ld2hlcmUgYmV0d2VlbiAxOTAyIGF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lKCIlZC4lbS4lWSIsICRkYXRlKTsNCj4gDQo+IAllY2hvICR2 YWx1ZTsNCj4gPz4NCj4gDQo+IFRoaXMgY29kZSB3b3JrcyBmaW5lIGFzIGxvbmcgYXMgSSB1c2Ug ZGF0ZXMgYWZ0ZXIgMTk3MCwgYWxsIGVhcmxpZXINCj4gZGF0ZXMgcmVzdWx0IGluIGFuIGVtcHR5 IHZhbHVlLg0KPiBBY2NvcmRpbmcgdG8gdGhlIGRvY3MsIG1rdGltZSBpcyBzdXBwb3NlZCB0byB3 b3JrIGZpbmUgd2l0aCA0LWRpZ2l0DQo+IGRhdGVzLg0KPiANCj4gV2hhdCBpcyB0aGUgcHJvYmxl bSBoZXJlLi4uDQo+IA0KPiBHcmVldGluZ3MsDQo+IA0KPiBEaXJrDQo+IA0KPiANCj4gDQo+IC0t IA0KPiBQSFAgV2luZG93cyBNYWlsaW5nIExpc3QgKGh0dHA6Ly93d3cucGhwLm5ldC8pDQo+IFRv IHVuc3Vic2NyaWJlLCBlLW1haWw6IHBocC13aW5kb3dzLXVuc3Vic2NyaWJlQGxpc3RzLnBocC5u ZXQNCj4gRm9yIGFkZGl0aW9uYWwgY29tbWFuZHMsIGUtbWFpbDogcGhwLXdpbmRvd3MtaGVscEBs aXN0cy5waHAubmV0DQo+IFRvIGNvbnRhY3QgdGhlIGxpc3QgYWRtaW5pc3RyYXRvcnMsIGUtbWFp bDogDQo+IHBocC1saXN0LWFkbWluQGxpc3RzLnBocC5uZXQNCj4g
Hi, I am trying to get US date out of a DATETIME column but it returns "12/31/1969". The line of code that I am using is: <?php echo date("m/d/Y", $Row->FileSentDate); ?> According to the documentation, the second parameter of the date() function requires timestamp value which is int data type. If any of you know how to convert a value into timestamp or any other solution to get US date out of a string or DATETIME column, please let me know. Thanks for your help. Vasu
> -----Original Message----- > From: Vasu [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 15, 2001 1:53 AM > To: [EMAIL PROTECTED] > Subject: [PHP-WIN] date conversion > > > Hi, > > I am trying to get US date out of a DATETIME column but it > returns "12/31/1969". The line of code that I am using is: > > <?php echo date("m/d/Y", $Row->FileSentDate); ?> in php u can convert it via: int mktime (int hour, int minute, int second, int month, int day, int year [, int is_dst]) the return-value is unix-timestamp > According to the documentation, the second parameter of the > date() function requires timestamp value which is int data type. > If any of you know how to convert a value into timestamp or any > other solution to get US date out of a string or DATETIME column, u can also use a simple SQL-Query (i.e. in MySQL): "SELECT UNIX_TIMESTAMP(datetimefield) AS unixtime FROM table" so SQL return a unix-timestamp instead of a pre-formated datetime string ;) > please let me know. > > Thanks for your help. > > > Vasu Hopes this solves your probs ;) CodeDuck
---------------------------------------------------------------------------- ----------------- Disclaimer: The information contained in this email is intended only for the use of the person(s) to whom it is addressed and may be confidential or contain legally privileged information. If you are not the intended recipient you are hereby notified that any perusal, use, distribution, copying or disclosure is strictly prohibited. If you have received this email in error please immediately advise us by return email at [EMAIL PROTECTED] and delete the email document without making a copy. ---------------------------------------------------------------------------- ----------------- I've personally found that whenever you use "variable-variables" you a probably better off using an array. if you have $tag_num[1] = 12345; $tag_type[1] = "My Type of tag"; $tag_cost[1] = 1.23; $tag_num[2] = 98654; $tag_type[2] = "Not my Type of tag"; $tag_cost[2] = 1.66; $tag_num[3] = 109876; $tag_type[3] = "Unknown tag"; $tag_cost[3] = 1.77; reset($tag_num); while(list($key,$value) = each($tag_num)){ $tag_cost[$key] = round($tag_cost[$key],2); echo "The KEY is $key and the VALUE is $value<br>\n"; // Now do your SQL stuff } This is a bit messy because if you dont have a $tag_num it'll ignore tag_type and $tag_cost. I prefere to use 2D arrays, im assuming the $tag_num is some sort of unique identifier.. <? $tag["12345"]["type"] = "My type of Tag"; $tag["12345"]["cost"] = "1.23"; $tag["98654"]["type"] = "Not my type of Tag"; $tag["98654"]["cost"] = "1.66"; $tag["109876"]["type"] = "Unknown Tag"; $tag["109876"]["cost"] = "1.77"; while(list($key,$data) = each($tag)){ $data["cost"] = round($data["cost"],2); //$tag[$key]["cost"] = round($data["cost"],2); // This will modify the original array, but not $data["cost"] echo "The tag is $key, the type is {$data['type']} and the cost is {$data['cost']}<br>\n"; //echo "The tag is $key, the type is $data[type] and the cost is $data[cost]<br>\n"; // This will work but im not sure how correct it is. // Do your SQL thang } ?> These are very useful as you can unset($tag["109876"]) to get rid of data and since you arent using a sequential for() loop you dont have to worry about missing data. This one comes down to taste though. I like the 2d arrays because they are similiar to data sets from your db or a spreadsheet. mn Mark Nold [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Senior Consultant Change is inevitable, except from vending machines. -----Original Message----- From: Asendorf, John [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 14, 2001 9:49 PM To: Ignatius Teo; Asendorf, John; 'Darvin Andrioli'; 'Php-Windows (E-mail)' Subject: RE: [PHP-WIN] assigning variable names on the fly, backed myself in to a corner Well, here's what I came up with that finally worked for me: for ( $i=1 ; $i <= $tag_count ; $i++ ) { //tag_count came from the post page $tag_num = "tag_num$i"; $tag_type = "tag_type$i"; $tag_cost = "tag_cost$i"; if ( $$tag_cost == "" ) { // can't have empty data per database parameters $$tag_cost = "0.00"; } $tag_late = "tag_late$i"; if ( $$tag_late == "" ) { // can't have empty data per database parameters $$tag_late = "0.00"; } $sql = "INSERT into cfull2.tbl_dl_tags (TAGID_NUM, CUSTID_NUM, TAG_NO, TAG_YEAR, TYPE_CODE, COST, LATE) VALUES( $TAGID_NUM, $CUSTID_NUM, ${$tag_num}, $this_year, '${$tag_type}' , ${$tag_cost}, ${$tag_late} )"; echo $sql; //debug SQL $stmt = OCIParse ( $connection , $sql ); OCIExecute ( $stmt , OCI_DEFAULT ); OCICommit( $connection ); OCIFreeStatement ( $stmt ); $TAGID_NUM++; } John --------------------- John Asendorf - [EMAIL PROTECTED] Web Applications Developer http://www.lcounty.com - NEW FEATURES ADDED DAILY! Licking County, Ohio, USA 740-349-3631 Ipsa scientia potestas est > -----Original Message----- > From: Ignatius Teo [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 13, 2001 5:32 PM > To: 'Asendorf, John'; 'Darvin Andrioli'; 'Ignatius Teo'; 'Php-Windows > (E-mail)' > Subject: RE: [PHP-WIN] assigning variable names on the fly, backed > myself in to a corner > > > No probs John. I'll take that in non-sequential small US > denominations, thanks! :-) And of course Darvin can have half. > > Ignatius > > > -----Original Message----- > > From: Asendorf, John [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, 14 February 2001 00:33 > > To: Darvin Andrioli; 'Ignatius Teo'; Asendorf, John; 'Php-Windows > > (E-mail)' > > Subject: RE: [PHP-WIN] assigning variable names on the fly, backed > > myself in to a corner > > > > > > That's the ticket. Thanks a million! > > > > --------------------- > > John Asendorf - [EMAIL PROTECTED] > > Web Applications Developer > > http://www.lcounty.com - NEW FEATURES ADDED DAILY! > > Licking County, Ohio, USA > > 740-349-3631 > > Ipsa scientia potestas est > > > > > > > -----Original Message----- > > > From: Darvin Andrioli [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, February 13, 2001 6:52 AM > > > To: 'Ignatius Teo'; 'Asendorf, John'; 'Php-Windows (E-mail)' > > > Subject: RE: [PHP-WIN] assigning variable names on the fly, backed > > > myself in to a corner > > > > > > > > > Ignatius wrote: > > > > > > > try assigning it to another variable first: > > > > for .... > > > > $tag = "$tag_num$i"; > > > > $type = "tag_type$i"; > > > > $sql = .... VALUES (..., $tag, $type....); > > > > > > The last statement must be: > > > $sql = .... VALUES (..., $$tag, $$type....); > > > > > > so you get the value of the variable named tag_type$i, > > > otherwise yo get only the string "tag_type value of $i" > > > > > > Darvin > > > > > > > > > > -----Original Message----- > > > > From: Asendorf, John [mailto:[EMAIL PROTECTED]] > > > > Sent: Tuesday, 13 February 2001 07:58 > > > > To: Php-Windows (E-mail) > > > > Subject: [PHP-WIN] assigning variable names on the fly, > > > > backed myself in > > > > to a corner > > > > > > > > > > > > I've written a little script that makes a form using a simple > > > > for loop: > > > > > > > > if ( $num_reg != "" ) { //we're doing regulars > > > > > > > > for ( $i = 1 ; $i <= $num_reg ; $i++ ) { > > > > echo "<tr><td>A<input type=\"hidden\" > > > > name=\"tag_type${i}\" > > > > value=\"A\"></td>"; > > > > echo "<td><input type=\"text\" > > > > name=\"tag_num${i}\"></td>"; > > > > echo "<td><input type=\"text\" > name=\"tag_cost${i}\" > > > > value=\"\"></td>"; > > > > echo "<td><input type=\"text\" > > > > name=\"tag_late${i}\"></td></tr>\n"; > > > > } > > > > > > > > $tag_count = $num_reg; > > > > > > > > } > > > > > > > > Now what I have is a number of variables that look > > > something like this > > > > > > > > $tag_type1, $tag_num1, $tag_cost1, $tag_late1, $tag_type2, > > > $tag_num2, > > > > $tag_cost2, $tag_late2, etcetera... up to any number of tags... > > > > > > > > now I'm trying to write a little for loop that drops this > > > > information into a > > > > database after the POST: > > > > > > > > for ( $i=1 ; $i <= $tag_count ; $i++ ) { //tag_count came > > > > from the post > > > > (dl_post_3.php) > > > > > > > > $sql = "INSERT into cfull2.tbl_dl_tags (TAGID_NUM, > > > > CUSTID_NUM, TAG_NO, > > > > TAG_YEAR, TYPE_CODE, COST, TYPE) VALUES ($CUSTID_NUM, > > > > $tag_num$i, $tag_year, > > > > '$tag_type$i' , $tag_cost$i )"; > > > > > > > > $stmt = OCIParse ( $connection , $sql ); > > > > > > > > OCIExecute ( $stmt , OCI_DEFAULT ); > > > > OCICommit( $connection ); > > > > OCIFreeStatement ( $stmt ); > > > > } > > > > > > > > > > > > This obviously doesn't work and I'm not really sure what to > > > > do now. Is this > > > > a case of variable variable names? I don't quite get those > > > either :) > > > > > > > > Thanks in advance all, > > > > > > > > John > > > > > > > > > > > > --------------------- > > > > John Asendorf - [EMAIL PROTECTED] > > > > Web Applications Developer > > > > http://www.lcounty.com - NEW FEATURES ADDED DAILY! > > > > Licking County, Ohio, USA > > > > 740-349-3631 > > > > Ipsa scientia potestas est > > > > > > > > > > > > -- > > > > PHP Windows 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 Windows 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] > > >