php-general Digest 9 May 2009 00:15:26 -0000 Issue 6111
php-general Digest 9 May 2009 00:15:26 - Issue 6111 Topics (messages 292396 through 292411): CURL error help 292396 by: Miller, Terion 292398 by: Jônatas Zechim 292399 by: Miller, Terion 292400 by: Jônatas Zechim 292401 by: Shawn McKenzie 292402 by: Miller, Terion 292404 by: Jônatas Zechim 292405 by: Miller, Terion 292406 by: Jônatas Zechim 292411 by: Shawn McKenzie Re: bcmath integer type? 292397 by: Michael A. Peters Session data files 292403 by: phphelp -- kbk 292407 by: Tom Worster Re: php-gene...@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account 292408 by: sean greenslade 292409 by: Lenin 292410 by: sean greenslade 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--- Trying to run a script on several different pages within the same site by making the url's an array...anyone see a better way to do this? Trying to resolve some curl errors and need some help, here are the errors: Notice: Array to string conversion in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 34 Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 36 cURL error number:6 cURL error:Couldn't resolve host 'Array' And here is the code: ?php ini_set('display_errors', 1); include(inc/dbconn_open.php); include(inc/dom.php); error_reportin g(E_ALL); $TESTING = TRUE; $targets[a] = http://www.greenecountymo.org/sheriff/warrants.php?search=A;; $targets[b] = http://www.greenecountymo.org/sheriff/warrants.php?search=B;; $targets[c] = http://www.greenecountymo.org/sheriff/warrants.php?search=C;; $targets[d] = http://www.greenecountymo.org/sheriff/warrants.php?search=D;; $targets[e] = http://www.greenecountymo.org/sheriff/warrants.php?search=E;; $targets[f] = http://www.greenecountymo.org/sheriff/warrants.php?search=F;; $targets[g] = http://www.greenecountymo.org/sheriff/warrants.php?search=G;; $targets[h] = http://www.greenecountymo.org/sheriff/warrants.php?search=H;; $targets[i] = http://www.greenecountymo.org/sheriff/warrants.php?search=I;; $targets[j] = http://www.greenecountymo.org/sheriff/warrants.php?search=J;; $targets[k] = http://www.greenecountymo.org/sheriff/warrants.php?search=K;; $targets[l] = http://www.greenecountymo.org/sheriff/warrants.php?search=L;; foreach ($targets as $target_url){ $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$targets); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) { echo br /cURL error number: .curl_errno($ch); echo br /cURL error: . curl_error($ch); exit; } // Create DOM from URL or file $html = file_get_html('$target_url'); // Find table foreach($html-find('table') as $table) { foreach($table-find('tr') as $tr) { ---End Message--- ---BeginMessage--- Try to change this: curl_setopt($ch,CURLOPT_URL,$targets); to: curl_setopt($ch,CURLOPT_URL, $target_url); Zechim zechim.com São Paulo/Brazil -Mensagem original- De: Miller, Terion [mailto:tmil...@springfi.gannett.com] Enviada em: sexta-feira, 8 de maio de 2009 09:50 Para: PHP-General List Assunto: [PHP] CURL error help Trying to run a script on several different pages within the same site by making the url's an array...anyone see a better way to do this? Trying to resolve some curl errors and need some help, here are the errors: Notice: Array to string conversion in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 34 Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 36 cURL error number:6 cURL error:Couldn't resolve host 'Array' And here is the code: ?php ini_set('display_errors', 1); include(inc/dbconn_open.php); include(inc/dom.php); error_reportin g(E_ALL); $TESTING = TRUE; $targets[a] = http://www.greenecountymo.org/sheriff/warrants.php?search=A;; $targets[b] = http://www.greenecountymo.org/sheriff/warrants.php?search=B;; $targets[c] =
Re: [PHP] Re: bcmath integer type?
On Thu, 2009-05-07 at 21:45 -0700, Michael A. Peters wrote: Michael A. Peters wrote: I'm having a problem with db2 and prepared statements. var_dump indicates that some variables that should be type int are type text. These variables are the output of bcmath equations, and are integer. Does bcmath for some reason output a text type? I can fix it by adding 0 but I want to know if I'm using bcmath incorrectly. LOL - I would like to know if bcmath is suppose to return int (I'm guessing yes so it can deal with numbers outside of fp math) but I don't think that was the issue. $foo[] = Array($var1,$var2) was my problem ... notice the [] ;) From the documentation at: http://ca2.php.net/manual/en/function.bcadd.php We see that bcadd has the prototype: string bcadd ( string $left_operand , string $right_operand [, int $scale ] ) See the string, that's because it takes strings and returns strings. The reason why is in the description: Add two arbitrary precision numbers That arbitrary part rules out integers or even floats since they are fixed width datatypes (fixed width with respect to the number of bits available to represent them). It may not be the case with what your doing, but with large enough (positive or negative numbers), or numbers with sufficient decimal places) you WILL lose precision by converting to a real integer or floating point value. If you don't need arbitrary precision functionality, then don't use the bcxxx() functions since they are MUCH slower than doing normal math. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CURL error help
Trying to run a script on several different pages within the same site by making the url's an array...anyone see a better way to do this? Trying to resolve some curl errors and need some help, here are the errors: Notice: Array to string conversion in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 34 Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 36 cURL error number:6 cURL error:Couldn't resolve host 'Array' And here is the code: ?php ini_set('display_errors', 1); include(inc/dbconn_open.php); include(inc/dom.php); error_reportin g(E_ALL); $TESTING = TRUE; $targets[a] = http://www.greenecountymo.org/sheriff/warrants.php?search=A;; $targets[b] = http://www.greenecountymo.org/sheriff/warrants.php?search=B;; $targets[c] = http://www.greenecountymo.org/sheriff/warrants.php?search=C;; $targets[d] = http://www.greenecountymo.org/sheriff/warrants.php?search=D;; $targets[e] = http://www.greenecountymo.org/sheriff/warrants.php?search=E;; $targets[f] = http://www.greenecountymo.org/sheriff/warrants.php?search=F;; $targets[g] = http://www.greenecountymo.org/sheriff/warrants.php?search=G;; $targets[h] = http://www.greenecountymo.org/sheriff/warrants.php?search=H;; $targets[i] = http://www.greenecountymo.org/sheriff/warrants.php?search=I;; $targets[j] = http://www.greenecountymo.org/sheriff/warrants.php?search=J;; $targets[k] = http://www.greenecountymo.org/sheriff/warrants.php?search=K;; $targets[l] = http://www.greenecountymo.org/sheriff/warrants.php?search=L;; foreach ($targets as $target_url){ $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$targets); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) { echo br /cURL error number: .curl_errno($ch); echo br /cURL error: . curl_error($ch); exit; } // Create DOM from URL or file $html = file_get_html('$target_url'); // Find table foreach($html-find('table') as $table) { foreach($table-find('tr') as $tr) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: bcmath integer type?
Robert Cummings wrote: On Thu, 2009-05-07 at 21:45 -0700, Michael A. Peters wrote: Michael A. Peters wrote: I'm having a problem with db2 and prepared statements. var_dump indicates that some variables that should be type int are type text. These variables are the output of bcmath equations, and are integer. Does bcmath for some reason output a text type? I can fix it by adding 0 but I want to know if I'm using bcmath incorrectly. LOL - I would like to know if bcmath is suppose to return int (I'm guessing yes so it can deal with numbers outside of fp math) but I don't think that was the issue. $foo[] = Array($var1,$var2) was my problem ... notice the [] ;) From the documentation at: http://ca2.php.net/manual/en/function.bcadd.php We see that bcadd has the prototype: string bcadd ( string $left_operand , string $right_operand [, int $scale ] ) See the string, that's because it takes strings and returns strings. The reason why is in the description: Add two arbitrary precision numbers That arbitrary part rules out integers or even floats since they are fixed width datatypes (fixed width with respect to the number of bits available to represent them). It may not be the case with what your doing, but with large enough (positive or negative numbers), or numbers with sufficient decimal places) you WILL lose precision by converting to a real integer or floating point value. If you don't need arbitrary precision functionality, then don't use the bcxxx() functions since they are MUCH slower than doing normal math. I started using them because there were a few cases where normal operations caused imprecision in unit conversions. With bcmath I could specify extra precision and then round to the precision I needed as the last step. Maybe there's a better way to do it but it solved the problem. I probably don't need them in this case, I can just round down the result to get the integer result, but the use is so small that the performance hit probably isn't worth changing them and pushing it through testing again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] CURL error help
Try to change this: curl_setopt($ch,CURLOPT_URL,$targets); to: curl_setopt($ch,CURLOPT_URL, $target_url); Zechim zechim.com São Paulo/Brazil -Mensagem original- De: Miller, Terion [mailto:tmil...@springfi.gannett.com] Enviada em: sexta-feira, 8 de maio de 2009 09:50 Para: PHP-General List Assunto: [PHP] CURL error help Trying to run a script on several different pages within the same site by making the url's an array...anyone see a better way to do this? Trying to resolve some curl errors and need some help, here are the errors: Notice: Array to string conversion in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 34 Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p hp on line 36 cURL error number:6 cURL error:Couldn't resolve host 'Array' And here is the code: ?php ini_set('display_errors', 1); include(inc/dbconn_open.php); include(inc/dom.php); error_reportin g(E_ALL); $TESTING = TRUE; $targets[a] = http://www.greenecountymo.org/sheriff/warrants.php?search=A;; $targets[b] = http://www.greenecountymo.org/sheriff/warrants.php?search=B;; $targets[c] = http://www.greenecountymo.org/sheriff/warrants.php?search=C;; $targets[d] = http://www.greenecountymo.org/sheriff/warrants.php?search=D;; $targets[e] = http://www.greenecountymo.org/sheriff/warrants.php?search=E;; $targets[f] = http://www.greenecountymo.org/sheriff/warrants.php?search=F;; $targets[g] = http://www.greenecountymo.org/sheriff/warrants.php?search=G;; $targets[h] = http://www.greenecountymo.org/sheriff/warrants.php?search=H;; $targets[i] = http://www.greenecountymo.org/sheriff/warrants.php?search=I;; $targets[j] = http://www.greenecountymo.org/sheriff/warrants.php?search=J;; $targets[k] = http://www.greenecountymo.org/sheriff/warrants.php?search=K;; $targets[l] = http://www.greenecountymo.org/sheriff/warrants.php?search=L;; foreach ($targets as $target_url){ $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$targets); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) { echo br /cURL error number: .curl_errno($ch); echo br /cURL error: . curl_error($ch); exit; } // Create DOM from URL or file $html = file_get_html('$target_url'); // Find table foreach($html-find('table') as $table) { foreach($table-find('tr') as $tr) { -- 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: RES: [PHP] CURL error help
On 5/8/09 8:04 AM, Jônatas Zechim zechim@gmail.com wrote: Try to change this: curl_setopt($ch,CURLOPT_URL,$targets); to: curl_setopt($ch,CURLOPT_URL, $target_url); Zechim zechim.com São Paulo/Brazil Thanks for the suggestion: Tried it and get this error now: Warning: file_get_contents($target_url) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/inc/dom.php on line 39 On line #39 from my dom.php file is this : // get html dom form file function file_get_html() { $dom = new simple_html_dom; $args = func_get_args(); $dom-load(call_user_func_array('file_get_contents', $args), true); return $dom; } I think somehow the array is not being read or it's trying to pass the full array of url's as one url? Therefore saying it does not exist? My best guess, am I making the array wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: RES: [PHP] CURL error help
Try to echo the $target_url var. What's on it? Try to echo the $args var. What's on it? How do you pass the $args? Zechim zechim.com São Paulo/Brazil -Mensagem original- De: Miller, Terion [mailto:tmil...@springfi.gannett.com] Enviada em: sexta-feira, 8 de maio de 2009 10:27 Para: Jônatas Zechim; Miller, Terion; PHP-General List Assunto: Re: RES: [PHP] CURL error help On 5/8/09 8:04 AM, Jônatas Zechim zechim@gmail.com wrote: Try to change this: curl_setopt($ch,CURLOPT_URL,$targets); to: curl_setopt($ch,CURLOPT_URL, $target_url); Zechim zechim.com São Paulo/Brazil Thanks for the suggestion: Tried it and get this error now: Warning: file_get_contents($target_url) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/inc/dom.php on line 39 On line #39 from my dom.php file is this : // get html dom form file function file_get_html() { $dom = new simple_html_dom; $args = func_get_args(); $dom-load(call_user_func_array('file_get_contents', $args), true); return $dom; } I think somehow the array is not being read or it's trying to pass the full array of url's as one url? Therefore saying it does not exist? My best guess, am I making the array wrong?
Re: RES: [PHP] CURL error help
Miller, Terion wrote: On 5/8/09 8:04 AM, Jônatas Zechim zechim@gmail.com wrote: Try to change this: curl_setopt($ch,CURLOPT_URL,$targets); to: curl_setopt($ch,CURLOPT_URL, $target_url); Zechim zechim.com São Paulo/Brazil Thanks for the suggestion: Tried it and get this error now: Warning: file_get_contents($target_url) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/inc/dom.php on line 39 On line #39 from my dom.php file is this : // get html dom form file function file_get_html() { $dom = new simple_html_dom; $args = func_get_args(); $dom-load(call_user_func_array('file_get_contents', $args), true); return $dom; } I think somehow the array is not being read or it's trying to pass the full array of url's as one url? Therefore saying it does not exist? My best guess, am I making the array wrong? Look at your function call in your original post: $html = file_get_html('$target_url'); $target_url is single quoted why? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: RES: [PHP] CURL error help
On 5/8/09 8:49 AM, Jônatas Zechim zechim@gmail.com wrote: Try to echo the $target_url var. What's on it? Try to echo the $args var. What's on it? How do you pass the $args? I echo'd the $target_url and I got all the correct urls -did I mention this error reports one time for every url in the array, I am not sure if I should echo the $args on the dom.php page or on my page, I didn't write the dom.php script, it's a bit beyond my skill level. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session data files
Hey, folks --- Just something I'm curious about: When I run PHP on my development box (W2K), I just get one session file per connection which gets deleted (usually) after the session expires. When I look at the session files on the client server (linux/apache), there seems to be one session file per page click. I needed to clear them a few minutes ago, and there are already 80+ files, and this is just from one user (a tester -- this is in late-late-late beta). Now, there is nothing wrong -- everything is working fine -- I am just curious if Apache does this differently, or if there is a configuration setting that governs this (I haven't found -- but only did a cursory look). Anybody willing to take the time to enlighten me? Thank you, Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session data files
On 5/8/09 11:09 AM, phphelp -- kbk phph...@comcast.net wrote: Just something I'm curious about: When I run PHP on my development box (W2K), I just get one session file per connection which gets deleted (usually) after the session expires. When I look at the session files on the client server (linux/apache), there seems to be one session file per page click. I needed to clear them a few minutes ago, and there are already 80+ files, and this is just from one user (a tester -- this is in late-late-late beta). Now, there is nothing wrong -- everything is working fine -- I am just curious if Apache does this differently, or if there is a configuration setting that governs this (I haven't found -- but only did a cursory look). Anybody willing to take the time to enlighten me? have you satisfied yourself that what you're seeing is not just an artifact of how the session garbage collector works? http://us.php.net/manual/en/session.configuration.php maybe compare the gc parameters on the two different machines? phpinfo() displays the values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account
On Fri, May 8, 2009 at 12:18 AM, Tim-Hinnerk Heuer th.he...@gmail.com wrote: I've been using Gmail and thought you might like to try it out. Here's an invitation to create an account. if you send me mail on here it will probably be more secure than over the rest of the network. just let me know what the new address will be in case you change mail providers. --- Tim-Hinnerk Heuer has invited you to open a free Google Mail account. To accept this invitation and register for your account, visit http://mail.google.com/mail/a-f5f2afb0c7-9207f3d89b-bd8bac4aaf494e87 Once you create your account, Tim-Hinnerk Heuer will be notified with your new email address so you can stay in touch with Google Mail! If you haven't already heard about Google Mail, it's a new search-based webmail service that offers: - Over 2,700 megabytes (two gigabytes) of free storage - Built-in Google search that instantly finds any message you want - Automatic arrangement of messages and related replies into conversations - Powerful spam protection using innovative Google technology - No large, annoying ads--just small text ads and related pages that are relevant to the content of your messages To learn more about Google Mail before registering, visit: http://mail.google.com/mail/help/intl/en_GB/benefits.html We're still working every day to improve Google Mail, so we might ask for your comments and suggestions periodically. We hope you'll like Google Mail. We do. And, it's only going to get better. Thanks, The Google Mail Team (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Lol, I don't think the mailing list can sign up for gmail. -- --Zootboy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account
Yeah gmail is a nice thing :) The best ever mailing system world has ever seen until now.
Re: [PHP] php-general@lists.php.net, Tim-Hinnerk Heuer has invited you to open a Google mail account
On Fri, May 8, 2009 at 5:27 PM, Lenin le...@phpxperts.net wrote: Yeah gmail is a nice thing :) The best ever mailing system world has ever seen until now. Agreed. -- --Zootboy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problems with HTTPS and maybe an .htaccess???
On Tue, 05 May 2009 13:20:56 -0500, Skip Evans wrote: [...] But now I have a problem implementing this on their development site, which is just a duplicate code base inside a directory public_html/_dev and a domain name dev.sitename.com, instead of sitename.com. The problem is, and I believe it may be the .htaccess file, redirecting the https pages to the live [...] You should be telling the browser to redirect to the new page, rather than just pulling up a page to offer back instead of the requested URL. You want the browser to request a new page, using HTTPS (i.e. SSL or TLS). See here, which forces a redirect to HTTPS for any pages in the orders folder that have been requested via HTTP: RewriteCond %{SERVER_PORT} !443$ RewriteRule ^orders/?.*$https://%{SERVER_NAME}/orders [R=301,L] The bit at the end, R=301 makes Apache tell the browser to ask for another page at the new URL. The %{SERVER_NAME} bit tells Apache to insert the server name, whether it be your sitename.com or dev.sitename.com -- Ross McKay, Toronto, NSW Australia Let the laddie play wi the knife - he'll learn - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php