php-general Digest 9 Dec 2009 14:39:28 -0000 Issue 6478
php-general Digest 9 Dec 2009 14:39:28 - Issue 6478 Topics (messages 300326 through 300331): (Slide Show) Developing PHP Web Applications with the Raxan Framework 300326 by: Raymond Irving Re: Force-Saving an Audio File 300327 by: Gaurav Kumar file_get_contents ($file) works -- file_get_contents ($url) returns false 300328 by: René Fournier 300329 by: Richard Quadling 300330 by: kranthi Where you are wanted! 300331 by: promoaction.hush.ai Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hello Everyone, I've put together a quick slide show for those who are interested in learning about Raxan for PHP. It only takes a minute or two Here's the url: http://tinyurl.com/yhdqc9k Best regards __ Raymond Irving---End Message--- ---BeginMessage--- You can do two things- 1. Read the file by providing a base directory path of the server where the file exist. Something like- //htdocs/httpfolder/files/audio/yourfile.mp3 You can take this in a variable //htdocs/httpfolder/files/audio/. 2. Try using file_get_contents. Something like $file = file_get_contents(' http://www.example.com/audio/file.mp3', false, $context); Hope this helps. Gaurav Kumar Blog.OsWebStudio.com On Wed, Dec 9, 2009 at 8:06 AM, c...@hosting4days.com c...@hosting4days.com wrote: Hi folks, I'm trying to force save .mp3 files so this is a test page (found on the net). It works fine when: $directory = ; // so the audio is in the same local directory but fails when I use a REAL web directory - (the audio file is here - http://mysite.com/test1/audio.mp3 ) $directory = http://mysite.com/test1/;; says - The file $file was not found. Q: Any ideas how to get it to download from the website? = ?php $file = 'audio1.mp3'; $directory = http://mysite.com/test1/;; //$directory = ; $path = $directory$file; if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); $file_extension = strtolower(substr(strrchr($path,.),1)); if( $file == ) { echo html head titleFile not found./title /head body File not found. /body /html; exit; } elseif (! file_exists( $path ) ) { echo html head titleThe file $file was not found./title /head body The file $file was not found.br / - path - $path /body /html;exit; }; switch( $file_extension ) { case pdf: $ctype=application/pdf; break; case zip: $ctype=application/zip; break; case doc: $ctype=application/msword; break; case xls: $ctype=application/vnd.ms-excel; break; case ppt: $ctype=application/vnd.ms-powerpoint; break; case gif: $ctype=image/gif; break; case png: $ctype=image/png; break; case jpeg: case jpg: $ctype=image/jpg; break; case wav: case mp3: $ctype=application/iTunes; break; default: $ctype=application/force-download; } header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Cache-Control: private,false); header(Content-Type: $ctype); header(Content-Disposition: attachment; filename=\.basename($path).\; ); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($path)); readfile($path); exit(); ? Thanks, c...@hosting4days.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene---End Message--- ---BeginMessage--- 2009/12/9 René Fournier m...@renefournier.com: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene If you enable all errors, anything extra? ... ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); // Just in case it takes more than your default execution time. var_dump(file_get_contents('http://www.google.com')); -- - Richard Quadling Standing on the shoulders of some very clever giants! EE :
php-general Digest 10 Dec 2009 03:14:21 -0000 Issue 6479
php-general Digest 10 Dec 2009 03:14:21 - Issue 6479 Topics (messages 300332 through 300356): Re: file_get_contents ($file) works -- file_get_contents ($url) returns false 300332 by: LinuxManMikeC 300333 by: LinuxManMikeC 300334 by: René Fournier 300335 by: René Fournier 300337 by: Richard Quadling Browsing PHP documentation from Emacs 300336 by: Roberto 300340 by: Kim Emax 300341 by: Roberto 300342 by: Joseph Thayne Re: Force-Saving an Audio File 300338 by: cool.hosting4days.com 300339 by: Shawn McKenzie 300355 by: cool.hosting4days.com SimpleXML or DOMDocument help 300343 by: Michael Alaimo 300344 by: Shawn McKenzie 300346 by: Shawn McKenzie 300347 by: Shawn McKenzie 300348 by: Shawn McKenzie 300353 by: Michael A. Peters can't retrieve more than 1 record at the time 300345 by: Catherine Madsen 300350 by: Simcha Younger 300351 by: Paul M Foster generating an object from XMl using Zend_Config_Xml 300349 by: reda khyatti refuses to complete all queries 300352 by: Allen McCabe 300354 by: Bastien Koert PHP 5.3 Code Documentor 300356 by: Andrew Mason Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen ---End Message--- ---BeginMessage--- On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D ---End Message--- ---BeginMessage--- No. And it doesn't matter if the url is local (localhost, host.domain.com) or remote. On 2009-12-09, at 10:30 PM, kranthi wrote: may be unrelated to your problem... but are you behind a proxy? ---End Message--- ---BeginMessage--- It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence ---End Message--- ---BeginMessage--- 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously
Re: [PHP] Force-Saving an Audio File
You can do two things- 1. Read the file by providing a base directory path of the server where the file exist. Something like- //htdocs/httpfolder/files/audio/yourfile.mp3 You can take this in a variable //htdocs/httpfolder/files/audio/. 2. Try using file_get_contents. Something like $file = file_get_contents(' http://www.example.com/audio/file.mp3', false, $context); Hope this helps. Gaurav Kumar Blog.OsWebStudio.com On Wed, Dec 9, 2009 at 8:06 AM, c...@hosting4days.com c...@hosting4days.com wrote: Hi folks, I'm trying to force save .mp3 files so this is a test page (found on the net). It works fine when: $directory = ; // so the audio is in the same local directory but fails when I use a REAL web directory - (the audio file is here - http://mysite.com/test1/audio.mp3 ) $directory = http://mysite.com/test1/;; says - The file $file was not found. Q: Any ideas how to get it to download from the website? = ?php $file = 'audio1.mp3'; $directory = http://mysite.com/test1/;; //$directory = ; $path = $directory$file; if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); $file_extension = strtolower(substr(strrchr($path,.),1)); if( $file == ) { echo html head titleFile not found./title /head body File not found. /body /html; exit; } elseif (! file_exists( $path ) ) { echo html head titleThe file $file was not found./title /head body The file $file was not found.br / - path - $path /body /html;exit; }; switch( $file_extension ) { case pdf: $ctype=application/pdf; break; case zip: $ctype=application/zip; break; case doc: $ctype=application/msword; break; case xls: $ctype=application/vnd.ms-excel; break; case ppt: $ctype=application/vnd.ms-powerpoint; break; case gif: $ctype=image/gif; break; case png: $ctype=image/png; break; case jpeg: case jpg: $ctype=image/jpg; break; case wav: case mp3: $ctype=application/iTunes; break; default: $ctype=application/force-download; } header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Cache-Control: private,false); header(Content-Type: $ctype); header(Content-Disposition: attachment; filename=\.basename($path).\; ); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($path)); readfile($path); exit(); ? Thanks, c...@hosting4days.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
2009/12/9 René Fournier m...@renefournier.com: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene If you enable all errors, anything extra? ... ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); // Just in case it takes more than your default execution time. var_dump(file_get_contents('http://www.google.com')); -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
may be unrelated to your problem... but are you behind a proxy? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where you are wanted!
[url=http://iwantsex.110mb.com]Online speed dating iwantsex.110mb.com[/url] allows users to participate in 5 minute webcam based dates. Also offers speed dating reviews, personal ads and custom profiles. Welcome to http://iwantsex.110mb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
No. And it doesn't matter if the url is local (localhost, host.domain.com) or remote. On 2009-12-09, at 10:30 PM, kranthi wrote: may be unrelated to your problem... but are you behind a proxy?
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence
[PHP] Browsing PHP documentation from Emacs
Hi all, I've just written a small tool for Emacs that will allow to browse PHP documentation directly from within Emacs. I thought you might be interested in it: http://aloiroberto.wordpress.com/2009/12/09/php-and-emacs-how-to-browse-documentation/ It is released with GNU GPLv3 license and it might be integrated with existing php-mode implementations. Looking forward to hear feedback from you. Regards, Roberto Aloi Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence Do you have ANY errors/warning/notices? -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force-Saving an Audio File
On Dec 9, 2009, at 12:27 AM, Gaurav Kumar wrote: You can do two things- 1. Read the file by providing a base directory path of the server where the file exist. Something like- //htdocs/httpfolder/files/audio/yourfile.mp3 You can take this in a variable //htdocs/httpfolder/files/audio/. 2. Try using file_get_contents. Something like $file = file_get_contents(' http://www.example.com/audio/file.mp3', false, $context); Hope this helps. Thanks for your help Gaurav, After a few tests based on your suggestions - I noticed why I think there was a problem: this line: elseif (! file_exists( $path ) ) worked locally but failed when the path was a http url: $directory = http://mysite.com/test1/;; so when I took out that elseif then readfile($path); did work SO: Is there a php function that can work like file_exists( $path ) and tell if the file exists but work from a URL like: $thisfile = http://mysite.com/test1/audio.mp3;; Thanks, c...@hosting4days.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force-Saving an Audio File
c...@hosting4days.com wrote: On Dec 9, 2009, at 12:27 AM, Gaurav Kumar wrote: You can do two things- 1. Read the file by providing a base directory path of the server where the file exist. Something like- //htdocs/httpfolder/files/audio/yourfile.mp3 You can take this in a variable //htdocs/httpfolder/files/audio/. 2. Try using file_get_contents. Something like $file = file_get_contents(' http://www.example.com/audio/file.mp3', false, $context); Hope this helps. Thanks for your help Gaurav, After a few tests based on your suggestions - I noticed why I think there was a problem: this line: elseif (! file_exists( $path ) ) worked locally but failed when the path was a http url: $directory = http://mysite.com/test1/;; so when I took out that elseif then readfile($path); did work SO: Is there a php function that can work like file_exists( $path ) and tell if the file exists but work from a URL like: $thisfile = http://mysite.com/test1/audio.mp3;; Thanks, c...@hosting4days.com You could possibly check the results of get_headers($thisfile); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browsing PHP documentation from Emacs
Hello Roberto wrote on 2009-12-09 17:08: Hi all, I've just written a small tool for Emacs that will allow to browse PHP documentation directly from within Emacs. I thought you might be interested in it: http://aloiroberto.wordpress.com/2009/12/09/php-and-emacs-how-to-browse-documentation/ It is released with GNU GPLv3 license and it might be integrated with existing php-mode implementations. Looking forward to hear feedback from you. Interesting stuff, is this against the php.net documentation? And do you believe it would be possible to do the same from Vim? -- Take Care Kim Emax - master|minds - Vi tænker IT for dig... Konsulentbistand, programmering, design hosting af websites. http://www.masterminds.dk - http://www.emax.dk Køb din vin online på http://www.gmvin.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browsing PHP documentation from Emacs
Hi Kim, this should actually work with almost all PHP documentation pages in HTML format. I personally tested it with the English package from: http://www.php.net/download-docs.php (the one that come in many HTML files). Regards, Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browsing PHP documentation from Emacs
Check the following link for help on integrating with Vim: http://vim.wikia.com/wiki/PHP_manual_in_Vim_help_format Kim Emax wrote: Hello Roberto wrote on 2009-12-09 17:08: Hi all, I've just written a small tool for Emacs that will allow to browse PHP documentation directly from within Emacs. I thought you might be interested in it: http://aloiroberto.wordpress.com/2009/12/09/php-and-emacs-how-to-browse-documentation/ It is released with GNU GPLv3 license and it might be integrated with existing php-mode implementations. Looking forward to hear feedback from you. Interesting stuff, is this against the php.net documentation? And do you believe it would be possible to do the same from Vim? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SimpleXML or DOMDocument help
Hello All, I have an XML document that has elements as such: Query:Expression Query:ResourceID Query:EqualTest/Query:Equal /Query:ResourceID /Query:Expression I cannot figure out how to access these with simple xml. I am not opposed to a DOMDocument solution either. Would anyone know what to do in this case? I think the problem is the :. Regards, Mike * Michael Alaimo ADNET Systems, Inc. Web Developer Work: 301-286-5569 Cell: 571-332-9210 * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SimpleXML or DOMDocument help
Michael Alaimo wrote: Hello All, I have an XML document that has elements as such: Query:Expression Query:ResourceID Query:EqualTest/Query:Equal /Query:ResourceID /Query:Expression I cannot figure out how to access these with simple xml. I am not opposed to a DOMDocument solution either. Would anyone know what to do in this case? I think the problem is the :. Regards, Mike * Michael Alaimo ADNET Systems, Inc. Web Developer Work: 301-286-5569 Cell: 571-332-9210 * What's the entire XML document? You need a xmlns declaration as Query is a namespace. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can't retrieve more than 1 record at the time
Hi, I'm really in need of help. I'm not a PHP programmer, but I've been given the privilege of customizing a script written by somebody else and can't get it to work right. I have to query 2 different tables in 2 different Oracle 10G DBs, one's mine (my_schema.my_table), the other (otherdb.other_table) belongs to another department. In my_table, I have the doc_id and the app_id for a record. In other_table there's the doc_id and pdf to retrieve. The goal is to make a PDF file from each BLOB in other_table and store them in the right directory under hash(app_id). PDO has been installed and working, and I can connect to both DBs without a problem. If my query limits the retrieval to one record, the script works, but if I try to run it for all records, one pdf file is correctly created in the right directory then I get the following error: PHP Fatal error: Call to a member function fetch() on a non-object in /my_location/my_script.php on line 154. It the while ($stmt-fetch(PDO::FETCH_BOUND)) line. I've pasted my script below. I thought my problem was that maybe I was in the wrong directory after creation of the first pdf, but several tries changing the directory didn't make a difference. Right now, I'm running the script at the command line. Soon I'm going to have a few hundred records to deal with and cannot do it one by one! Any help would be very much appreciated. Thank you! ?php /* First Oracle DB connection info removed */ try { $dbh1 = new PDO(oci:dbname=.$tns1,$db1_username,$db1_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; } if (empty($_SESSION['docIDs'])) { $_SESSION['DOCIDs'] = array(); $_SESSION['msgs'] = array(); $sql = SELECT COUNT(*) all_rec FROM myschema.my_table where academic_year = 2010; $_SESSION['numberCand'] = 0; /* initialize ctr for stack popping */ $_SESSION['PHPulled'] = 0; /* number new personal histories pulled */ if ($res = $dbh1-query($sql)) { /* Check the number of rows that match the SELECT statement */ if ($res-fetchColumn() 0) { /* Issue the real SELECT statement and work with the results */ $sql = select doc_id, app_id from myschema.my_table where academic_year = 2010; foreach ($dbh1-query($sql) as $row) { $cand = array(); $cand['DOC_ID']= $row['DOC_ID']; $cand['APP_ID'] = $row['APP_ID']; $_SESSION['DOC_IDS'][] = $cand; } } } } if (!empty($_SESSION['DOC_IDS']) and $_SESSION['numberCand'] count($_SESSION['DOC_IDS'])) { /* if have doc_IDs, pick next one off array */ $cand = $_SESSION['DOC_IDS'][$_SESSION['numberCand']]; if ($cand['DOC_ID'] == 0) { /* redirect to self to get next candidate with updated numberCand */ $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1; exit; } $dirname = md5($cand['APP_ID']); $curdir = '/my_location/'.$dirname; print App_id/Dir: . $row['APP_ID'] . $curdir . \n; if (!(is_dir($curdir))) { if (!mkdir($curdir,0775)) print error: . $curdir . \n; exit; } /* Second Oracle DB connection info removed */ try { $dbh2 = new PDO(oci:dbname=.$tns2,$db2_username,$db2_password); } catch(PDOException $e) { echo ($e-getMessage()); exit; } $stmt = $dbh2-prepare('select PDF from otherdb.other_table where DOC_ID = :id'); $stmt-bindParam(':id', $cand['DOC_ID'], PDO::PARAM_INT); $stmt-bindColumn(1, $PDF, PDO::PARAM_LOB); $stmt-execute(); if (!(chdir($curdir))) { $_SESSION['msgs'][] = 'Could not change to '.$curdir; continue; } $cnt = 0; while ($stmt-fetch(PDO::FETCH_BOUND)) { $filename = 'phs-'.$cnt.'.pdf'; if (!file_exists($filename)) { /* if file not already there, write file with BLOB contents */ $fh = fopen($filename, 'w'); fwrite($fh, stream_get_contents($PDF)); fclose($fh); /* add to $_SESSION['PHPulled'] for each new file saved */ $_SESSION['PHPulled'] = $_SESSION['PHPulled'] + 1; } /* increment stack counter */ $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1; $stmt = NULL; /* release the connection */ /*if not done with stack, redirect to self to get next*/ if (!empty($_SESSION['DOCIDs']) and $_SESSION['numberCand'] count($_SESSION['DOCIDs'])) { exit; } } } /* once done, go back to display search page after clearing stack if(isset($_SESSION['DOCIDs'])) unset($_SESSION['DOCIDs'] );*/ $res = null; $dbh1 = null; ? -- Catherine Madsen Programmer Analyst College of Chemistry Berkeley, CA 94720-1460
[PHP] Re: SimpleXML or DOMDocument help
Please keep this on list. The URI for the namespace is important. Something like (not tested): | ||// use URI for Query namespace| | foreach ($xml-children('http://www.example.com/something') as $Query) { echo $Query-Where; } || | Michael Alaimo wrote: What's the entire XML document? You need a xmlns declaration as Query is a namespace. The document is valid XML. xml_parse_into_struct returns an array with all of the values. Its just so much work to get it to work. SimpleXML wont let me access $xml-Query-{Query:Where}. for example -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SimpleXML or DOMDocument help
Shawn McKenzie wrote: Please keep this on list. The URI for the namespace is important. Something like (not tested): | ||// use URI for Query namespace| | foreach ($xml-children('http://www.example.com/something') as $Query) { echo $Query-Where; } || | Michael Alaimo wrote: What's the entire XML document? You need a xmlns declaration as Query is a namespace. The document is valid XML. xml_parse_into_struct returns an array with all of the values. Its just so much work to get it to work. SimpleXML wont let me access $xml-Query-{Query:Where}. for example -- Thanks! -Shawn http://www.spidean.com Wow, that came out with some weird pipes in it: // use URI for Query namespace foreach ($xml-children('http://www.example.com/something') as $Query) { echo $Query-Where; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SimpleXML or DOMDocument help
Shawn McKenzie wrote: Shawn McKenzie wrote: Please keep this on list. The URI for the namespace is important. Something like (not tested): | ||// use URI for Query namespace| | foreach ($xml-children('http://www.example.com/something') as $Query) { echo $Query-Where; } || | Michael Alaimo wrote: What's the entire XML document? You need a xmlns declaration as Query is a namespace. The document is valid XML. xml_parse_into_struct returns an array with all of the values. Its just so much work to get it to work. SimpleXML wont let me access $xml-Query-{Query:Where}. for example -- Thanks! -Shawn http://www.spidean.com Wow, that came out with some weird pipes in it: // use URI for Query namespace foreach ($xml-children('http://www.example.com/something') as $Query) { echo $Query-Where; } I guess you could also use (not tested): $ns = $xml-getNamespaces(true); foreach ($xml-children($ns['Query']) as $Query) { echo $Query-Where; } Maybe look at the xpath() method, I don't know anything about it. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] generating an object from XMl using Zend_Config_Xml
Dear all I have the following XMl document, that I parse and generate from it an object using Zend_Config_Xml: ?xml version=1.0 encoding=UTF-8? configdata category nameCategoria/name groups group nameGrupo 1 /name /group group nameGrupo 2 /name /group /groups /categoria /configdata $category = *new* Zend_Config_Xml(*'category.xml'*,*'category'*) ; print_r($category-toArray());** the result is: Array ( [name] = Categoria [grupos] = Array ( [grupo] = Array ( [0] = Array ( [name] = Grupo 1 ) [1] = Array ( [name] = Grupo 2 ) ) ) ) Till here, everything is fine, I do get what I want. But in the case I have only one group in groups, the result is different. ?xml version=1.0 encoding=UTF-8? configdata category nameCategoria/name groups group nameGrupo/name /group /grupos /category /configdata Array ( [name] = Categoria [grupos] = Array ( [grupo] = Array ( [name] = Grupo ) ) ) Indeed, I woul like to generate something like this: Array ( [name] = Categoria [grupos] = Array ( [grupo] = Array ( [0] = Array ( [name] = Grupo 1 ) ) ) ) Does anyone see how can we do that. Regards -- khyatti Reda Tel: +21255880898
Re: [PHP] can't retrieve more than 1 record at the time
On Wed, 09 Dec 2009 11:39:55 -0800 Catherine Madsen cmad...@berkeley.edu wrote: It looks like you have to take out this line: $stmt = NULL; /* release the connection */ You are destroying the variable instead of just deleting the data, so the while statement terminates after the first record. -- Simcha Younger sim...@syounger.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't retrieve more than 1 record at the time
On Wed, Dec 09, 2009 at 11:39:55AM -0800, Catherine Madsen wrote: Hi, I'm really in need of help. I'm not a PHP programmer, but I've been given the privilege of customizing a script written by somebody else and can't get it to work right. I have to query 2 different tables in 2 different Oracle 10G DBs, one's mine (my_schema.my_table), the other (otherdb.other_table) belongs to another department. In my_table, I have the doc_id and the app_id for a record. In other_table there's the doc_id and pdf to retrieve. The goal is to make a PDF file from each BLOB in other_table and store them in the right directory under hash(app_id). PDO has been installed and working, and I can connect to both DBs without a problem. If my query limits the retrieval to one record, the script works, but if I try to run it for all records, one pdf file is correctly created in the right directory then I get the following error: PHP Fatal error: Call to a member function fetch() on a non-object in /my_location/my_script.php on line 154. It the while ($stmt-fetch(PDO::FETCH_BOUND)) line. I've pasted my script below. I thought my problem was that maybe I was in the wrong directory after creation of the first pdf, but several tries changing the directory didn't make a difference. Right now, I'm running the script at the command line. Soon I'm going to have a few hundred records to deal with and cannot do it one by one! Any help would be very much appreciated. Thank you! snip if (!(chdir($curdir))) { $_SESSION['msgs'][] = 'Could not change to '.$curdir; continue; } $cnt = 0; while ($stmt-fetch(PDO::FETCH_BOUND)) { $filename = 'phs-'.$cnt.'.pdf'; if (!file_exists($filename)) { /* if file not already there, write file with BLOB contents */ $fh = fopen($filename, 'w'); fwrite($fh, stream_get_contents($PDF)); fclose($fh); /* add to $_SESSION['PHPulled'] for each new file saved */ $_SESSION['PHPulled'] = $_SESSION['PHPulled'] + 1; } Judging by your indentation you probably want a closing brace here. As it is, your while statement won't end until the final closing brace, which includes the $stmt = NULL; statement. Nulling this variable in the middle of the while loop will cause it to execute once only and cause the error message you're seeing. /* increment stack counter */ $_SESSION['numberCand'] = $_SESSION['numberCand'] + 1; $stmt = NULL; /* release the connection */ /*if not done with stack, redirect to self to get next*/ if (!empty($_SESSION['DOCIDs']) and $_SESSION['numberCand'] count($_SESSION['DOCIDs'])) { exit; } } } /* once done, go back to display search page after clearing stack if(isset($_SESSION['DOCIDs'])) unset($_SESSION['DOCIDs'] );*/ $res = null; $dbh1 = null; Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] refuses to complete all queries
I have a PURGE ORDERS link that calculates which orders are made up entirely of expired shows and deletes them. Well, that's idea anyhow. The procedure does 3 things: 1. Gets the order_id of all orders that contain all expired shows 2. Deallocates the quantity of the seats on each show from the show table (freeing up 'inventory') 3. Deletes the order from the order table and all associated entries on the line_item table. Well, it does the first step beautifully, but does not want to delete the table entries. The problem seems to be somewhere in: // CREATE STRING FROM $black_list[] array $expired_order_ids_str = implode($black_list, ', '); // UPDATE SHOW QUANTITIES - SUBTRACT SEATS $getshowsSQL = SELECT * FROM afy_order_lineitem WHERE order_id IN ({$expired_order_ids_str}); $showsResult = mysql_query($getshowsSQL); while ($updateShow = mysql_fetch_array($showsResult)) { $updatequantitySQL = UPDATE afy_show SET show_seats_reqd = (show_seats_reqd - {$updateShow['quantity']}) WHERE show_id = {$updateShow['show_id']}; $updatequantityResult = mysql_query($updatequantitySQL); } mysql_free_result($showsResult); // UPDATE MYSQL $deleteSQL = DELETE FROM afy_order WHERE order_id IN ({$expired_order_ids_str}); mysql_query($deleteSQL); $deleteSQL = DELETE FROM afy_order_lineitem WHERE order_id IN ({$expired_order_ids_str}); $deleteResult = mysql_query($deleteSQL); if ($deleteResult) { $message = font color=\#009900\Orders successfully Purged!br /(Order #'s deleted: {$expired_order_ids_str})/font; } break; The works just fine, up until the // UPDATE MYSQL line. I am NOT getting the $message set, and the orders are NOT being deleted. Only the afy_show gets updated. Can anyone see an problem with this?? Thanks!
Re: [PHP] Re: SimpleXML or DOMDocument help
Shawn McKenzie wrote: Michael Alaimo wrote: Hello All, I have an XML document that has elements as such: Query:Expression Query:ResourceID Query:EqualTest/Query:Equal /Query:ResourceID /Query:Expression I cannot figure out how to access these with simple xml. I am not opposed to a DOMDocument solution either. Would anyone know what to do in this case? I think the problem is the :. Regards, Mike What's the entire XML document? You need a xmlns declaration as Query is a namespace. I have run into documents that use a namespace without properly defining it. Seems fairly common in data sets from academic sources (IE vertebrate museum records). Usually there is only one namespace, and you can use a regular expression to just remove it before importing the document. IE - $buffer = preg_replace('/Query:/','',$input); then import the $buffer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] refuses to complete all queries
On Wed, Dec 9, 2009 at 7:18 PM, Allen McCabe allenmcc...@gmail.com wrote: I have a PURGE ORDERS link that calculates which orders are made up entirely of expired shows and deletes them. Well, that's idea anyhow. The procedure does 3 things: 1. Gets the order_id of all orders that contain all expired shows 2. Deallocates the quantity of the seats on each show from the show table (freeing up 'inventory') 3. Deletes the order from the order table and all associated entries on the line_item table. Well, it does the first step beautifully, but does not want to delete the table entries. The problem seems to be somewhere in: // CREATE STRING FROM $black_list[] array $expired_order_ids_str = implode($black_list, ', '); // UPDATE SHOW QUANTITIES - SUBTRACT SEATS $getshowsSQL = SELECT * FROM afy_order_lineitem WHERE order_id IN ({$expired_order_ids_str}); $showsResult = mysql_query($getshowsSQL); while ($updateShow = mysql_fetch_array($showsResult)) { $updatequantitySQL = UPDATE afy_show SET show_seats_reqd = (show_seats_reqd - {$updateShow['quantity']}) WHERE show_id = {$updateShow['show_id']}; $updatequantityResult = mysql_query($updatequantitySQL); } mysql_free_result($showsResult); // UPDATE MYSQL $deleteSQL = DELETE FROM afy_order WHERE order_id IN ({$expired_order_ids_str}); mysql_query($deleteSQL); $deleteSQL = DELETE FROM afy_order_lineitem WHERE order_id IN ({$expired_order_ids_str}); $deleteResult = mysql_query($deleteSQL); if ($deleteResult) { $message = font color=\#009900\Orders successfully Purged!br /(Order #'s deleted: {$expired_order_ids_str})/font; } break; The works just fine, up until the // UPDATE MYSQL line. I am NOT getting the $message set, and the orders are NOT being deleted. Only the afy_show gets updated. Can anyone see an problem with this?? Thanks! If you echo out the statement and run it thru phpmyadmin or some other db tool, does the statement work? -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force-Saving an Audio File
Thanks Gaurav Shawn, I'll check into your suggestions. Thanks, c...@hosting4days.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.3 Code Documentor
Hi all, Is anyone aware of a code documentation generator like phpdoc or doxygen that supports the PHP 5.3 namespaces ? I tried adding support to doxygen myself but didn't have a whole lot of luck and didn't have huge amounts of time to spend on learning flex/yacc. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php