php-general Digest 16 Feb 2005 15:22:26 -0000 Issue 3289
Topics (messages 208804 through 208828):
Re: isset
208804 by: Bret Hughes
208812 by: Burhan Khalid
208815 by: M. Sokolewicz
208823 by: Matthew Weier O'Phinney
208828 by: Bret Hughes
Re: fopen problem using ftp
208805 by: The Disguised Jedi
Re: Session Vars and Performance
208806 by: trlists.clayst.com
208807 by: trlists.clayst.com
other mhash hashes
208808 by: David Norman
208814 by: Burhan Khalid
208827 by: Jason Barnett
Re: PHP 5 with Apache 2.0
208809 by: The Disguised Jedi
Re: [NEWBIE] Trying to combine array into one string [SOLVED]
208810 by: Dave
Re: PHP book recommendations>
208811 by: yangshiqi
Re: issue with accents and mysql
208813 by: Burhan Khalid
SoapServer::handlle
208816 by: FENDT Charles
208817 by: FENDT Charles
Re: Image Creation
208818 by: James Taylor
The length of midi
208819 by: Bauglir
208825 by: kermodebear.kermodebear.org
retrieve single field from database without while loop
208820 by: ross.aztechost.com
208821 by: Jay Blanchard
208822 by: Matthew Weier O'Phinney
paring large files - PHP or Perl
208824 by: John Cage
Problem with Include function using Apache 2.0 and PHP 5 on W2K3 Server
208826 by: Dave Adler
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Tue, 2005-02-15 at 16:22, M. Sokolewicz wrote:
> > Chris.
> that's a different issue.
> There are always at least 2 things you should do with your (expected) input:
> 1 - check if it *exists* (isset)
> 2 - check the validity (input-validation)
>
> for step #2 empty is very commonly used, and also a very useful
> function. However, you should never do #2 without #1, since that again
> raises issues (of security, problems, unexpected input, etc)
>
> Also note that empty($non_existent_var) will always throw an E_NOTICE
> error when the variable in question is not set. isset() is the only
> function/language-construct that can check for the existence of
> variables without throwing an E_NOTICE.
This is not true and explicitly states so in the doc. I had to reread
it to remember why I stopped using it. empty will return true if the
value is one of several things "", "0", 0 to name a few. Since I do not
consider these empty I stick with isset and then test for a valid value
depending on the circumstance.
Personally, I think people piss and moan too much about what I consider
proper coding practices. Input validation is to important to skimp on.
Again it is my opinion.
I have been revisiting some php code that I wrote a couple of years ago
and have been pleasantly surprised at the job I did on input validation.
A similar complaint occurs when installing a new version of or moving
code to another box where register_globals is not on. I pissed and
moaned and wailed for about 10 minutes until I thought about it and can
now see the value in not having unknown variables pollute the namespace.
Of course, since most of my code was already validating the variables, a
few :s/\$\(var\)/\$_GET[\1]/ iterations and I was good to go. Yes it
took some time but I feel better having done it.
I just wish there was a use strict; sort of deal so I would not have to
hunt down logic errors due to mistyping a variable name.
Bret
--- End Message ---
--- Begin Message ---
D_C wrote:
I often use this type of construct
$cmd = $_POST['cmd'];
if ($cmd == null) { // do default
but this throws a notice if the ['cmd'] index is not defined. ugly.
using
if (isset($_POST['cmd'] ) {
$cmd = $_POST['cmd'];
}
seems lengthy. is there a way around this?
http://www.php.net/array-key-exists
$cmd = array_key_exists('cmd',$_POST) ? $_POST['cmd'] : null;
--- End Message ---
--- Begin Message ---
Marek Kilimajer wrote:
M. Sokolewicz wrote:
Also note that empty($non_existent_var) will always throw an E_NOTICE
error when the variable in question is not set.
No, it does not.
hmm... seems to have changed since I last checked (PHP5 change?)
I appoligize :)
--- End Message ---
--- Begin Message ---
* Bret Hughes <[EMAIL PROTECTED]>:
> I just wish there was a use strict; sort of deal so I would not have to
> hunt down logic errors due to mistyping a variable name.
There is, in PHP5: E_STRICT. From the manual
(http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):
Run-time notices. Enable to have PHP suggest changes to your
code which will ensure the best interoperability and forward
compatibility of your code.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org
--- End Message ---
--- Begin Message ---
On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
> * Bret Hughes <[EMAIL PROTECTED]>:
> > I just wish there was a use strict; sort of deal so I would not have to
> > hunt down logic errors due to mistyping a variable name.
>
> There is, in PHP5: E_STRICT. From the manual
> (http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):
>
> Run-time notices. Enable to have PHP suggest changes to your
> code which will ensure the best interoperability and forward
> compatibility of your code.
>
Hmm. Good tip thanks. chalk up another reason to upgrade to 5.
getting close to haveing enough reasons to do so :)
E_STRICT is closer but still does not warn of assigning to undeclared
variables in or out of a class. bummer.
Bret
--- End Message ---
--- Begin Message ---
Why not use the built in FTP functions instead of fopen?
us2.php.net/ftp
Those should be able to handle any of the address problems you have,
seeing as they don't use the ftp://username:[EMAIL PROTECTED] syntax,
they open a connection and work with the FTP system.
--
The Disguised Jedi
[EMAIL PROTECTED]
Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm
already internationally compatible!
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"
Disclaimer: Any disclaimer attached to this message may be ignored.
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.
This message is Certified Virus Free
--- End Message ---
--- Begin Message ---
On 15 Feb 2005 Richard Lynch wrote:
> Throw an ab (Apache Benchmark) test at it and find out.
>
> Don't just guess or sit there wondering.
>
> You could run test in about the time it took to compose this email --
Perhaps if you are already familiar with ab, which I'm not ... and if
the server supports it, which it does not at this moment, development
is on Windows, later testing and deployment on Linux.
> All the database code is already written for you on the PHP
> web-site, and it's about one 8.5x11 page of five (5) functions.
>
> Doesn't really sound like a complex test to me.
The data is an internal list of items on the form, all the form field
specs, the data for the fields, default data for resetting the form,
and a data structure for the forms class. Most of these are in
associative arrays, sometimes nested a couple of levels deep. If I'm
going to build a database structure that mirrors the array structure,
and update it every time the array changes during development, that's
hardly straightforward. Without that, I'll have to serialize and
unserialize the data -- and if I'm going to do that, I'd guess that I
might as well use the session vars. So maybe that answers the
question, and the remainder (below) is theoretical.
> Sending the actual query and getting/storing the results will be
> chump-change compared to opening the db connection, almost for sure.
I do actually need a DB connection on every page anyway, so there's no
benefit to avoiding one for this purpose. But to me the likely
consumer of cycles here with a database structure matching the data
structure would be the conversion of MySQL data into an associative
array, and I'd be comparing that to serializing and unserializing. I
don't think either is going to be trivial.
> These two will be neck-and-neck on performance, and will depend more
> on your hardware than on somebody else's experience with their
> hardware.
Fair point.
> Particularly if you've got a 2-tier setup with database on one box
> and PHP on another, where your network hardware and cabling gets
> involved.
Not in this case.
> If you have to choose between a meaningful variable name and
> performance considerations, buy more hardware! :-)
Agreed!
Thanks,
--
Tom
--- End Message ---
--- Begin Message ---
On 15 Feb 2005 Greg Donald wrote:
> > If you have to choose between a meaningful variable name and performance
> > considerations, buy more hardware! :-)
> >
> > The cost you'll save in the long run for code maintenance will make it
> > worth it.
>
> Comments in the code make using short session variable names a non-issue.
Most of what's in my session file is data, not variable names, and my
variable names are not particularly long. Descriptive, but not overly
so (actually in this case most of the 'names' are associative array
indices). If I shortened the variable names I might go down from 250K
to 200K -- if that -- at a large cost in time for code modifications.
I'm not at all keen on that approach, though I'm sure it might work for
some.
--
Tom
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I thought some other people would be interested in the other hashes
that you can do with mhash that aren't on the php.net docs after the
recent news that SHA-1 might be weaker than previously thought:
http://www.schneier.com/blog/archives/2005/02/sha1_broken.html
The built in constants that the mhash docs have listed are simply
integers that tell mhash what to use. So I found the integers in
mhash's mhash.h:
http://cvs.sourceforge.net/viewcvs.py/mhash/mhash/lib/mhash.h?rev=1.25&view=auto
The following works for alternate hashes in the Win32 PHP 5.0.3
release of libmhash.h. For anyone wanting a step up from SHA-1, SHA256
works.
$hashes = array('CRC32' => 0,
~ 'CRC32B' => 9,
~ 'ADLER32' => 18,
~ 'MD4' => 16,
~ 'MD5' => 1,
~ 'RIPEMD160' => 5,
~ 'SHA1' => 2,
~ 'SHA256' => 17,
~ 'HAVAL128' => 13,
~ 'HAVAL160' => 12,
~ 'HAVAL192' => 11,
~ 'HAVAL224' => 10,
~ 'HAVAL256' => 3,
~ 'TIGER128' => 14,
~ 'TIGER160' => 15,
~ 'TIGER192' => 7,
~ 'GOST' => 8);
foreach($hashes as $name => $number) {
~ echo '<br />';
~ echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
or as PHP constants:
$hashes = array('CRC32' => MHASH_CRC32,
~ 'CRC32B' => MHASH_CRC32B,
~ 'ADLER32' => MHASH_ADLER32,
~ 'MD4' => MHASH_MD4,
~ 'MD5' => MHASH_MD5,
~ 'RIPEMD160' => MHASH_RIPEMD160,
~ 'SHA1' => MHASH_SHA1,
~ 'SHA256' => MHASH_SHA256,
~ 'HAVAL128' => MHASH_HAVAL128,
~ 'HAVAL160' => MHASH_HAVAL160,
~ 'HAVAL192' => MHASH_HAVAL192,
~ 'HAVAL224' => MHASH_HAVAL224,
~ 'HAVAL256' => MHASH_HAVAL256,
~ 'TIGER128' => MHASH_TIGER128,
~ 'TIGER160' => MHASH_TIGER160,
~ 'TIGER192' => MHASH_HAVAL192,
~ 'GOST' => MHASH_GOST);
foreach($hashes as $name => $number) {
~ echo '<br />';
~ echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
I suspect if you were able to compile a more recent version of mhash,
the following complete list of mhash's hashes would work, including
SHA512 and WHIRLPOOL.
$hashes = array('CRC32' => 0,
~ 'CRC32B' => 9,
~ 'ADLER32' => 18,
~ 'MD2' => 27,
~ 'MD4' => 16,
~ 'MD5' => 1,
~ 'RIPEMD160' => 5,
~ 'RIPEMD128' => 22,
~ 'RIPEMD256' => 23,
~ 'RIPEMD320' => 24,
~ 'SHA1' => 2,
~ 'SHA224' => 19,
~ 'SHA256' => 17,
~ 'SHA384' => 21,
~ 'SHA512' => 20,
~ 'HAVAL128' => 13,
~ 'HAVAL160' => 12,
~ 'HAVAL192' => 11,
~ 'HAVAL224' => 10,
~ 'HAVAL256' => 3,
~ 'TIGER128' => 14,
~ 'TIGER160' => 15,
~ 'TIGER192' => 7,
~ 'GOST' => 8,
~ 'WHIRLPOOL' => 21,
~ 'SNEFRU128' => 25,
~ 'SNEFRU256' => 26);
foreach($hashes as $name => $number) {
~ echo '<br />';
~ echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCEtHtqLBH+DmBuAIRAhN1AJ9YjaYRNP7d1FVp9zLXNDlBAeWvUQCgutlh
7d+AAPjv1Kh3rWiqld654DE=
=dhyN
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
David Norman wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I thought some other people would be interested in the other hashes
that you can do with mhash that aren't on the php.net docs after the
recent news that SHA-1 might be weaker than previously thought:
http://www.schneier.com/blog/archives/2005/02/sha1_broken.html
The built in constants that the mhash docs have listed are simply
integers that tell mhash what to use. So I found the integers in
mhash's mhash.h:
http://cvs.sourceforge.net/viewcvs.py/mhash/mhash/lib/mhash.h?rev=1.25&view=auto
The following works for alternate hashes in the Win32 PHP 5.0.3
release of libmhash.h. For anyone wanting a step up from SHA-1, SHA256
works.
David:
You should really post this at the mhash manual entry in php.net.
I'm sure others would find it useful. Good find :)
Cheers,
Burhan
[ snippity snip snip ]
--- End Message ---
--- Begin Message ---
Burhan Khalid wrote:
...
David:
You should really post this at the mhash manual entry in php.net. I'm
sure others would find it useful. Good find :)
Cheers,
Burhan
[ snippity snip snip ]
Agreed! I found it very, very useful.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
signature.asc
Description: OpenPGP digital signature
--- End Message ---
--- Begin Message ---
go for it dude....it's ready for you...the question is...
<being funny> Are you ready for it?? </being funny>
On Tue, 15 Feb 2005 12:29:04 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]>
wrote:
> Neal Schilling wrote:
> > I know this question probably gets asked a lot, but I'm setting up a Web
> > Server shortly and am debating going with PHP 5 on Apache 2.0 or 1.3. In
> > short, is PHP 5, when combined with either Apache 1.3 or 2.0 on Linux or
> > FreeBSD, ready for a production environment? This is, of course, an
> > opinion, but back your opinion with as much fact as possible.
> >
> > Also, if PHP 5 is NOT ready, do you feel PHP 4.3 is ready for production
> > with Apache 2.0?
>
> What features in Apache 2.0 do you NEED?
> What features in PHP 5 do you NEED?
> Which modules of PHP do you NEED?
>
> The answers to these questions, and some testing on a development server
> (with stress-load testing!) will answer your question for YOU, which has
> very little to do with anybody else's answer to the question. :-)
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
The Disguised Jedi
[EMAIL PROTECTED]
Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm
already internationally compatible!
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"
Disclaimer: Any disclaimer attached to this message may be ignored.
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.
This message is Certified Virus Free
--- End Message ---
--- Begin Message ---
Matt, Warren, Gareth, Chris, Jochem, Ospinto, Richard,
Thank you all for your helpful suggestions. implode() is the command
I needed, and I've applied syntax similar to Matt's suggestion.
My problem is now solved.
Your responses are all much appreciated.
--
Dave Gutteridge
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
I enjoy the "Core PHP Programming, Third Edition by Leon Atkinson" very
much.
Best regards,
Yang Shiqi
-----Original Message-----
From: Joe Harman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 16, 2005 3:20 AM
To: [email protected]
Subject: Re: [PHP] PHP book recommendations>
personally, I like Julie Meloni's books... PHP essentials.. and fast
and easy web development... these were some of the first books that i
bought and got started with... they are pretty easy to use, especially
if you are not into reading technical manuals
http://www.thickbook.com
On Tue, 15 Feb 2005 14:20:05 -0500, Joe Harman <[EMAIL PROTECTED]> wrote:
> sorry... wrong address
>
>
> On Tue, 15 Feb 2005 14:19:46 -0500, Joe Harman <[EMAIL PROTECTED]> wrote:
> > personally, I like Julie Meloni's books... PHP essentials.. and fast
> > and easy web development... these were some of the first books that i
> > bought and got started with... they are pretty easy to use, especially
> > if you are not into reading technical manuals
> >
> >
> > On Tue, 15 Feb 2005 08:54:14 -0800 (PST), Chris Shiflett
> > <[EMAIL PROTECTED]> wrote:
> > > --- "Bosky, Dave" <[EMAIL PROTECTED]> wrote:
> > > > I'm looking for an easy to read PHP book that will help me learn a
> > > > solid foundation in PHP.
> > >
> > > If you need a strong foundation:
> > >
> > > http://www.oreilly.com/catalog/learnphp5/
> > >
> > > If you already have a strong foundation:
> > >
> > > http://www.amazon.com/exec/obidos/ASIN/0672325616
> > >
> > > Hope that helps.
> > >
> > > Chris
> > >
> > > =====
> > > Chris Shiflett - http://shiflett.org/
> > >
> > > PHP Security - O'Reilly HTTP Developer's Handbook - Sams
> > > Coming Soon http://httphandbook.org/
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
mario wrote:
Hello,
please help me on the following issue.
please reply to [EMAIL PROTECTED] too.
(I asked for help on the php-db ml, but nobody replied)
I have hacked the following function:
function accents($text) {
global $export;
$search = array ( '�', '�', '�', '�' , '�');
$replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
$export = str_replace($search, $replace, $text);
return $export;
}
It works fine, as long as I feed it with a string:
accents('�') --> \`{a}
The issue is when I get '�' from a mysql table.
I.e., for some record of a mysql table Table, let � the value of the
field Field, and say
$result = mysql_fetch_array($answer, MYSQL_BOTH),
where $answer= mysql_query(SELECT * FROM Table).
Now accents($result['Field']) returns � (instead of \`{a}).
Why? I have no idea.
Try var_dump $text in accents() when you pass it $result['Field']
--- End Message ---
--- Begin Message ---
Hello,
I (try) to use a SoapServer in a CLI program.
I want to redirect the SoapServer::handle() output from STDOUT to a
socket stream.
(my second question is how can i prevent SoapServer::handle() to kill my
daemon process... cf php.soap)
How can I o this ?
regards
FENDT Charles
--- End Message ---
--- Begin Message ---
Hello,
here is an example:
<?php
$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->handle("");
echo "\nAlive!!!!\n";
?>
here is the result
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
this didn't output "Alive!!!!" on stdout...
the script ends with the SoapServer::handle() call.
Did i miss something?
an option ?
regards
FENDT Charles
P.S. I need to use the WSDL mode. The same happened, but this is easier show my
probleme
(no need of a WSDL file)
--- End Message ---
--- Begin Message ---
Ahh now it becomes clear, you where trying to place the image inline.
There is a way with base64 encoding, but it isnt supported by many
browsers - you can actually say <IMG SRC="data:image/png,base64;[...]">
where the [...] is the base64 encoded image, so you would need to wrap
an ob start and ob end around your code to catch output, then base64
encode it then display it.
The problem is it dosnt work in IE because IE dosn't support this. Its
also not very nice for anyone not wanting to view images as they will
have downloaded the image even though they dont want to see it. There
was a very good reason why I know that and have done it, but more then
99.9% of the time, its not the way to go.
(the case in example was an embedded application on a machine that had a
pseudo-web interface but no webserver - it would wait for a connection
on a port then "dump" a stream of text which would be in HTML - there
was no webserver there it would ignore any http headers sent).
Aaron Todd wrote:
Hey Guys,
I think I fixed my own problem. I tried calling the PHP script from a
different page like this:
<img border='0' src='include/pie.php?slice=100&total=200'>
This gave me the results I wanted.
Thanks for all your help.
Aaron
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I just wrote a little script to play around with the GD library but I am
having a problem displaying it in the browser. I have not problem at all
when I just run the script. But I was trying to make the image in a custom
function which will return the image when its called. All I end up getting
is a bunch of weird characters.
Here's my code:
function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 0, 0);
imagefilledellipse($im, 75, 75, 125, 125, $red);
imageellipse($im, 75, 75, 125, 125, $black);
//Making the Slice
$pieslice = (($slice / $total) * 360) + 315;
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black,
IMG_ARC_PIE);
//Return
header("Content-type: image/png");
echo ImagePNG($im);
}
Anyone have any idea why I cant return the image?
Thanks
--- End Message ---
--- Begin Message ---
Hi,
Does anybody know how to determine the length (in seconds) of midi melody?
--
s pozdravem
Bronislav Klucka
----------=[ pro2-soft.com ]=----------
http://pro2-soft.com
[EMAIL PROTECTED]
+420 605 58 29 22
* webove aplikace
* software na zakazku
---------------------------------------
--- End Message ---
--- Begin Message ---
You may find this to be useful:
http://www.google.com/search?hl=en&q=PHP+MIDI
-KBear
Original Message Follows:
Hi,
Does anybody know how to determine the length (in seconds) of midi melody?
--
s pozdravem
Bronislav Klucka
----------=[ pro2-soft.com ]=----------
http://pro2-soft.com
[EMAIL PROTECTED]
+420 605 58 29 22
* webove aplikace
* software na zakazku
---------------------------------------
--- End Message ---
--- Begin Message ---
Is there a way to retrieve and display a single value (customer number) from
a database and display it without using
while ($row = mysql_fetch_array) ($result)){
I have a value I know the query will only ever return a single value. I want
to get it from the database and convert it to a variable so I can use it on
my php page.
Thanks in advance,
Ross
--- End Message ---
--- Begin Message ---
[snip]
Is there a way to retrieve and display a single value (customer number)
from
a database and display it without using
while ($row = mysql_fetch_array) ($result)){
I have a value I know the query will only ever return a single value. I
want
to get it from the database and convert it to a variable so I can use it
on
my php page.
[/snip]
Yes...take out the while....
$row = mysql_fetch_array($results);
echo $row['CustomerNumber'] . '\n';
--- End Message ---
--- Begin Message ---
* [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> Is there a way to retrieve and display a single value (customer number) from
> a database and display it without using
>
> while ($row = mysql_fetch_array) ($result)){
>
>
> I have a value I know the query will only ever return a single value. I want
> to get it from the database and convert it to a variable so I can use it on
> my php page.
Use a DB abstraction layer. PEAR::DB and PEAR::MDB2 both have a getOne()
method that will grab the value from the first column of the first row
in the resultset:
$result = $db->getOne($sql);
Yes, it's more overhead, but it makes things like this so trivial that
you have to ask if your time or your processor time is more important.
(And, frankly, on most machines these days won't even notice the
performance hit of loading one of these libraries.)
ADODB gets good reviews as well, and I'm pretty sure they have a similar
method.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org
--- End Message ---
--- Begin Message ---
Hi there
I'm a great believer in using the right program for the right job. I
need some advice from people who use both PHP and Perl. I've long been
a fan of PHP and we use it for all our development work. However, I seem
to keep coming up with a bit of a problem when using PHP and I just
wanted to see if I was right or if there's something I'm not doing right.
Basically, we are bringing emails in from a client that all contain
large files - usually between 12mb and 15mb in size. This side of what
we are doing cannot be changed unfortunately. When we use PHP to parse
these files it often times out - I understand that we can flush data and
we call set_time_limit() occassionally to reset the time counter, but
PHP really seems to struggle. It just seems that every job I work on
that needs to parse large files or do something like web crawling that
we always come across these problems. A couple of people have said that
we should look at Perl because it is better at this kind of thing and
thats why I'd be interested in opinions about it from people who know -
ie those who regularly code in both
Appreciate any comments or suggestions or even if you can point me to
any sites that cover this as I looked and couldn't find any
thanks
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
I am new to PHP and Apache. I am trying to use the include function to
include a file that has my web page header and menu, similar to what I used
to do with SSI.
The content of the include file doesn't display. Instead, I get a link that
says function.main and below that I get a link that says function.include
I can run other PHP code with no problem. The include files are in a folder
below the doc root called Includes.
This is running on Windows 2003 Server. I did a default install of Apache
2.0 and PHP 5.
This is probably a settig in httpd.conf or php.ini but I can't seem to find
it in the docs.
Any help would be greatly appreciated.
Thanks in advance,
David
--- End Message ---