php-general Digest 27 Sep 2007 14:30:48 -0000 Issue 5041
php-general Digest 27 Sep 2007 14:30:48 - 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] -- ---BeginMessage--- 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--- ---BeginMessage--- 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--- ---BeginMessage--- Robert Cummings wrote: When
Re: [PHP] trouble trying to connect to gmail server.
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}INBOXhttp://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}INBOXhttp://pop.gmail.com:995/pop3%7DINBOXin 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PDOStatement execute memory issue?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] move_uploaded_file permission problem under php5
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] freopen?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with donwload
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] languages and PHP
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] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
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] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
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] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Fwd: Attachment Size and Memory limit with php and FC6 System]
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.
Re: [PHP] counting with leading zeros
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! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Fwd: Attachment Size and Memory limit with php and FC6 System]
[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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting with leading zeros
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting with leading zeros
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting with leading zeros
At 10:39 PM -0400 9/26/07, brian wrote: Now you're obviously just trying to be a dickhead. While someone is, it's not Rob. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] languages and PHP
David Christopher Zentgraf wrote: 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 I work almost exclusively in UTF-8 (language irrelevant), but I've never had to do any of the above. The mb_convert_encoding() from UTF-8 to UTF-8 doesn't seem to make much sense? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with donwload
Hulf wrote: 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) = here you set a variable called $file_name mysql_fetch_array($result); /*echo $file_name; echo $type; echo $size;*/ header(Content-Type: $type); header(Content-Disposition: attachment; filename=$file_name); here you are using $file_name header(Content-Length: .filesize($file)); here you are using $file Isn't this something that someone pointed out earlier in the week? from the input script, it looks like you should be using $size instead of filename($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; } ? Thanks, -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple product selection guide
At 12:07 PM -0400 9/26/07, David wrote: This is probably pretty basic but : I'd like to create a page where the end result is the product(s) listed based on certain criteria selected by the user, so I would like a drop down menu or other means that they select from and based on that selection a second list apears and then a third list, and then from those criteria have the product or products listed I have a php/mysql host. What would you recomend to develop this. Thanks. A lot of work in both php and mysql. Here's an example: http://ancientstones.com It's quite involved. Good luck, it can be done. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: languages and PHP
Per Jessen wrote: David Christopher Zentgraf wrote: 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 I work almost exclusively in UTF-8 (language irrelevant), but I've never had to do any of the above. The mb_convert_encoding() from UTF-8 to UTF-8 doesn't seem to make much sense? I agree. Provided you HTML is dished out with UTF-8 in the doctype definiton etc. then all forms are automatically sent in UTF-8 Also for multilingual content (labels etc.) in PHP have a look at the gettext extension. This will let you code in your default language with a minimal wrapper and translate to other languages with catalog files. Be careful about breaking strings tho' as the xgettext crawler file will not be able to extract strings properly. Also do not use variable substituion but rather use printf/sprintf e.g.: $var = sprintf(_('Here is %d example of a translatable string.'), 1); That way the string you translate is nice and standard.(here _() is the name of the gettext function which is quite common). You may leave this up to your templating engine (e.g. no labels in code), so it may not matter. Also if you are writing modular code, ensure you think about the gettext domains first and you'll probably want to pass the domain in with *every* string in your system to ensure it's modular design (e.g. each module has it's own gettext domain). If you want a good example of modular gettext usage, I'd recommend looking at the source of gallery2. HTH. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDOStatement execute memory issue?
The problem is isolated to PDO ODBC -- old school ODBC works fine. Below are my test cases. Plain old ODBC: ?php // lobtestOdbc.php $res = odbc_connect('fmarchive_mssql', 'change', 'me'); if (!$res) { die ('failed to connect'); } $stp = 'SELECT attdata FROM fm_faxin_att WHERE id = 11908591344 AND attid = 0'; // statement to prepare $ps = odbc_prepare($res, $stp); if (!$res) { die ('failed to prepare statement'); } $execResult = odbc_execute($ps); echo var_export($execResult, true); ? The output from the plain old ODBC test case is: true (indicating that odbc_execute succeeded, see http://www.php.net/manual/en/function.odbc-execute.php). Next up, PDO ODBC: ?php // lobtestPdoOdbc.php try { $db = new PDO('odbc:fmarchive_mssql', 'change', 'me'); $stp = 'SELECT attdata FROM fm_faxin_att WHERE id = 11908591344 AND attid = 0'; // statement to prepare $ps = $db-prepare($stp); $execResult = $ps-execute(); var_export($execResult, true); } catch (PDOException $e) { die($e-getMessage()); } ? When running lobtestPdoOdbc.php, I get the same old error: *Fatal error*: Out of memory (allocated 262144) (tried to allocate 4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php* on line *9* I tried removing the try-catch blocks with no change in output (still gets the exact same Fatal Error) -- not like that would be an acceptable solution anyway. It appears this is a problem with PDO. I'm starting to really get out of my league now. How can I go about fixing this? Regards, Carlton Whitehead Larry Garfield wrote: 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Conditional jump menu
Does anyone know how to create a field based on a menu choice? When the menu is selected, then another field is created with an associated number. For instance: Selection = Collie Field = 1 Selection = AkitaField = 2 And so on... Thanks, -- Steve M.
RE: [PHP] Conditional jump menu
[snip] Does anyone know how to create a field based on a menu choice? When the menu is selected, then another field is created with an associated number. For instance: Selection = Collie Field = 1 Selection = AkitaField = 2 [/snip] Javascript, DHTML, and AJAX -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PDOStatement execute memory issue?
Hi Colin, The MS documentation says the image type can hold up to 2GB: http://technet.microsoft.com/en-us/library/ms187993.aspx It appears someone beat me to filing a bug report about this: http://bugs.php.net/bug.php?id=42765 I guess that's that for now until this gets fixed. Regards, Carlton Whitehead - Original Message - From: Colin Guthrie [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, September 27, 2007 4:04:53 AM (GMT-0500) America/New_York Subject: [PHP] Re: PDOStatement execute memory issue? 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
Colin Guthrie wrote: Per Jessen wrote: I work almost exclusively in UTF-8 (language irrelevant), but I've never had to do any of the above. The mb_convert_encoding() fromUTF-8 to UTF-8 doesn't seem to make much sense? I agree. Provided you HTML is dished out with UTF-8 in the doctype definiton etc. then all forms are automatically sent in UTF-8 Quite so. Also for multilingual content (labels etc.) in PHP have a look at the gettext extension. This will let you code in your default language with a minimal wrapper and translate to other languages with catalog files. I haven't done much with gettext yet - I use apache language content negotiation, separate source-files per language, and try hard to keep my PHP code language neutral. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
Edward Vermillion wrote: But what happens if you get data that's *not* UTF-8? Just because your html/form is set to UTF-8 doesn't mean that all your incoming data will be UTF-8. Yes it does. If your HTML page was sent in UTF-8, any request originating from that page will also be in UTF8. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
On 9/27/07, Edward Vermillion [EMAIL PROTECTED] wrote: But what happens if you get data that's *not* UTF-8? Just because your html/form is set to UTF-8 doesn't mean that all your incoming data will be UTF-8. just my experience, but as long as it has the meta tag w/ utf-8 in it, the browser sends (and receives) utf-8. i can store the strings in mysql without modification or character set conversion, it works like a charm. the only thing that might need help then is doing string modifications like urlencoding, or replacement on the utf-8 characters... i haven't had to do that yet, but otherwise the end-to-end utf-8 solution has worked like a charm for me. but yes, it does require browsers+utf8, running it out of that context may or may not work depending on what you're trying to do with the data.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
On Sep 27, 2007, at 10:09 AM, Colin Guthrie wrote: Per Jessen wrote: David Christopher Zentgraf wrote: 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 I work almost exclusively in UTF-8 (language irrelevant), but I've never had to do any of the above. The mb_convert_encoding() from UTF-8 to UTF-8 doesn't seem to make much sense? I agree. Provided you HTML is dished out with UTF-8 in the doctype definiton etc. then all forms are automatically sent in UTF-8 But what happens if you get data that's *not* UTF-8? Just because your html/form is set to UTF-8 doesn't mean that all your incoming data will be UTF-8. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
On Sep 27, 2007, at 1:49 PM, Per Jessen wrote: Edward Vermillion wrote: But what happens if you get data that's *not* UTF-8? Just because your html/form is set to UTF-8 doesn't mean that all your incoming data will be UTF-8. Yes it does. If your HTML page was sent in UTF-8, any request originating from that page will also be in UTF8. ... and you can guarantee that any data coming into your site comes from your form?!? WOW!!! ;) So back to my original question, what breaks if you're *expecting* UTF-8 and you don't *get* UTF-8? Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: languages and PHP
Edward Vermillion wrote: ... and you can guarantee that any data coming into your site comes from your form?!? WOW!!! ;) So back to my original question, what breaks if you're *expecting* UTF-8 and you don't *get* UTF-8? As long as my server isn't vulnerable to it, I couldn't care less. I'm certainly not going to be that defensive and write my code to deal with such situations. If someone POSTs or GETs something not in UTF-8 from outside my site, and I can't deal with it, it's their problem, not mine. And with PHP being the solid platform it is, it wouldn't dream of taking down my server just because I get KOI8-R when I expected UTF-8 :-) /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] want to learn about zend
hello people anyone know a good tutorial to learn the basics of zend, how it works and how to use? Regards, Gonzalo
[PHP] Curl Timeout causing Firefox to Download PHP File ?!?
Ave, I¹m not sure what¹s causing the problem, but I have a feeling that its¹ a timeout issue. I have a curl function that retrieves specific data from a remote webpage. The script works fine on my localhost, but when I upload it to my remote server, the script tries to execute, but 10 15 seconds into it, Firefox gives me an option to download the PHP script. Googling it I found that the Curl function taking too long might cause a timeout, which Firefox interprets by giving a Download option for the script. Safari on the other hand says ³Could not load data from script². Again, same script works on localhost on both browsers. I don¹t know if that¹s the real cause or if something is wrong with my script. Note that latest PHP Curl are enabled and working on the remote server, and other PHP pages curl functions run on that remote server, so that¹s not an issue. Here¹s my curl function: ?php # Gather cookies in a Jar $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, ³path-to-cookieFileName); curl_setopt($ch, CURLOPT_URL,http://www.mywebsite.com;); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); ob_start(); // prevent any output curl_exec ($ch); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($ch); unset($ch); # Login with your Cookie Jar $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, usr=usrnamepwd=password); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, path-to-cookieFileName); curl_setopt($ch, CURLOPT_URL,http://www.mywebsite.com;); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $result = curl_exec ($ch); curl_close ($ch); # Get the text in the middle of ... function get_middle($source, $beginning, $ending, $init_pos) { $beginning_pos = strpos($source, $beginning, $init_pos); $middle_pos = $beginning_pos + strlen($beginning); $ending_pos = strpos($source, $ending, $beginning_pos + 1); $middle = substr($source, $middle_pos, $ending_pos - $middle_pos); return $middle; } # trim result and get what you need ... $share_ratio = get_middle($result, 'Share ratio', '/tr', 0); $share_ratio2 = trim(ereg_replace([\n\r\t], , $share_ratio)); $share_ratio3 = substr($share_ratio2, 25, 5); echo Ratio: STRONG$share_ratio3/STRONG; ? ~~~ Rahul Sitaram Johari CEO, Twenty Four Seventy Nine Inc. W: http://www.rahulsjohari.com E: [EMAIL PROTECTED] ³I morti non sono piu soli ... The dead are no longer lonely²
Re: [PHP] want to learn about zend
On 9/27/07, Gonzalo PHPFan [EMAIL PROTECTED] wrote: hello people anyone know a good tutorial to learn the basics of zend, how it works and how to use? Regards, Gonzalo Google: Zend Basics First result: Understanding the Zend Framework, Part 1: The basics www.ibm.com/developerworks/opensource/library/os-php-zend1 Tijnema -- If this is a mailing list: DO NOT TOP POST! why?: http://www.caliburn.nl/topposting.html Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SimpleXMLElement is not Simple
On Friday 28 September 2007 11:09, Nathan Nobbe wrote: just curious, what database are you using? I am using MySQL Ver 14.12 Distrib 5.0.22 cheers, Jeffery -nathan On 9/27/07, Jeffery Fernandez [EMAIL PROTECTED] wrote: I am having nightmares with this bit off code. The following code work perfectly fine: $soap_request_string = XML ?xml version=1.0 encoding=UTF-8? env:Envelope xmlns:env=http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:enc= http://www.w3.org/2003/05/soap-encoding; env:Body ns1:make_proxy_payment env:encodingStyle= http://www.w3.org/2003/05/soap-encoding; payment_id61ecc268-1cd0-f468/payment_id payment_amount15495/payment_amount callback_query_stringamp;payment_id=61ecc268-1cd0-f468/callback_query _string transaction_noteOrder from Student Library Fees with Payment Id: 61ecc268-1cd0-f468/transaction_note /ns1:make_proxy_payment /env:Body /env:Envelope XML; $xml = new SimpleXMLElement($soap_request_string, NULL, false, ' http://www.w3.org/2003/05/soap-envelope'); print_r($xml); $ns = $xml-getNamespaces(true); //print_r($ns); foreach ($xml-children($ns['env']) as $body) { //printf(%sbr /, $body-getName()); foreach ($body-children($ns['ns1']) as $function) { printf(function %s()br /, $function-getName()); foreach ($function-children() as $parameters) { printf(%s = \%s\br /, $parameters-getName(), $parameters); } } } However when the XML string is coming from the database it does not work. The Field and table have a collation of utf8_unicode_ci $soap_request_string = trim(str_replace(array(\n), '', $record['SoapRequestEnvelope'])); $xml = new SimpleXMLElement($soap_request_string, NULL, false, ' http://www.w3.org/2003/05/soap-envelope'); print_r($xml); The above code is supposed to print out the following (for me to proceed further): SimpleXMLElement Object ( [Body] = SimpleXMLElement Object ( ) ) but only returns: SimpleXMLElement Object ( ) The XL string from the database looks exactly like this (after replacing new lines): ?xml version=1.0 encoding=UTF-8?env:Envelope xmlns:env= http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xmlns:enc= http://www.w3.org/2003/05/soap-encoding;env:Bodyns1:make_proxy_paymen t env:encodingStyle=http://www.w3.org/2003/05/soap-encoding;payment_id5 ce30dcc-7df7-04e8/payment_idpayment_amount10/payment_amountcallback _query_stringamp;payment_id=5ce30dcc-7df7-04e8/callback_query_stringt ransaction_noteOrder from Student Library Fees with Payment Id: 5ce30dcc-7df7-04e8/transaction_note/ns1:make_proxy_payment/env:Body /env:Envelope I can't figure out whats wrong with the code. Any suggestions? cheers, Jeffery -- Internet Vision Technologies Level 1, 520 Dorset Road Croydon Victoria - 3136 Australia -- Internet Vision Technologies Level 1, 520 Dorset Road Croydon Victoria - 3136 Australia pgpYLgM4DjM0T.pgp Description: PGP signature
Re: [PHP] SimpleXMLElement is not Simple
just curious, what database are you using? -nathan On 9/27/07, Jeffery Fernandez [EMAIL PROTECTED] wrote: I am having nightmares with this bit off code. The following code work perfectly fine: $soap_request_string = XML ?xml version=1.0 encoding=UTF-8? env:Envelope xmlns:env=http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:enc= http://www.w3.org/2003/05/soap-encoding; env:Body ns1:make_proxy_payment env:encodingStyle= http://www.w3.org/2003/05/soap-encoding; payment_id61ecc268-1cd0-f468/payment_id payment_amount15495/payment_amount callback_query_stringamp;payment_id=61ecc268-1cd0-f468/callback_query_string transaction_noteOrder from Student Library Fees with Payment Id: 61ecc268-1cd0-f468/transaction_note /ns1:make_proxy_payment /env:Body /env:Envelope XML; $xml = new SimpleXMLElement($soap_request_string, NULL, false, ' http://www.w3.org/2003/05/soap-envelope'); print_r($xml); $ns = $xml-getNamespaces(true); //print_r($ns); foreach ($xml-children($ns['env']) as $body) { //printf(%sbr /, $body-getName()); foreach ($body-children($ns['ns1']) as $function) { printf(function %s()br /, $function-getName()); foreach ($function-children() as $parameters) { printf(%s = \%s\br /, $parameters-getName(), $parameters); } } } However when the XML string is coming from the database it does not work. The Field and table have a collation of utf8_unicode_ci $soap_request_string = trim(str_replace(array(\n), '', $record['SoapRequestEnvelope'])); $xml = new SimpleXMLElement($soap_request_string, NULL, false, ' http://www.w3.org/2003/05/soap-envelope'); print_r($xml); The above code is supposed to print out the following (for me to proceed further): SimpleXMLElement Object ( [Body] = SimpleXMLElement Object ( ) ) but only returns: SimpleXMLElement Object ( ) The XL string from the database looks exactly like this (after replacing new lines): ?xml version=1.0 encoding=UTF-8?env:Envelope xmlns:env= http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xmlns:enc= http://www.w3.org/2003/05/soap-encoding;env:Bodyns1:make_proxy_payment env:encodingStyle=http://www.w3.org/2003/05/soap-encoding;payment_id5ce30dcc-7df7-04e8/payment_idpayment_amount10/payment_amountcallback_query_stringamp;payment_id=5ce30dcc-7df7-04e8/callback_query_stringtransaction_noteOrder from Student Library Fees with Payment Id: 5ce30dcc-7df7-04e8/transaction_note/ns1:make_proxy_payment/env:Body/env:Envelope I can't figure out whats wrong with the code. Any suggestions? cheers, Jeffery -- Internet Vision Technologies Level 1, 520 Dorset Road Croydon Victoria - 3136 Australia
[PHP] SimpleXMLElement is not Simple
I am having nightmares with this bit off code. The following code work perfectly fine: $soap_request_string = XML ?xml version=1.0 encoding=UTF-8? env:Envelope xmlns:env=http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:enc=http://www.w3.org/2003/05/soap-encoding; env:Body ns1:make_proxy_payment env:encodingStyle=http://www.w3.org/2003/05/soap-encoding; payment_id61ecc268-1cd0-f468/payment_id payment_amount15495/payment_amount callback_query_stringamp;payment_id=61ecc268-1cd0-f468/callback_query_string transaction_noteOrder from Student Library Fees with Payment Id: 61ecc268-1cd0-f468/transaction_note /ns1:make_proxy_payment /env:Body /env:Envelope XML; $xml = new SimpleXMLElement($soap_request_string, NULL, false, 'http://www.w3.org/2003/05/soap-envelope'); print_r($xml); $ns = $xml-getNamespaces(true); //print_r($ns); foreach ($xml-children($ns['env']) as $body) { //printf(%sbr /, $body-getName()); foreach ($body-children($ns['ns1']) as $function) { printf(function %s()br /, $function-getName()); foreach ($function-children() as $parameters) { printf(%s = \%s\br /, $parameters-getName(), $parameters); } } } However when the XML string is coming from the database it does not work. The Field and table have a collation of utf8_unicode_ci $soap_request_string = trim(str_replace(array(\n), '', $record['SoapRequestEnvelope'])); $xml = new SimpleXMLElement($soap_request_string, NULL, false, 'http://www.w3.org/2003/05/soap-envelope'); print_r($xml); The above code is supposed to print out the following (for me to proceed further): SimpleXMLElement Object ( [Body] = SimpleXMLElement Object ( ) ) but only returns: SimpleXMLElement Object ( ) The XL string from the database looks exactly like this (after replacing new lines): ?xml version=1.0 encoding=UTF-8?env:Envelope xmlns:env=http://www.w3.org/2003/05/soap-envelope; xmlns:ns1=urn:Gateway_Proxy xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:enc=http://www.w3.org/2003/05/soap-encoding;env:Bodyns1:make_proxy_payment env:encodingStyle=http://www.w3.org/2003/05/soap-encoding;payment_id5ce30dcc-7df7-04e8/payment_idpayment_amount10/payment_amountcallback_query_stringamp;payment_id=5ce30dcc-7df7-04e8/callback_query_stringtransaction_noteOrder from Student Library Fees with Payment Id: 5ce30dcc-7df7-04e8/transaction_note/ns1:make_proxy_payment/env:Body/env:Envelope I can't figure out whats wrong with the code. Any suggestions? cheers, Jeffery -- Internet Vision Technologies Level 1, 520 Dorset Road Croydon Victoria - 3136 Australia pgpSwDIXaIYCH.pgp Description: PGP signature
Re: [PHP] counting with leading zeros
tedd wrote: 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 I wasn't bitching! And i *thought* that my numerous attempts at explaining such would have been enough. Obviously not, but wtf can you do with people who seem to want only to stir up shit? Jim Lucas wrote: 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... Perfect timing, then. 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. There's a daemon that locks the dir, zips up the contents, moves it elsewhere, then removes everything at once. ?php function getNextImage($path, $prefix) { $filelist = glob(${path}${prefix}*) or return '01'; return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT); } ? Sweet! Thanks much! brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php