[PHP] convert a string to integer
Hi, i know this topic is obvious but i have a strange behavior and i'm getting crazy. my stored procedure returns me a string. string can be an email or a message error = '-1', '-2', '-3' when i check if the string contains only digit, i use ctype_digit(mystring) but any way it returns me false... i suppose that for -1, -2, -3 the - is taken as character and not a digit. i tried also to cast it before into integer thanks ctype_digit((int)mystring), but it does not work. so how can i solve this issue ? thx -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008
Re: [PHP] convert a string to integer
On Fri, Mar 28, 2008 at 12:48 AM, Alain Roger [EMAIL PROTECTED] wrote: Hi, i know this topic is obvious but i have a strange behavior and i'm getting crazy. my stored procedure returns me a string. string can be an email or a message error = '-1', '-2', '-3' when i check if the string contains only digit, i use ctype_digit(mystring) but any way it returns me false... i suppose that for -1, -2, -3 the - is taken as character and not a digit. i tried also to cast it before into integer thanks ctype_digit((int)mystring), but it does not work. so how can i solve this issue ? thx -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 is_numeric() -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert a string to integer
On 28/03/2008, at 8:48, Alain Roger wrote: Hi, i know this topic is obvious but i have a strange behavior and i'm getting crazy. my stored procedure returns me a string. string can be an email or a message error = '-1', '-2', '-3' when i check if the string contains only digit, i use ctype_digit(mystring) but any way it returns me false... i suppose that for -1, -2, -3 the - is taken as character and not a digit. i tried also to cast it before into integer thanks ctype_digit((int)mystring), but it does not work. so how can i solve this issue ? thx -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 is_numeric() - Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. --- Simon Welsh Admin of http://simon.geek.nz/ Windows is a joke operating system. Hell, it's not even an operating system. NT is Not Tough enough for me either. 95 is how may times it will crash an hour. http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert a string to integer
thx a lot... i completly skipped this one...i don't know why :-( now it works On Fri, Mar 28, 2008 at 8:55 AM, Simon Welsh [EMAIL PROTECTED] wrote: On 28/03/2008, at 8:48, Alain Roger wrote: Hi, i know this topic is obvious but i have a strange behavior and i'm getting crazy. my stored procedure returns me a string. string can be an email or a message error = '-1', '-2', '-3' when i check if the string contains only digit, i use ctype_digit(mystring) but any way it returns me false... i suppose that for -1, -2, -3 the - is taken as character and not a digit. i tried also to cast it before into integer thanks ctype_digit((int)mystring), but it does not work. so how can i solve this issue ? thx -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 is_numeric() - Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. --- Simon Welsh Admin of http://simon.geek.nz/ Windows is a joke operating system. Hell, it's not even an operating system. NT is Not Tough enough for me either. 95 is how may times it will crash an hour. http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008
Re: [PHP] Re: optimilize web page loading
2008. 03. 27, csütörtök keltezéssel 11.13-kor Jason Pruim ezt írta: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) if you have variables in the mix, concatenation is better than interpolation greets, Zoltán Németh -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt írta: Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) nope. it parses both, since you may have escaped characters within single quotes too. so the difference only comes in when you actually have a variable in the string. greets, Zoltán Németh -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] I would assume your 2 examples to be the same because the point is that the PHP interpreter must parse for vars to substitute when it encounters double-quotes whether there are any vars in it or not. With single-quotes the interpreter does not have to worry about it. Regardless, the speed diff is probably negligible, hence my flame inviting post. :-) -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
2008. 03. 27, csütörtök keltezéssel 09.29-kor Philip Thompson ezt írta: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... that above statement is simply not true. parsing foo and 'foo' is all the same a good read about it: http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html greets, Zoltán Németh ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
2008. 03. 28, péntek keltezéssel 09.19-kor Zoltán Németh ezt írta: 2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt írta: Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] I would assume your 2 examples to be the same because the point is that the PHP interpreter must parse for vars to substitute when it encounters double-quotes whether there are any vars in it or not. With single-quotes the interpreter does not have to worry about it. Regardless, the speed diff is probably negligible, hence my flame inviting post. :-) ehh my answer is meant to be here: nope. it parses both, since you may have escaped characters within single quotes too. so the difference only comes in when you actually have a variable in the string. sorry its morning ;) greets, Zoltán Németh -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
Eric Butera wrote: On Thu, Mar 27, 2008 at 12:41 PM, Peter Ford [EMAIL PROTECTED] wrote: Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) There was a discussion about this a few weeks ago - ISTR that the compiler does wierd things with double-quoted strings, something like tokenising the words and checking each bit for lurking variables. So in fact echo $foo bar bar bar bar $foo $foo; is slowest (because there *are* variables to interpolate, echo $foo . bar bar bar bar .$foo. .$foo; is a bit faster, but the double-quoted bits cause some slow-down, echo $foo . ' bar bar bar bar '.$foo.' '.$foo; is a bit faster again - the single quoted bits pass through without further inspection, and finally echo $foo,' bar bar bar bar ',$foo,' ',$foo; is actually the fastest, because the strings are not concatenated before output. I think that was the overall summary - I can't locate the original post to verify (or attribute) but it's in this list somewhere... Cheers -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can you prove these statements with real benchmarks that are current? Ilia said that it is a myth that there is a performance difference between and ' in one of his talks. I found one recent post on the subject in gmane: http://article.gmane.org/gmane.comp.php.general/169028 The poster's results are as I remembered, except that was building a string, not echoing: possibly not quite the same. So I tried it myself, adapting to using echo (to the ob to avaoid printing forty million * foo bar bar ...). For an extra wheeze, I also tried ?=$foo? syntax embedded in HTML to see if that is as bad as people make out. I didn't try HEREDOC syntax, because it is difficult to reproduce exactly the same output - newlines get added to the output. To get thing to run I needed to increase time out, and reduce the string to avoid filling the PHP memory limit I have set at the moment. Here is the code: ?php ini_set('max_execution_time',300); $foo = 'f'; ob_start(); $time[1] = microtime(TRUE); for($x = 0; $x 1000; $x++){ echo $foo b b b b $foo $foo; } $time[2] = microtime(TRUE); ob_end_clean(); ob_start(); $time[3] = microtime(TRUE); for($x = 0; $x 1000; $x++){ echo $foo . ' b b b b '.$foo.' '.$foo; } $time[4] = microtime(TRUE); ob_end_clean(); ob_start(); $time[5] = microtime(TRUE); for($x = 0; $x 1000; $x++){ echo $foo . b b b b .$foo. .$foo; } $time[6] = microtime(TRUE); ob_end_clean(); ob_start(); $time[7] =
[PHP] putting variables in a variable
Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to log APC Cache errors?
Hi. I'm using APC 3.0.17 with PHP 5.2.5 on Linux. I'm suffering some white page of death APC errors, and I'm trying to investigate the reasons. But: 1) I don't find any APC support forum. 2) I don't find any APC error log. I'm browsing Apache error log (with PHP 'E_ALL' activate) and don't see any line about it. Any suggestion is welcome. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: putting variables in a variable
Hulf wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross Since you've used double quotes, It Should Just Work(TM) ... $body .= table tr tdimg src=\$myimage1\/td /tr /table ; I'd probably use single-quotes (') around the src attribute to avoid those ugly backslashes ... $body .= table tr tdimg src='$myimage1'/td /tr /table ; Might be better in this case to use heredoc syntax ... $body .EndOfChunk table tr tdimg src=$myimage1/td /tr /table EndOfChunk; -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
On Fri, 2008-03-28 at 09:14 +0100, Zoltán Németh wrote: 2008. 03. 27, csütörtök keltezéssel 09.29-kor Philip Thompson ezt írta: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... that above statement is simply not true. parsing foo and 'foo' is all the same a good read about it: http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html Nope, parsing is not the same, the resultant bytecode is the same, but parsing is not. 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
Re: [PHP] Re: optimilize web page loading
On Fri, 2008-03-28 at 09:31 +0100, Zoltán Németh wrote: 2008. 03. 28, péntek keltezéssel 09.19-kor Zoltán Németh ezt írta: 2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt írta: Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) I would assume your 2 examples to be the same because the point is that the PHP interpreter must parse for vars to substitute when it encounters double-quotes whether there are any vars in it or not. With single-quotes the interpreter does not have to worry about it. Regardless, the speed diff is probably negligible, hence my flame inviting post. :-) ehh my answer is meant to be here: It's still wrong :) nope. it parses both, since you may have escaped characters within single quotes too. so the difference only comes in when you actually have a variable in the string. sorry its morning ;) Aaah, that's why you're confused :P ;) 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] Use of callback on a stream
Hello, I am trying to make a daemon that launches shell commands via proc_open and gets the stdout of the command via a pipe. The thing is that I would like to get this stdout via a callback, instead of monitoring the pipe regularly. I tried the following code (this is a simplified version of it, but the callback never gets called, does anyone know what I forgot ? Thanks, Olivier ?php // First we proc_open a ls //1 - we build the descriptor array $descriptorspec = array( 0 = array(pipe, r), // // stdin 1 = array(pipe, w), // stdout 2 = array(pipe, w) // stderr ); $pipes=array(); // We make a simple callback function function stream_callback(){ global $pipes; $stdout_child=stream_get_contents($pipes[1]); print(Callback received:\n); print($stdout_child.\n); } $context=stream_context_create(array()); stream_context_set_params($context,array('notification' = 'stream_callback')); $handle=proc_open(/bin/ls /tmp,$descriptorspec,$pipes,null,null,array('context' = $context)); stream_context_set_params($pipes[1],array('notification' = 'stream_callback')); while (true){ print(Waiting...\n); sleep(5); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Use of callback on a stream
Hello, I am trying to make a daemon that launches shell commands via proc_open and gets the stdout of the command via a pipe. The thing is that I would like to get this stdout via a callback, instead of monitoring the pipe regularly. I tried the following code (this is a simplified version of it), but the callback never gets called, does anyone know what I forgot ? Thanks, Olivier ?php // Php5 used // we build the descriptor array $descriptorspec = array( 0 = array(pipe, r), // stdin 1 = array(pipe, w), // stdout 2 = array(pipe, w) // stderr ); $pipes=array(); // We make a simple callback function with an ugly global var function stream_callback(){ global $pipes; $stdout_child=stream_get_contents($pipes[1]); print(Callback received:\n); print($stdout_child.\n); } $context=stream_context_create(array()); stream_context_set_params($context,array('notification' = 'stream_callback')); $handle=proc_open(/bin/ls /tmp,$descriptorspec,$pipes,null,null,array('context' = $context)); stream_context_set_params($pipes[1],array('notification' = 'stream_callback')); while (true){ print(Waiting...\n); sleep(5); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
2008. 03. 28, péntek keltezéssel 09.00-kor Robert Cummings ezt írta: On Fri, 2008-03-28 at 09:31 +0100, Zoltán Németh wrote: 2008. 03. 28, péntek keltezéssel 09.19-kor Zoltán Németh ezt írta: 2008. 03. 27, csütörtök keltezéssel 10.21-kor Shawn McKenzie ezt írta: Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= foo; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar bar . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) I would assume your 2 examples to be the same because the point is that the PHP interpreter must parse for vars to substitute when it encounters double-quotes whether there are any vars in it or not. With single-quotes the interpreter does not have to worry about it. Regardless, the speed diff is probably negligible, hence my flame inviting post. :-) ehh my answer is meant to be here: It's still wrong :) nope. it parses both, since you may have escaped characters within single quotes too. so the difference only comes in when you actually have a variable in the string. sorry its morning ;) Aaah, that's why you're confused :P yeah maybe. you're right, the bytecode is the same. but somewhere I heard that the parsing is the same too - because escaped characters can be in any string, though I'm not that sure about this anymore, as my link proved something else ;) greets Zoltán Németh ;) Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_filter function
Hello, If I have an array like this $dataArray = array(0=array('type'='da'), 1=array('type'='wb'), 2=array('type'='da'); How I can filtering to get only 'da' only, like this $newDataArray = array(0=array('type'='da'),2=array('type'='da')) Thanks in advance bnug
Re: [PHP] array_filter function
If I have an array like this $dataArray = array(0=array('type'='da'), 1=array('type'='wb'), 2=array('type'='da'); How I can filtering to get only 'da' only, like this $newDataArray = array(0=array('type'='da'),2=array('type'='da')) Off the top of my head: ?php foreach ($newDataArray as $k = $v) { if (!empty($v['type']) AND $v['type'] != 'da') { unset($newDataArray[$k]); } } ? Optionally, you could use array_values() to re-index $newDataArray if you need to. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] munge / obfuscate ?
On Thu, Mar 27, 2008 at 9:27 PM, Robert Cummings [EMAIL PROTECTED] wrote: ?php $sekret = 'the brown cow stomped on the wittle bug'; $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0; $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : ''; if( $key == sha1( $id.':'.$sekret ) ) { header( 'Content-Type: image/jpg' ); readfile( /images/not/in/web/path/$id.jpg ) exit(); } // // Failure... tell them to bugger off :) // header( 'Content-Type: image/jpg' ); readfile( '/images/wherever/you/please/buggerOff.jpg' ); exit(); ? I'd add on to this a bit like so: ?php // Rob's code up to here. $path = /images/not/in/web/path/; if($key == sha1($id.':'.$sekret)) { if(file_exists($path.$id) is_file($path.$id) is_readable($path.$h)) { header('Content-Type: image/jpg'); readfile($path.$id); exit(0); } else { header('Content-Type: image/jpg'); readfile($path.'image-does-not-exist.jpg'); exit(1); } } else { header('Content-Type: image/jpg'); readfile($path.'incorrect-id.jpg'); exit(1); } ? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
On Fri, 2008-03-28 at 14:46 +0100, Zoltán Németh wrote: yeah maybe. you're right, the bytecode is the same. but somewhere I heard that the parsing is the same too - because escaped characters can be in any string, though I'm not that sure about this anymore, as my link proved something else ;) Single quoted strings do support some escape characters. As far as I know only you can only escape a single quote and a backslash when creating a string via single quotes. 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
Re: [PHP] Re: optimilize web page loading
2008. 03. 28, péntek keltezéssel 10.24-kor Robert Cummings ezt írta: On Fri, 2008-03-28 at 14:46 +0100, Zoltán Németh wrote: yeah maybe. you're right, the bytecode is the same. but somewhere I heard that the parsing is the same too - because escaped characters can be in any string, though I'm not that sure about this anymore, as my link proved something else ;) Single quoted strings do support some escape characters. As far as I know only you can only escape a single quote and a backslash when creating a string via single quotes. yes, but I think the parser would still need to tokenize the string and verify each token whether it contains an escape character or not - which should be the same process as tokenizing and checking for escape character and $ signs. greets, Zoltán Németh Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] putting variables in a variable
On Mon, Mar 28, 2011 at 7:06 AM, Hulf [EMAIL PROTECTED] wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Consider HEREDOC syntax. I'm not sure why you're doing your tables like that, but I'm sure you have your reasons. Also, I'm certain that hardcoding the image names like that is just for example, since it would be much easier to use an array or something similar (if it's not coming from a database or otherwise dynamically-generated). ?php $myimage1 = image1.png; $myimage2 = image2.png; $myimage3 = image3.png; $body .=EOT table tr tdimg src=$myimage1/td /tr tr tdnbsp;/td /tr tr tdimg src=$myimage2/td /tr tr tdnbsp;/td /tr tr tdimg src=$myimage3/td /tr tr tdnbsp;/td /tr /table EOT; // This has to be at position one on the line, no matter what. ? And, for good measure, the array way: ?php $images = array('image1.png','image2.png','image3.png'); echo table\n; foreach($images as $p = $v) { $body .=EOT tr tdimg src=$v/td /tr tr tdnbsp;/td /tr EOT; // Notice the blank line. That ensures a linebreak after the last /tr } echo /table\n; ? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Quick email address check
On 28/03/2008, Bastien Koert [EMAIL PROTECTED] wrote: On Thu, Mar 27, 2008 at 10:23 PM, Bill Guion [EMAIL PROTECTED] wrote: At 1:28 PM -0400 3/26/08, Al wrote: I'm scripting a simple registry where the user can input their name and email address. I'd like to do a quick validity check on the email address they just inputted. I can check the syntax, etc. but want check if the address exists. I realize that servers can take a long time to bounce etc. I'll just deal with this separately. Is there a better way than simply sending a test email to see if it bounces? Thanks I've had pretty good success from the following: after checking the syntax (exactly one @, at least one . to the right of the @, etc.), if it passes the syntax check, I then set $rhs to everything to the right of the @. Then I test: if (!checkdnsrr($rhs, 'MX')) { invalid } else { valid } -= Bill =- -- You can't tell which way the train went by looking at the track. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I have used this to good effect function isEmail($email) { if (eregi(^[a-z0-9]+([-_\.]?[a-z0-9])[EMAIL PROTECTED]([-_\.]?[a-z0-9])+\.[a-z]{2,4},$email)) { return TRUE; } else { return FALSE; } }//end function I often have a '+' in my email address (which is perfectly valid) and it really annoys me when a site refuses to accept it. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] putting variables in a variable
Hulf [EMAIL PROTECTED] wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross First, you need to change the date on your mail server, since it is reporting the year to be 2011, which in most cases and most servers I run automagically sets you as a spammer and reports the email and domain to the authorities and blacklists you. Secondly, if you want to use a variable, you need to make sure you are doing the $image1.jpg inside the body, because according to the snippet of code you have done, the $ is missing. HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
On Fri, 2008-03-28 at 15:30 +0100, Zoltán Németh wrote: 2008. 03. 28, péntek keltezéssel 10.24-kor Robert Cummings ezt írta: On Fri, 2008-03-28 at 14:46 +0100, Zoltán Németh wrote: yeah maybe. you're right, the bytecode is the same. but somewhere I heard that the parsing is the same too - because escaped characters can be in any string, though I'm not that sure about this anymore, as my link proved something else ;) Single quoted strings do support some escape characters. As far as I know only you can only escape a single quote and a backslash when creating a string via single quotes. yes, but I think the parser would still need to tokenize the string and verify each token whether it contains an escape character or not - which should be the same process as tokenizing and checking for escape character and $ signs. Nope, when processing a single quoted string there should be 4 available parse branches: EOF '(end of string) \ EOF \ ' anything else anything else Whereas with a double quoted string you have something along the lines of: EOF (end of string) $(begin variable) {(possible begin interpolation) $(begin interpolation) \ EOF \ ' t n r x v f digit anything else anything else So presuming no variable is embeded and assuming no escaped characters... double quotes still need to check for the beginning of variable interpolation which has 2 different start possibilities. With respect to creating the byte code single quotes have 4 branches, double quotes have 6 branches in the simplest of cases with no escape and no interpolation. So one would expect compile time for double quotes to be approximately 33% slower than for single quotes. Once compiled though, the point is moot especially since most sites use a bytecode cache like eAccelerator or APC. Even without a cache htough, the time difference is tncy, and this is just for informational purposes :) There are usually bigger eggs to fry when optimizing. One last thing though... even if this were escaped and even if there were fifty variables embedded, a good bytecode optimizer (not quite the same as a bytecode cacher) would optimize the bytecode for caching so that the string is broken up according to what needs to be interpolated and what does not. 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
RE: [PHP] munge / obfuscate ?
On Fri, 2008-03-28 at 10:37 -0400, Bastien Koert wrote: [snip] Save yourself the database trip and just stick the id AND the hash in the URL and validate upon request. Cheers, Rob. [/snip] The only reason I suggest a database look up is that in my application there is further security checks to see if the user is allowed to view the image. Both solutions are totally valid. Certainly, but without your added qualifier about checking permissions then querying the database would just be wasted cycles. Although, one would presume that if the link was presented with the key then the user is allowed to view it ;) If you're worried about other users viewing it too then just encode the user ID into the hash key. You can still validate on retrieval at the other end without hitting the database. You can even time limit access to the image via the url by adding a timestamp parameter and encoding that into the key also. 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
Re: [PHP] array_filter function
On 28/03/2008, Bagus Nugroho [EMAIL PROTECTED] wrote: Hello, If I have an array like this $dataArray = array(0=array('type'='da'), 1=array('type'='wb'), 2=array('type'='da'); How I can filtering to get only 'da' only, like this $newDataArray = array(0=array('type'='da'),2=array('type'='da')) $newDataArray = array_filter($dataArray, create_function('$a','return $a[type] == da;')); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: character encoding
Hi Manuel In the body that column shows Brébeuf in Windows Outlook. You may want to try this MIME message composing and sending class that http://www.phpclasses.org/mimemessage Looks great Manuel.but my server is under dyndns and the DN isn't qualified so no mail functions available. I was asking how to have the right character set translation so the data stored in the table show no grimmerish in the outlook window. A simple mailto link in the page with some basic content defined does the trick but the data retrieved from the table can look awsome in the mail client before the user sends it back to the owner email address. I'm making a site for myself. I'm a paintbrush artist, among other things, and I've set a buying level for the visitors. But one can ask to raise his level so he can buy more things in one session. For that I use a mailto link sent to my hotmail with the request giving the name and address of the sender. And that's where I can't control anything. The guy may have written accented caracters in his record and when that info is brought back, it messes the Outlook msg window of the sender. Can I force Outlook msg composer to use my Mysql table collation ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Deleting file in /tmp directory
Hi, I have this PHP script (simplificated here), called delete_tmp.php that basically calls external commands: ?php $session_file = '/tmp/sess_89765' system(''rm -f' . ' ' . $session_file); ? delete_tmp.php file is owned by gamito.users /tmp/sess_89765 file has permissions -rw-- and is owned by gamito.users My /tmp permissions are rwxrwxrwt and is owned by root.root I know that the the sticky bit only allows files to be deleted by their owners, the owner of the directory or by root. Never the less, i can switch to /tmp directory and delete sess_89765 file as user gamito. If I run: $ php delete_tmp.php as root, it deletes sess_89765 file. But if I do the same has user gamito, it doesn't delete the file !!! Ideas ? Any help would be appreciated. Warm Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
At 9:14 AM +0100 3/28/08, Zoltán Németh wrote: This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= I like to $foo). A minimal speedup, but nonetheless... that above statement is simply not true. parsing foo and 'foo' is all the same a good read about it: http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html greets, Zoltán Németh I read it, but it still doesn't disprove the premise. 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] Re: optimilize web page loading
At 10:59 AM -0400 3/28/08, Robert Cummings wrote: Nope, when processing a single quoted string there should be 4 available parse branches: EOF '(end of string) \ EOF \ ' anything else anything else Whereas with a double quoted string you have something along the lines of: EOF (end of string) $(begin variable) {(possible begin interpolation) $(begin interpolation) \ EOF \ ' t n r x v f digit anything else anything else So presuming no variable is embeded and assuming no escaped characters... double quotes still need to check for the beginning of variable interpolation which has 2 different start possibilities. With respect to creating the byte code single quotes have 4 branches, double quotes have 6 branches in the simplest of cases with no escape and no interpolation. So one would expect compile time for double quotes to be approximately 33% slower than for single quotes. Once compiled though, the point is moot especially since most sites use a bytecode cache like eAccelerator or APC. Even without a cache htough, the time difference is tncy, and this is just for informational purposes :) There are usually bigger eggs to fry when optimizing. One last thing though... even if this were escaped and even if there were fifty variables embedded, a good bytecode optimizer (not quite the same as a bytecode cacher) would optimize the bytecode for caching so that the string is broken up according to what needs to be interpolated and what does not. As always, thanks for your most excellent explanation. I figured that something along those lines was happening. I didn't consider the escape concerns. 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] Re: optimilize web page loading
My method was. Store into global thingy. Then echo very end of the page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: putting variables in a variable
Hulf wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross My first idea is to ask you what you WANT exactly and what's wrong with what you have. Currently you're showing 1 string, and 3 variables. Nothing else... what do you expect to happen that is not hapenning? Or what do you expect not to happen that IS hapenning ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] munge / obfuscate ?
At 9:27 PM -0400 3/27/08, Robert Cummings wrote: $sekret = 'the brown cow stomped on the wittle bug'; :-) 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: Deleting file in /tmp directory
Mário Gamito wrote: Hi, I have this PHP script (simplificated here), called delete_tmp.php that basically calls external commands: ?php $session_file = '/tmp/sess_89765' system(''rm -f' . ' ' . $session_file); ? delete_tmp.php file is owned by gamito.users /tmp/sess_89765 file has permissions -rw-- and is owned by gamito.users My /tmp permissions are rwxrwxrwt and is owned by root.root I know that the the sticky bit only allows files to be deleted by their owners, the owner of the directory or by root. Never the less, i can switch to /tmp directory and delete sess_89765 file as user gamito. If I run: $ php delete_tmp.php as root, it deletes sess_89765 file. But if I do the same has user gamito, it doesn't delete the file !!! Ideas ? Any help would be appreciated. It is a bit odd as it should delete it fine. Does using the PHP internal function unlink() work better than shelling out? system() will possibly have more overheads and it may require that the user has a valid SHELL etc. too... Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting file in /tmp directory
On Fri, Mar 28, 2008 at 11:24 AM, Mário Gamito [EMAIL PROTECTED] wrote: Hi, I have this PHP script (simplificated here), called delete_tmp.php that basically calls external commands: ?php $session_file = '/tmp/sess_89765' system(''rm -f' . ' ' . $session_file); ? That's extremely short for a session name. Should it be /tmp/sess_89765* ? Or is that just an example? Since the ending semicolon is missing, I'll presume it's just an example. ;-P Also, here are two different ways of doing that: ?php // Method 1 $session_file = '/tmp/sess_89765'; exec('rm '.$session_file.' 21',$ret,$err); echo isset($err) $err != 0 ? print_r($ret) : null; ? ?php // Method 2 $session_file = '/tmp/sess_89765'; if(file_exists($session_file) is_file($session_file) is_writeable($session_file)) { unlink($session_file); } else { echo No file named .$session_file.\n; } ? delete_tmp.php file is owned by gamito.users /tmp/sess_89765 file has permissions -rw-- and is owned by gamito.users My /tmp permissions are rwxrwxrwt and is owned by root.root I know that the the sticky bit only allows files to be deleted by their owners, the owner of the directory or by root. Never the less, i can switch to /tmp directory and delete sess_89765 file as user gamito. If I run: $ php delete_tmp.php as root, it deletes sess_89765 file. But if I do the same has user gamito, it doesn't delete the file !!! Ideas ? Any help would be appreciated. Warm Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: putting variables in a variable
At 4:47 PM +0100 3/28/08, M. Sokolewicz wrote: Hulf wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .= table tr tdimg src=\image1.jpg\/td /tr tr td/td /tr /table ; ideally I would like to have $myimage1 = image1.jpg; $myimage2 = image2.jpg; $myimage3 = image3.jpg; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross My first idea is to ask you what you WANT exactly and what's wrong with what you have. Currently you're showing 1 string, and 3 variables. Nothing else... what do you expect to happen that is not hapenning? Or what do you expect not to happen that IS hapenning ? I think it's fuzzy thinking. He probably wants: $body .= table tr tdimg src=\$image.jpg\/td /tr tr td/td /tr /table ; Where $image.jpg is image1.jpg or image2.jpg or image3.jpg 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] array_filter function
Thanks You, rgds, bnug From: Robin Vickery [mailto:[EMAIL PROTECTED] Sent: Jumat 28-Mar-2008 21:45 To: Bagus Nugroho Cc: php-general@lists.php.net Subject: Re: [PHP] array_filter function On 28/03/2008, Bagus Nugroho [EMAIL PROTECTED] wrote: Hello, If I have an array like this $dataArray = array(0=array('type'='da'), 1=array('type'='wb'), 2=array('type'='da'); How I can filtering to get only 'da' only, like this $newDataArray = array(0=array('type'='da'),2=array('type'='da')) $newDataArray = array_filter($dataArray, create_function('$a','return $a[type] == da;'));
[PHP] why won't my array work?
Hi everyone :) Happy friday to all of you! Here's my issues, I am attempting to echo the results of mysqli query out to my script just so I can make sure it's working right, what I'm hoping to do in the long run is compare what was typed in a text box to this info... It's for verifying a old password before changing to a new password... So here is my query: $oldpasswordquery = SELECT loginPassword, Record FROM current WHERE loginPassword='{$oldPassHash}' AND Record='{$Record}'; $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; print_r($chpwrow); The echo and the print_r are for debugging and obviously wont' be in the final script... Here is the error that I am getting: [Fri Mar 28 12:14:39 2008] [error] PHP Notice: Undefined index: loginPassword in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/admin/ chpwpost.php on line 18 Line 18 is where the echo is... the print_r though shows this: Array ( [0] = Array ( [loginPassword] = 42205baa2581d3fcd8d8f9c6b9746a1f [Record] = 2 ) ) So why can't I access it via $chpwrow['loginPassword']? I'm stumped Anyone that can help me has a free beer waiting for them the next time they are in my town! :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] why won't my array work?
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim [EMAIL PROTECTED] wrote: $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; Why would you pump that into an array instead of just calling it result itself? I'd say you're just making it harder on yourself for no apparent reason. The problem seems to be on your other line. $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; Just fetch the row into a single variable and not an array. In your example you'd need to access chpwrow[0]['loginPassword'] assuming it was an empty array up to that point. Calling things old query and old password isn't really adding any value to your code. If you're only going to use it once then throw it away call it result so it is easier to read and understand. But then again feel free to ignore this. Also is there a reason why you aren't using prepared statements? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] why won't my array work?
That's because your loginpassWord is in another array. try $chpwrow[0]['loginPassword'] -Mensagem original- De: Jason Pruim [mailto:[EMAIL PROTECTED] Enviada em: sexta-feira, 28 de março de 2008 13:29 Para: [php] PHP General List Assunto: [PHP] why won't my array work? Hi everyone :) Happy friday to all of you! Here's my issues, I am attempting to echo the results of mysqli query out to my script just so I can make sure it's working right, what I'm hoping to do in the long run is compare what was typed in a text box to this info... It's for verifying a old password before changing to a new password... So here is my query: $oldpasswordquery = SELECT loginPassword, Record FROM current WHERE loginPassword='{$oldPassHash}' AND Record='{$Record}'; $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; print_r($chpwrow); The echo and the print_r are for debugging and obviously wont' be in the final script... Here is the error that I am getting: [Fri Mar 28 12:14:39 2008] [error] PHP Notice: Undefined index: loginPassword in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/admin/ chpwpost.php on line 18 Line 18 is where the echo is... the print_r though shows this: Array ( [0] = Array ( [loginPassword] = 42205baa2581d3fcd8d8f9c6b9746a1f [Record] = 2 ) ) So why can't I access it via $chpwrow['loginPassword']? I'm stumped Anyone that can help me has a free beer waiting for them the next time they are in my town! :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why won't my array work?
On Mar 28, 2008, at 12:40 PM, Eric Butera wrote: On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim [EMAIL PROTECTED] wrote: $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; Why would you pump that into an array instead of just calling it result itself? I'd say you're just making it harder on yourself for no apparent reason. The problem seems to be on your other line. $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; Just fetch the row into a single variable and not an array. In your example you'd need to access chpwrow[0]['loginPassword'] assuming it was an empty array up to that point. Calling things old query and old password isn't really adding any value to your code. If you're only going to use it once then throw it away call it result so it is easier to read and understand. But then again feel free to ignore this. In the scope of my application since I'm checking the currently stored password before updating to a new password $oldpasswordquery makes sense, at least to me :) Also is there a reason why you aren't using prepared statements? a prepared statement seemed like alot of overkill for a simple check to see if the old pass matches what was stored in the database... And I didn't realize that you could use prepared statements for SELECTing rather then UPDATEing... But I'll look into that more, since I know that prepared statements make it much harder to do Sql injection attacks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP code to write excel spreadsheet with multiple workbooks
Hi all, I have a linux based web app which prints an html screen of results. My users really want Excel spreadsheets with the same results. There is a PEAR application which does this, but from the PEAR description it seems to be pretty buggy (65 open bugs, average days open 616 days) and dated. My spreadsheets will be somewhat simple. They will have multiple workbooks and could be as large as 1 rows spread out over 100 workbooks (Bigger than the code can handle, according to one of the open bug reports). No colors, no formulas, no hyperlinks. I've checked the archives and found an example which shows me how to write the results of an SQL (MySQL, I am using postresql, but the example will still work) into a very simple Excel spreadsheet with just one table of results. Is there a way to get a php program to generate a spreadsheet with multiple workbooks? Thanks Mary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why won't my array work?
On Fri, Mar 28, 2008 at 12:58 PM, Jason Pruim [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 12:40 PM, Eric Butera wrote: On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim [EMAIL PROTECTED] wrote: $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; Why would you pump that into an array instead of just calling it result itself? I'd say you're just making it harder on yourself for no apparent reason. The problem seems to be on your other line. $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; Just fetch the row into a single variable and not an array. In your example you'd need to access chpwrow[0]['loginPassword'] assuming it was an empty array up to that point. Calling things old query and old password isn't really adding any value to your code. If you're only going to use it once then throw it away call it result so it is easier to read and understand. But then again feel free to ignore this. In the scope of my application since I'm checking the currently stored password before updating to a new password $oldpasswordquery makes sense, at least to me :) Also is there a reason why you aren't using prepared statements? a prepared statement seemed like alot of overkill for a simple check to see if the old pass matches what was stored in the database... And I didn't realize that you could use prepared statements for SELECTing rather then UPDATEing... But I'll look into that more, since I know that prepared statements make it much harder to do Sql injection attacks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] It isn't just about sql injection, it's also about not letting your application break because of user input. Getting errors because someone puts an apostrophe in the form is bad. If I were using your site and I saw my search term break a page I'd leave because there are thousands of other sites that can get it right. http://us2.php.net/manual/en/function.mysqli-prepare.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP code to write excel spreadsheet with multiple workbooks
On Fri, Mar 28, 2008 at 1:12 PM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I have a linux based web app which prints an html screen of results. My users really want Excel spreadsheets with the same results. There is a PEAR application which does this, but from the PEAR description it seems to be pretty buggy (65 open bugs, average days open 616 days) and dated. My spreadsheets will be somewhat simple. They will have multiple workbooks and could be as large as 1 rows spread out over 100 workbooks (Bigger than the code can handle, according to one of the open bug reports). No colors, no formulas, no hyperlinks. I've checked the archives and found an example which shows me how to write the results of an SQL (MySQL, I am using postresql, but the example will still work) into a very simple Excel spreadsheet with just one table of results. Is there a way to get a php program to generate a spreadsheet with multiple workbooks? There is an XML format that Microsoft has documented that will do multi-workbook spreadsheets in Excel. (You can get an idea by saving an existing spreadsheet as XML and looking at the source.) I haven't used any libraries like PEAR to build them, but it isn't too difficult to write with the basic PHP XML libraries like XMLWriter or DOM. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why won't my array work?
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim [EMAIL PROTECTED] wrote: [snip!] $oldpasswordquery = SELECT loginPassword, Record FROM current WHERE loginPassword='{$oldPassHash}' AND Record='{$Record}'; $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or die(Sorry read failed: . mysqli_error($chpwpostlink)); $chpwresult = $chpwold[0]; $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; print_r($chpwrow); The echo and the print_r are for debugging and obviously wont' be in the final script... Here is the error that I am getting: [Fri Mar 28 12:14:39 2008] [error] PHP Notice: Undefined index: loginPassword in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/admin/ chpwpost.php on line 18 [snip!] Let's explain this a bit $chpwrow[] = mysqli_fetch_assoc($chpwresult) // The response from mysqli_fetch_assoc() will be an array already. You're then adding this into the $chpwrow[] array, which creates a nested array. So to call it from your example, you'd need $chpwrow[0]['loginPassword']. -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Enabling cURL on my Mac
Hi all, Ok, I'm still a newbie (hopefully, someday I'll be past this stage), so don't get too upset and also, if you can provide some assistance, I guess you'll have to give a step by step description from a beginner's point of view. The question: How can I check to be sure cURL is enabled? I'm on a MacBookPro running OS X 10.4.11. My PHP version is 5.1.4. Apache is version 1.3.33 Let me know if you need more information. Kista -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Enabling cURL on my Mac
Kista Tucker wrote: Hi all, Ok, I'm still a newbie (hopefully, someday I'll be past this stage), so don't get too upset and also, if you can provide some assistance, I guess you'll have to give a step by step description from a beginner's point of view. The question: How can I check to be sure cURL is enabled? I'm on a MacBookPro running OS X 10.4.11. My PHP version is 5.1.4. Apache is version 1.3.33 Let me know if you need more information. Kista call curl_init() from any php script and see if it works. If it reports and unknown function, then you don't have cUrl. If it works, then you have curl. From the manual: Description resource curl_init ([ string $url ] ) Initializes a new session and return a cURL handle for use with the curl_setopt(), curl_exec(), and curl_close() functions. -- 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
[PHP] convert associative array to ordinary array
Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] thanks Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert associative array to ordinary array
On Fri, Mar 28, 2008 at 2:27 PM, It Maq [EMAIL PROTECTED] wrote: Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] Did you try? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert associative array to ordinary array
Daniel Brown wrote: On Fri, Mar 28, 2008 at 2:27 PM, It Maq [EMAIL PROTECTED] wrote: Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] Did you try? array_values() will throw out the keys and replace them with numeric indices. Anyway, in PHP there is no difference between an associative array or an ordinary array, they're both the same thing. Only one has integers as keys while the other has strings... - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert associative array to ordinary array
On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 2:27 PM, It Maq [EMAIL PROTECTED] wrote: Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] Did you try? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 $numbered_array = array_values($associative_array); -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert associative array to ordinary array
thank you, it works! --- Casey [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 2:27 PM, It Maq [EMAIL PROTECTED] wrote: Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] Did you try? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 $numbered_array = array_values($associative_array); -- -Casey Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP code to write excel spreadsheet with multiple workbooks
Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I have a linux based web app which prints an html screen of results. My users really want Excel spreadsheets with the same results. There is a PEAR application which does this, but from the PEAR description it seems to be pretty buggy (65 open bugs, average days open 616 days) and dated. My spreadsheets will be somewhat simple. They will have multiple workbooks and could be as large as 1 rows spread out over 100 workbooks (Bigger than the code can handle, according to one of the open bug reports). No colors, no formulas, no hyperlinks. I've checked the archives and found an example which shows me how to write the results of an SQL (MySQL, I am using postresql, but the example will still work) into a very simple Excel spreadsheet with just one table of results. Is there a way to get a php program to generate a spreadsheet with multiple workbooks? Thanks Mary You can write them via XML, but there are also come classes out there that people have written for doing excel stuff as well. http://www.phpclasses.org used to be a good place to go and see what classes there are. HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Posting Summary for Week Ending 28 March, 2008: php-general@lists.php.net
Posting Summary for PHP-General List Week Ending: Friday, 28 March, 2008 Messages| Bytes | Sender ++-- 311 (100%) 850774 (100%) EVERYONE 18 (5.8%) 24095 (2.8%) Daniel Brown parasane at gmail dot com 18 (5.8%) 24878 (2.9%) Mark Weaver mdw1982 at mdw1982 dot com 16 (5.1%) 14590 (1.7%) tedd tedd dot sperling at gmail dot com 14 (4.5%) 20197 (2.4%) Nilesh Govindrajan admin at itech7 dot com 10 (3.2%) 22378 (2.6%) Zoltán Németh znemeth at alterationx dot hu 9 (2.9%) 10777 (1.3%) Casey heavyccasey at gmail dot com 9 (2.9%) 19224 (2.3%) Robert Cummings robert at interjinn dot com 9 (2.9%) 16853 (2%)Shawn McKenzie nospam at mckenzies dot net 9 (2.9%) 7941(0.9%) Wolf lonewolf at nc dot rr dot com 8 (2.6%) 15638 (1.8%) Eric Butera eric dot butera at gmail dot com 8 (2.6%) 10532 (1.2%) Andrew Ballard aballard at gmail dot com 7 (2.3%) 13758 (1.6%) Jason Pruim japruim at raoset dot com 7 (2.3%) 12869 (1.5%) Lamp Lists lamp dot lists at yahoo dot com 7 (2.3%) 10655 (1.3%) Al news at ridersite dot org 7 (2.3%) 11444 (1.3%) Jim Lucas lists at cmsws dot com 7 (2.3%) 11986 (1.4%) Richard Lynch ceo at l-i-e dot com 4 (1.3%) 13584 (1.6%) Peter Ford pete at justcroft dot com 4 (1.3%) 6940(0.8%) Philip Thompson philthathril at gmail dot com 4 (1.3%) 5937(0.7%) Robin Vickery robinv at gmail dot com 4 (1.3%) 5202(0.6%) Sudhakar sudhakararaog at gmail dot com 4 (1.3%) 3466(0.4%) Greg Bowser topnotcher at gmail dot com 3 (1%)3596(0.4%) Alain Roger raf dot news at gmail dot com 3 (1%)4162(0.5%) Bastien Koert phpster at gmail dot com 3 (1%)4872(0.6%) VamVan vamseevan at gmail dot com 3 (1%)3178(0.4%) Colin Guthrie gmane at colin dot guthr dot ie 3 (1%)9221(1.1%) Richard php_list at ghz dot fr 3 (1%)4352(0.5%) Michelle Konzack linux4michelle at freenet dot de 3 (1%)3090(0.4%) Bill billlab51 at hotmail dot com 3 (1%)3208(0.4%) Richard Heyes richardh at phpguru dot org 2 (0.6%) 95298 (11.2%) Andy Chongfpqkfd at pchome dot com 2 (0.6%) 1890(0.2%) Chris dmagick at gmail dot com 2 (0.6%) 2032(0.2%) Bill Guion bguion at comcast dot net 2 (0.6%) 2417(0.3%) Liz Kim lizkim270 at gmail dot com 2 (0.6%) 95298 (11.2%) Andy Chongkwtuvb at yahoo dot com dot sg 2 (0.6%) 2299(0.3%) Christoph Boget christoph dot boget at gmail dot com 2 (0.6%) 10009 (1.2%) N dot Boatswain wow_226 at hotmail dot com 2 (0.6%) 95298 (11.2%) Andy Chongwjrkcn at yahoo dot com dot cn 2 (0.6%) 1889(0.2%) Eric Wood eric at interplas dot com 2 (0.6%) 2183(0.3%) Paul Scott pscott at uwc dot ac dot za 2 (0.6%) 2549(0.3%) Dan frozendice at gmail dot com 2 (0.6%) 1504(0.2%) It Maq itmaqurfe at yahoo dot com 2 (0.6%) 2288(0.3%) Manuel Lemos mlemos at acm dot org 2 (0.6%) 1704(0.2%) Jeremy Privett jeremy at omegavortex dot net 2 (0.6%) 1591(0.2%) Mário Gamito gamito at gmail dot com 2 (0.6%) 1987(0.2%) Aschwin Wesselius aschwin at illuminated dot nl 2 (0.6%) 2682(0.3%) Olivier Dupuis dupuis dot olivier at lemonde dot fr 2 (0.6%) 2557(0.3%) Simon Welsh simon at welsh dot co dot nz 2 (0.6%) 1606(0.2%) M dot Sokolewicz tularis at php dot net 2 (0.6%) 95298 (11.2%) Andy Chongxbjpwt at ms45 dot url dot com dot tw 2 (0.6%) 3904(0.5%) Brandon Orther brandon dot orther at think-done dot com 2 (0.6%) 2619(0.3%) Ron Piggott ron dot php at actsministries dot org 2 (0.6%) 1371(0.2%) Bagus Nugroho bnugroho at unisemgroup dot com 2 (0.6%) 4248(0.5%) Thiago Pojda thiago dot pojda at softpartech dot com dot br 2
[PHP] does function extract() trim?
do not laugh, but I discovered today function extract(); :D before I used: foreach ($array as $key = $value) { ${$key} = trim($value); } though, trimming $value is kind of important to me and I would like to know if extract trims too? thanks. -ll Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does function extract() trim?
On 28 Mar 2008, at 20:59, Lamp Lists wrote: do not laugh, but I discovered today function extract(); :D before I used: foreach ($array as $key = $value) { ${$key} = trim($value); } though, trimming $value is kind of important to me and I would like to know if extract trims too? No, but you can use http://php.net/array_map to do the trim before using extract. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does function extract() trim?
- Original Message From: Stut [EMAIL PROTECTED] To: Lamp Lists [EMAIL PROTECTED] Cc: php General list php-general@lists.php.net Sent: Friday, March 28, 2008 4:02:27 PM Subject: Re: [PHP] does function extract() trim? On 28 Mar 2008, at 20:59, Lamp Lists wrote: do not laugh, but I discovered today function extract(); :D before I used: foreach ($array as $key = $value) { ${$key} = trim($value); } though, trimming $value is kind of important to me and I would like to know if extract trims too? No, but you can use http://php.net/array_map to do the trim before using extract. -Stut -- http://stut.net/ function trim_array($array_element) { $array_element = trim($array_element); return $array_element; } $myArray = array_map(trim_array, $myArray); extract($myArray); hm?!? my way is shorter! :D -ll Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Re: [PHP] does function extract() trim?
On 28 Mar 2008, at 21:14, Lamp Lists wrote: - Original Message From: Stut [EMAIL PROTECTED] To: Lamp Lists [EMAIL PROTECTED] Cc: php General list php-general@lists.php.net Sent: Friday, March 28, 2008 4:02:27 PM Subject: Re: [PHP] does function extract() trim? On 28 Mar 2008, at 20:59, Lamp Lists wrote: do not laugh, but I discovered today function extract(); :D before I used: foreach ($array as $key = $value) { ${$key} = trim($value); } though, trimming $value is kind of important to me and I would like to know if extract trims too? No, but you can use http://php.net/array_map to do the trim before using extract. -Stut -- http://stut.net/ function trim_array($array_element) { $array_element = trim($array_element); return $array_element; } $myArray = array_map(trim_array, $myArray); extract($myArray); hm?!? my way is shorter! :D Only if you over-complicate it. extract(array_map('trim', $myArray)); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does function extract() trim?
- Original Message From: Stut [EMAIL PROTECTED] To: Lamp Lists [EMAIL PROTECTED] Cc: php General list php-general@lists.php.net Sent: Friday, March 28, 2008 4:22:25 PM Subject: Re: [PHP] does function extract() trim? On 28 Mar 2008, at 21:14, Lamp Lists wrote: - Original Message From: Stut [EMAIL PROTECTED] To: Lamp Lists [EMAIL PROTECTED] Cc: php General list php-general@lists.php.net Sent: Friday, March 28, 2008 4:02:27 PM Subject: Re: [PHP] does function extract() trim? On 28 Mar 2008, at 20:59, Lamp Lists wrote: do not laugh, but I discovered today function extract(); :D before I used: foreach ($array as $key = $value) { ${$key} = trim($value); } though, trimming $value is kind of important to me and I would like to know if extract trims too? No, but you can use http://php.net/array_map to do the trim before using extract. -Stut -- http://stut.net/ function trim_array($array_element) { $array_element = trim($array_element); return $array_element; } $myArray = array_map(trim_array, $myArray); extract($myArray); hm?!? my way is shorter! :D Only if you over-complicate it. extract(array_map('trim', $myArray)); -Stut TOUCHE! :D I like your way. Thanks Stut! -ll You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com
Re: [PHP] loosing session in new window (IE only) [SOLVED]
this is happening when Security on IE (internet options) is on levels High or Block all cookies.. most likely there is a solution to fix this but I think (in my case) is not worth and it's much easier to tell client (their administrator) to trust the world a little bit more :D thanks for all posts. -ll - Original Message From: Stefan Langwald [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, March 26, 2008 9:20:33 AM Subject: Re: [PHP] loosing session in new window (IE only) href=person.php?id=123SESSIONID=... maybe.. ev0l but works.. 2008/3/26, Lamp Lists [EMAIL PROTECTED]: --- Richard Lynch [EMAIL PROTECTED] wrote: On Tue, March 25, 2008 4:07 pm, Lamp Lists wrote: - Original Message From: Andrew Ballard [EMAIL PROTECTED] To: PHP General list php-general@lists.php.net Sent: Tuesday, March 25, 2008 3:41:35 PM Subject: Re: [PHP] loosing session in new window (IE only) On Tue, Mar 25, 2008 at 3:49 PM, Lamp Lists [EMAIL PROTECTED] wrote: hi, i have a list of people on one page. each row, on the end has link a href=person.php?id=123 target=_blankview details/a. it's requested to open detail page in new window. very few people complained they can't open detail page. all of them use IE. I wasn't able to reproduce the error, though using GoToMeeting I was able to look while customer was doing it. I put session info on screen to see what's going on and found that new window doesn't have session info from old window?!? like, new window - new session. does anybody knows anything about this? thanks. -ll If they open a new window by clicking on IE (say, on the desktop, the QuickLaunch bar, or the Start menu), Windows actually opens a new, totally separate process of IE along side the first. The new one will share any persistent cookies with the first, since they are written to the file system, but sessions do not usually use persistent cookies. As long as your users are opening the new window by clicking a link or by pressing Ctrl+N from the first window, the session information *should* remain in tact. Andrew should - but don't :D you're right and I understand opening new window from desktop starts new process, but this is happening after visitor hits the link detail view and that is confusing :( WILD GUESS ALERT! Perhaps the MS version of open popup in new tab/window is to start a whole new process? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php exactly. now, what would be my solution to keep session info in new window? -ll Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mit freundlichen Grüßen Stefan Langwald Special deal for Yahoo! users friends - No Cost. Get a month of Blockbuster Total Access now http://tc.deals.yahoo.com/tc/blockbuster/text3.com
[PHP] Re: character encoding
Hello, on 03/28/2008 12:08 PM Bill said the following: Hi Manuel In the body that column shows Brébeuf in Windows Outlook. You may want to try this MIME message composing and sending class that http://www.phpclasses.org/mimemessage Looks great Manuel.but my server is under dyndns and the DN isn't qualified so no mail functions available. I am not sure what you mean. This class can compose messages which can be delivered by different drivers, like the mail() function, SMTP client, qmail, sendmail, etc. If you can't use the mail function, you can still send message relaying them through an SMTP server, like for instance Gmail's. I was asking how to have the right character set translation so the data stored in the table show no grimmerish in the outlook window. A simple mailto link in the page with some basic content defined does the trick but the data retrieved from the table can look awsome in the mail client before the user sends it back to the owner email address. I'm making a site for myself. I'm a paintbrush artist, among other things, and I've set a buying level for the visitors. But one can ask to raise his level so he can buy more things in one session. For that I use a mailto link sent to my hotmail with the request giving the name and address of the sender. And that's where I can't control anything. The guy may have written accented caracters in his record and when that info is brought back, it messes the Outlook msg window of the sender. Can I force Outlook msg composer to use my Mysql table collation ? You can build mailto: links with a default subject and text, but I am not sure you can force Outlook to use specific HTML. It's wiser to not rely on mailto: . -- Regards, Manuel Lemos PHP professionals looking for PHP jobs http://www.phpclasses.org/professionals/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD, changing an images pixel color, color matching, fuzzy picture
Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec(substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } function toColor($r, $g, $b) { return $r * $g * $b; } $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { extract(toRGB(imagecolorat($im, $x, $y))); if ($r = 0xCC $g = 0xCC $b = 0x33) imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); } } header('Content-type: image/png'); imagepng($im); ? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] munge / obfuscate ?
-Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 10:02 PM To: Joey Cc: PHP Subject: RE: [PHP] munge / obfuscate ? Hi Joey, Please keep responses on the list so others can also benefit from the learning process. Comments below... On Thu, 2008-03-27 at 21:46 -0400, Joey wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 9:28 PM To: Joey Cc: PHP Subject: Re: [PHP] munge / obfuscate ? On Thu, 2008-03-27 at 21:10 -0400, Joey wrote: Hi All, I have written an app to allow a person to go online and see a picture we take of them. When we link to the picture I don't want it to be obvious that the URL is Domain.Com/Pix/123.jpg because the next person we take a picture of may be 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious. ?php $sekret = 'the brown cow stomped on the wittle bug'; $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0; $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : ''; if( $key == sha1( $key.':'.$sekret ) ) That should have been: if( $key == sha1( $id.':'.$sekret ) ) { header( 'Content-Type: image/jpg' ); readfile( /images/not/in/web/path/$id.jpg ) exit(); } // // Failure... tell them to bugger off :) // header( 'Content-Type: image/jpg' ); readfile( '/images/wherever/you/please/buggerOff.jpg' ); exit(); ? Sorry to be such a newbie... I basically would call this function lets say like: munge( $url ); end in the end be returned the munged url, however, I don't understand the values you have like the readfile with that url -vs- failure? I didn't munge... I provided code for a script that sends the requested image if it was requested with the appropriate key (presumably set wherever the image was linked). If the key doesn't validate then another image is presented. It can say bugger off, it can say not found, it can say whatever you please. By placing the images outside the web root and using a script like this you are virtually guaranteed the visitor can't just request images by making a lucky guess. Let's say the above script was called: getUserImage.php Then you might have the following in your HTML: img src=getUserImage.php?id=123amp;key=4fad1fea72565105d84cb187d1a3ed3bfb9 aba3b / I understand what is happening here, however I really want something simple like: $link =http://www.whataver.com/whateverpath/;; $image = 123456; new_image = munge($image); new_link = $link . $new_image; or maybe new_link = munge($link . $image); Which would encode the whole link. Either way this is what would go into the email message we send out. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] munge / obfuscate ?
On 29 Mar 2008, at 02:15, Jack Sasportas wrote: I understand what is happening here, however I really want something simple like: $link =http://www.whataver.com/whateverpath/;; $image = 123456; new_image = munge($image); new_link = $link . $new_image; or maybe new_link = munge($link . $image); Which would encode the whole link. Either way this is what would go into the email message we send out. Encode in what way? What are you actually trying to stop people doing? If all you're wanting to do is make sure people can't write a script that simply requests n.jpg over and over again with an incrementing n then all you need to do is obfuscate the filename when you store it on your server. You then store that filename in the database alongside the data it relates to. $filename = sha1(time()).'.jpg'; Obviously that's just an example. You can generate the filename in any way you choose as long as you check for duplicates before using it. If that's not the reason please explain exactly what you're trying to achieve rather than how you want to achieve it. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r = 0xCC $g = 0xCC $b = 0x33) After some trial and error (looking at color charts), any red CC, green CC, and blue 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ? :) I don't understand half of that, can you explain what you did? (it works) I was more trying to fix my problem then recoding the whole thing though. I hope that helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] munge / obfuscate ?
On Mar 28, 2008, at 7:15 PM, Jack Sasportas [EMAIL PROTECTED] wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 10:02 PM To: Joey Cc: PHP Subject: RE: [PHP] munge / obfuscate ? Hi Joey, Please keep responses on the list so others can also benefit from the learning process. Comments below... On Thu, 2008-03-27 at 21:46 -0400, Joey wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 9:28 PM To: Joey Cc: PHP Subject: Re: [PHP] munge / obfuscate ? On Thu, 2008-03-27 at 21:10 -0400, Joey wrote: Hi All, I have written an app to allow a person to go online and see a picture we take of them. When we link to the picture I don't want it to be obvious that the URL is Domain.Com/Pix/123.jpg because the next person we take a picture of may be 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious. ?php $sekret = 'the brown cow stomped on the wittle bug'; $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0; $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : ''; if( $key == sha1( $key.':'.$sekret ) ) That should have been: if( $key == sha1( $id.':'.$sekret ) ) { header( 'Content-Type: image/jpg' ); readfile( /images/not/in/web/path/$id.jpg ) exit(); } // // Failure... tell them to bugger off :) // header( 'Content-Type: image/jpg' ); readfile( '/images/wherever/you/please/buggerOff.jpg' ); exit(); ? Sorry to be such a newbie... I basically would call this function lets say like: munge( $url ); end in the end be returned the munged url, however, I don't understand the values you have like the readfile with that url -vs- failure? I didn't munge... I provided code for a script that sends the requested image if it was requested with the appropriate key (presumably set wherever the image was linked). If the key doesn't validate then another image is presented. It can say bugger off, it can say not found, it can say whatever you please. By placing the images outside the web root and using a script like this you are virtually guaranteed the visitor can't just request images by making a lucky guess. Let's say the above script was called: getUserImage.php Then you might have the following in your HTML: img src=getUserImage.php? id=123amp;key=4fad1fea72565105d84cb187d1a3ed3bfb9 aba3b / I understand what is happening here, however I really want something simple like: $link =http://www.whataver.com/whateverpath/;; $image = 123456; new_image = munge($image); new_link = $link . $new_image; or maybe new_link = munge($link . $image); Which would encode the whole link. Either way this is what would go into the email message we send out. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could use base64_encode/decode. Or... function bitshift_encode($i) { return $i 3; } function bitshift_decode($i) { return $i 3; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 7:38 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r = 0xCC $g = 0xCC $b = 0x33) After some trial and error (looking at color charts), any red CC, green CC, and blue 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ? :) I don't understand half of that, can you explain what you did? (it works) I was more trying to fix my problem then recoding the whole thing though. I hope that helps. The thing is, it returns black. not red. Oh. Replace the toColor function with the imagecolorallocate function and add $im as the first parameter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php