|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Fri Mar 28 2008 - 21:03:41 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 29 Mar 2008 02:03:41 -0000 Issue 5373
Topics (messages 272213 through 272266):
Re: putting variables in a variable
272213 by: Peter Ford
272224 by: Daniel Brown
272226 by: Wolf
272235 by: M. Sokolewicz
272239 by: tedd
Re: optimilize web page loading
272214 by: Robert Cummings
272215 by: Robert Cummings
272218 by: Zoltán Németh
272222 by: Robert Cummings
272223 by: Zoltán Németh
272227 by: Robert Cummings
272232 by: tedd
272233 by: tedd
272234 by: Sancar Saran
Use of callback on a stream
272216 by: Olivier Dupuis
272217 by: Olivier Dupuis
array_filter function
272219 by: Bagus Nugroho
272220 by: Richard Heyes
272229 by: Robin Vickery
272240 by: Bagus Nugroho
Re: munge / obfuscate ?
272221 by: Daniel Brown
272228 by: Robert Cummings
272236 by: tedd
Re: Quick email address check
272225 by: Robin Vickery
Re: character encoding
272230 by: Bill
272264 by: Manuel Lemos
Deleting file in /tmp directory
272231 by: Mário Gamito
272237 by: Colin Guthrie
272238 by: Daniel Brown
why won't my array work?
272241 by: Jason Pruim
272242 by: Eric Butera
272243 by: Thiago Pojda
272244 by: Jason Pruim
272246 by: Eric Butera
272248 by: Daniel Brown
PHP code to write excel spreadsheet with multiple workbooks
272245 by: Mary Anderson
272247 by: Andrew Ballard
272256 by: Wolf
Enabling cURL on my Mac
272249 by: Kista Tucker
272250 by: Jim Lucas
convert associative array to ordinary array
272251 by: It Maq
272252 by: Daniel Brown
272253 by: M. Sokolewicz
272254 by: Casey
272255 by: It Maq
Posting Summary for Week Ending 28 March, 2008: php-general
lists.php.net
272257 by: PostTrack [Dan Brown]
does function extract() trim?
272258 by: Lamp Lists
272259 by: Stut
272260 by: Lamp Lists
272261 by: Stut
272262 by: Lamp Lists
Re: loosing session in new window (IE only) [SOLVED]
272263 by: Lamp Lists
GD, changing an images pixel color, color matching, fuzzy picture
272265 by: Lamonte
272266 by: Casey
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hulf wrote:
> Hi,
>
> I am making and HTML email. I have 3 images to put in. Currently I have
>
> $body .="
> <table>
> <tr>
> <td><img 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>
<td><img src=\"$myimage1\"></td>
</tr>
</table>
";
I'd probably use single-quotes (') around the src attribute to avoid those ugly
backslashes ...
$body .="
<table>
<tr>
<td><img src='$myimage1'></td>
</tr>
</table>
";
Might be better in this case to use heredoc syntax ...
$body .<<<EndOfChunk
<table>
<tr>
<td><img src="$myimage1"></td>
</tr>
</table>
EndOfChunk;
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
attached mail follows:
On Mon, Mar 28, 2011 at 7:06 AM, Hulf <ross
blue-fly.co.uk> wrote:
> Hi,
>
> I am making and HTML email. I have 3 images to put in. Currently I have
>
> $body .="
> <table>
> <tr>
> <td><img 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>
<td><img src="$myimage1"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="$myimage2"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="$myimage3"></td>
</tr>
<tr>
<td> </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>
<td><img src="$v"></td>
</tr>
<tr>
<td> </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
attached mail follows:
---- Hulf <ross
blue-fly.co.uk> wrote:
> Hi,
>
> I am making and HTML email. I have 3 images to put in. Currently I have
>
> $body .="
> <table>
> <tr>
> <td><img 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
attached mail follows:
Hulf wrote:
> Hi,
>
> I am making and HTML email. I have 3 images to put in. Currently I have
>
> $body .="
> <table>
> <tr>
> <td><img 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 ?
attached mail follows:
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>
>> <td><img 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>
<td><img 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
attached mail follows:
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
attached mail follows:
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 <news
ridersite.org> 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 .00000000000000000000000000000002 seconds
> > > >> to run using double quotes it will only take
> > > >> .000000000000000000000000000000019 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
attached mail follows:
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 <news
ridersite.org> 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 .00000000000000000000000000000002 seconds
> > > > >> to run using double quotes it will only take
> > > > >> .000000000000000000000000000000019 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.
attached mail follows:
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
attached mail follows:
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.
attached mail follows:
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
teeeeeeeency, 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
attached mail follows:
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
attached mail follows:
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
>teeeeeeeency, 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
attached mail follows:
My method was.
Store into global thingy. Then echo very end of the page.
attached mail follows:
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);
}
attached mail follows:
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);
}
attached mail follows:
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
attached mail follows:
> 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
attached mail follows:
On 28/03/2008, Bagus Nugroho <bnugroho
unisemgroup.com> 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";'));
attached mail follows:
Thanks You,
rgds, bnug
________________________________
From: Robin Vickery [mailto:robinv
gmail.com]
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 <bnugroho
unisemgroup.com> 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";'));
attached mail follows:
On Thu, Mar 27, 2008 at 9:27 PM, Robert Cummings <robert
interjinn.com> 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
attached mail follows:
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
attached mail follows:
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
attached mail follows:
On 28/03/2008, Bastien Koert <phpster
gmail.com> wrote:
> On Thu, Mar 27, 2008 at 10:23 PM, Bill Guion <bguion
comcast.net> 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])+
[a-z0-9]+([-_\.]?[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
attached mail follows:
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
attached mail follows:
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/
attached mail follows:
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
attached mail follows:
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
attached mail follows:
On Fri, Mar 28, 2008 at 11:24 AM, Mário Gamito <gamito
gmail.com> 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.' 2>&1',$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
attached mail follows:
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
japruim
raoset.com
attached mail follows:
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim
raoset.com> 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?
attached mail follows:
That's because your loginpassWord is in another array.
try $chpwrow[0]['loginPassword']
-----Mensagem original-----
De: Jason Pruim [mailto:japruim
raoset.com]
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
japruim
raoset.com
attached mail follows:
On Mar 28, 2008, at 12:40 PM, Eric Butera wrote:
> On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim
raoset.com>
> 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
japruim
raoset.com
attached mail follows:
On Fri, Mar 28, 2008 at 12:58 PM, Jason Pruim <japruim
raoset.com> wrote:
>
>
> On Mar 28, 2008, at 12:40 PM, Eric Butera wrote:
> > On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim
raoset.com>
> > 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
> japruim
raoset.com
>
>
>
>
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
attached mail follows:
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim
raoset.com> 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
attached mail follows:
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 10000 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
attached mail follows:
On Fri, Mar 28, 2008 at 1:12 PM, Mary Anderson
<maryfran
demog.berkeley.edu> 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 10000 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
attached mail follows:
---- Mary Anderson <maryfran
demog.berkeley.edu> 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 10000 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
attached mail follows:
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
attached mail follows:
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
attached mail follows:
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
attached mail follows:
On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe
yahoo.com> 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
attached mail follows:
Daniel Brown wrote:
> On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe
yahoo.com> 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
attached mail follows:
On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown <parasane
gmail.com> wrote:
> On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe
yahoo.com> 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
attached mail follows:
thank you, it works!
--- Casey <heavyccasey
gmail.com> wrote:
> On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown
> <parasane
gmail.com> wrote:
> > On Fri, Mar 28, 2008 at 2:27 PM, It Maq
> <itmaqurfe
yahoo.com> 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
attached mail follows:
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 Chong<fpqkfd 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 Chong<kwtuvb 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 Chong<wjrkcn 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 Chong<xbjpwt 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 (0.6%) 1942 (0.2%) Ray Hauge <ray dot hauge dot lists at gmail dot com>
2 (0.6%) 2551 (0.3%) Kirk dot Johnson at zootweb dot com
1 (0.3%) 475 (0.1%) thomas Armstrong <tarmstrong at gmail dot com>
1 (0.3%) 1377 (0.2%) Alfredo CV <acovaleda at loslibrosusados dot net>
1 (0.3%) 793 (0.1%) Rod Clay <rclay at columbus dot rr dot com>
1 (0.3%) 1007 (0.1%) David Lidstone <dnews at elocal dot co dot uk>
1 (0.3%) 1576 (0.2%) jeffry s <paragasu at gmail dot com>
1 (0.3%) 1585 (0.2%) Tom Chubb <tomchubb at gmail dot com>
1 (0.3%) 3016 (0.4%) robert <roadtested at gmail dot com>
1 (0.3%) 184 (0%) Sancar Saran <sancar dot saran at evodot dot com>
1 (0.3%) 878 (0.1%) Shelley <myphplist at gmail dot com>
1 (0.3%) 2322 (0.3%) Ashalintubbi Schouten <evaluates at sesa dot org>
1 (0.3%) 670 (0.1%) Joey <Joey at Web56 dot net>
1 (0.3%) 2245 (0.3%) ganu <ganu dot ullu at gmail dot com>
1 (0.3%) 1647 (0.2%) Christoph Boget <jcboget at yahoo dot com>
1 (0.3%) 1022 (0.1%) Mary Anderson <maryfran at demog dot berkeley dot edu>
1 (0.3%) 560 (0.1%) Hulf <ross at blue-fly dot co dot uk>
1 (0.3%) 1764 (0.2%) Sangamesh B <forum dot san at gmail dot com>
1 (0.3%) 550 (0.1%) Kista Tucker <kista at rochester dot rr dot com>
1 (0.3%) 1061 (0.1%) Haig Dedeyan <hdedeyan at videotron dot ca>
1 (0.3%) 1381 (0.2%) Ashley M dot Kirchner <ashley at pcraft dot com>
1 (0.3%) 187 (0%) edwardspl at ita dot org dot mo
1 (0.3%) 351 (0%) steve <iamstever at gmail dot com>
1 (0.3%) 782 (0.1%) Jonathan Mast <jhmast dot developer at gmail dot com>
1 (0.3%) 667 (0.1%) admin at buskirkgraphics dot com
1 (0.3%) 1200 (0.1%) n3or <info at n3or dot de>
1 (0.3%) 865 (0.1%) Jonesy <gmane at jonz dot net>
1 (0.3%) 1242 (0.1%) Greg Sims <greg at headingup dot net>
1 (0.3%) 622 (0.1%) cool7 at hosting4days dot com <cool7 at hosting4days dot com>
1 (0.3%) 712 (0.1%) Børge Holen <borge at arivene dot net>
1 (0.3%) 961 (0.1%) Terry Burns-Dyson <hammerstein_02 at msn dot com>
1 (0.3%) 743 (0.1%) Larry Garfield <larry at garfieldtech dot com>
1 (0.3%) 253 (0%) L-Soft list server at AudetteMedia (1 dot 8d) <LISTSERV at LIST dot AUDETTEMED
1 (0.3%) 1736 (0.2%) Ryan S <genphp at yahoo dot com>
1 (0.3%) 8520 (1%) PostTrack [Dan Brown] <listwatch-php-general at pilotpig dot net>
1 (0.3%) 2745 (0.3%) Nitsan Bin-Nun <nitsanbn at gmail dot com>
1 (0.3%) 1861 (0.2%) Lester Caine <lester at lsces dot co dot uk>
1 (0.3%) 736 (0.1%) MartĂn MarquĂ©s <martin at marquesminen dot com dot ar>
1 (0.3%) 1282 (0.2%) Carlton Whitehead <carlton dot whitehead at cebesius dot com>
1 (0.3%) 647 (0.1%) Per Jessen <per at computer dot org>
1 (0.3%) 1512 (0.2%) Dee Ayy <dee dot ayy at gmail dot com>
1 (0.3%) 170 (0%) alexus <alexus at gmail dot com>
1 (0.3%) 4299 (0.5%) Stefan Langwald &