OSEC

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 23 Jan 2007 12:45:30 -0000 Issue 4585

php-general-digest-helplists.php.net
Date: Tue Jan 23 2007 - 06:45:30 CST


php-general Digest 23 Jan 2007 12:45:30 -0000 Issue 4585

Topics (messages 247585 through 247625):

Re: Normalized Numbers
        247585 by: Brian P. Giroux
        247613 by: Roman Neuhauser

Re: [HELP] Fatal error when uploading large files!
        247586 by: Jochem Maas

Re: preg_match problem
        247587 by: Beauford
        247588 by: Paul Novitski

Re: Function returning but continues execution
        247589 by: Jochem Maas
        247590 by: Robert Cummings
        247592 by: Jochem Maas
        247593 by: Robert Cummings
        247624 by: David Mytton

Re: Php coding help - Newbie question
        247591 by: Chris
        247606 by: Ramdas

JPEG info needed
        247594 by: Gerry D

where match question
        247595 by: Don
        247597 by: Chris
        247600 by: Don
        247601 by: Chris
        247605 by: Don
        247607 by: Jim Lucas
        247618 by: Németh Zoltán
        247619 by: Chris
        247620 by: Németh Zoltán
        247621 by: Jim Lucas
        247622 by: Németh Zoltán
        247623 by: Chris

using return in include files
        247596 by: Aaron Axelsen
        247598 by: Chris
        247599 by: Gregory Beaver
        247625 by: Arno Kuhl

having trouble with is_file() and is_dir() on 5.1.2
        247602 by: jekillen
        247603 by: Chris
        247604 by: Ligaya A. Turmelle
        247610 by: clive
        247612 by: jekillen
        247614 by: clive
        247615 by: Roman Neuhauser
        247616 by: Roman Neuhauser

Re: Help With Inventory
        247608 by: Brandon Bearden
        247609 by: Roman Neuhauser
        247611 by: Brandon Bearden
        247617 by: Jim Lucas

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Roman Neuhauser wrote:
--
Brian P. Giroux
Sénécal & Associé.e.s / Associates
Recherche et marketing / Research and marketing
Tél : (705) 476-9667
Fax : (705) 476-1618
www.senecal.ca> # bpgsenecal.ca / 2007-01-14 14:51:30 -0500:
>> I tried to install Testilence on my Ubuntu using Gnu make 3.81beta4(my
>> skills as a Linux administrator are weaker than my PHP skills) but was
>> unsuccessful :(
>
> What problems did you have?

Well, I had a few problems following the "wash and go" instructions...

First off, I am using 64bit Ubuntu 6.06LTS.

I don't have "fetch" so I just downloaded it with my web browser.

Next, the tar command "tar -xzf
testilence-0.0.0.snap200701051209.tar.bz2" forces my version of tar (GNU
tar 1.15.1) to use gzip so I just did a "tar -xvf testil...." and that
worked fine.

The "cd testil...." worked as expected ;)

And finally the "make check install" gave the following:

| env TENCE_TESTS_TARGET=tencetest_SafeTests make _check
| phpflags="-d include_path=$(pwd)/src:$(make -s _include-path)"; \
| /usr/bin/env php $phpflags src/tence/tence --run
| tests/alltests.php tencetest_SafeTests
|
| Fatal error: Call to undefined method ReflectionClass::newInstanceArgs()
| in /root/testilence-0.0.0.snap200701051209/src/tence/main.php on line
| 196
| make[1]: *** [_check] Error 255
| make: *** [check] Error 2

If I was more comfortable I could probably poke at it a bit and get it
to work, but right now, I'd probably poke at the wrong thing and break
the whole system. :(

--
Brian P. Giroux

attached mail follows:


# bpgsenecal.ca / 2007-01-22 19:36:50 -0500:
> Roman Neuhauser wrote:
> www.senecal.ca> # bpgsenecal.ca / 2007-01-14 14:51:30 -0500:
> >> I tried to install Testilence on my Ubuntu using Gnu make 3.81beta4(my
> >> skills as a Linux administrator are weaker than my PHP skills) but was
> >> unsuccessful :(
> >
> > What problems did you have?
>
> Well, I had a few problems following the "wash and go" instructions...
>
> First off, I am using 64bit Ubuntu 6.06LTS.
>
> I don't have "fetch" so I just downloaded it with my web browser.
>
> Next, the tar command "tar -xzf
> testilence-0.0.0.snap200701051209.tar.bz2" forces my version of tar (GNU
> tar 1.15.1) to use gzip so I just did a "tar -xvf testil...." and that
> worked fine.

Sorry, it says tar.gz and tar -xzf, while the actual tarball names end
with tar.bz2 (the tars are bzip2ed). Thanks for pointing out the
problem, I just fixed it.
 
> And finally the "make check install" gave the following:
>
> | env TENCE_TESTS_TARGET=tencetest_SafeTests make _check
> | phpflags="-d include_path=$(pwd)/src:$(make -s _include-path)"; \
> | /usr/bin/env php $phpflags src/tence/tence --run
> | tests/alltests.php tencetest_SafeTests
> |
> | Fatal error: Call to undefined method ReflectionClass::newInstanceArgs()
> | in /root/testilence-0.0.0.snap200701051209/src/tence/main.php on line

What version of PHP do you have? Please send me (privately) your
php -v
php -m

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


Jay Paulson wrote:
> Hi everyone,
>
> Hopefully you all can help! I¹m at a loss as to what to do next. I¹m
> running PHP 5.1.2 with Apache 2.0.55 on RedHat ES4 and I keep getting the
> following PHP error when trying to upload a larger file. I have
> AllowOverride turned on in the httpd.conf file so my .htaccess file is below
> as well. When I look at phpinfo() it reflects the changes in the .htaccess
> file but yet still I get the following PHP fatal error. Anyone have any
> ideas what could be going on? Could it be the Zend Memory Manager
> (something that I know nothing about)? Or anything else I may not be aware
> of?
>
> Any help would be greatly appreciated!
>
>
> Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
> allocate 19590657 bytes) in /path/to/php/file on line 979
>
> LimitRequestBody 0
> php_value memory_limit 40M
> php_value post_max_size 30M
> php_value upload_max_filesize 30M
> php_value display_errors On
> php_value max_execution_time 300
> php_value max_input_time 300

php_value can't overrule a php_admin_value (your apache conf or another .htaccess
maybe setting these ini settings usiong php_admin_value).

check that the php ini settings you've got in your .htaccess are
actually being honored:

foreach (array('memory_limit','post_max_size','upload_max_filesize') as $ini)
        echo ini_get($ini),'<br />';

>

attached mail follows:


 

> -----Original Message-----
> From: Paul Novitski [mailto:pauljuniperwebcraft.com]
> Sent: January 22, 2007 6:58 PM
> To: PHP
> Subject: Re: [PHP] preg_match problem
>
> At 1/22/2007 03:04 PM, Beauford wrote:
> >I'm trying to get this but not quite there. I want to allow the
> >following characters.
> >
> >A-Za-z0-9!#$%&()*;:_.'/\ and a space.
> >
> >Is there a special order these need to be in or escaped somehow. For
> >example, if I just allow _' the ' is fine, if I add the other
> >characters, the ' gets preceded by a \ and an error is
> returned. If I
> >take the ' out of the sting below it works fine, I get no errors
> >returned. I am also using stripslashes on the variable.
> >
> >This is my code. (although I have tried various things with
> it trying
> >to get it right)
> >
> >if(preg_match("/^[-A-Za-z0-9!#%&\(\)\*;:_.\'\$ ]+$/", $string)) {
>
>
> Please read this page:
>
> Pattern Syntax -- Describes PCRE regex syntax
> http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php
>
> specifically the section on character classes:
> http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php#
> regexp.reference.squarebrackets
>
> In PREG there are few characters that you need to escape in a
> character class expression:
>
> 1) ^ must be escaped (\^) if it's the first character (it
> negates the match when it's unescaped in the first position).
>
> 2) ] must be escaped (\]) unless it's the first character of
> the class (it closes the class if it appears later and is not
> escaped).
>
> 3) \ must be escaped (\\) if you're referring to the
> backslash character rather than using backslash to escape
> another character.
>
> 4) Control codes such as \b for backspace (not to be confused
> with \b which means word boundary outside of a character class).
>
>
> In addition, you may need to escape certain characters in PHP if
> you're expressing the RegExp pattern in a quoted string, such as
> single or double quotes (whichever you're using to quote the pattern):
>
> '[\'"]' escape the apostophe
> "['\"]" escape the quotation mark
>
> Those are PHP escapes -- by the time PREG sees the pattern, the PHP
> compiler has rendered it to:
>
> ['"]
>
> And then of course there's the complication that both PREG and PHP
> use the backslash as the escape character, so the pattern:
>
> [\\] escape the backslash
>
> must be expressed in PHP as:
>
> [\\\\] escape the escape and the backslash
>
> Interestingly, PHP compiles both \\\ and \\\\ as \\, go figure. I
> use \\\\ to escape both backslashes to maintain some semblance of
> logic and order in these eye-crossing expressions.
>
> Because PHP requires quotes to be escaped, I find it easier to write
> & debug patterns in PHP if I express them in heredoc where quoting
> and most escaping is unnecessary:
>
> $sPattern = <<<_
> ['"\\\\]
> _;
>
> becomes the PREG pattern ['"\\].
>
>
> So to address your character class:
>
> >A-Za-z0-9!#$%&()*;:_.'/\ and a space.
>
> I'd use the pattern:
>
> [A-Za-z0-9!#$%&()*;:_.'/\\ ]
>
> where the only character I need to escape is the backslash itself.
>
> In PHP this would be:
>
> $sPattern = '[A-Za-z0-9!#$%&()*;:_.\'/\\\\ ]';
> (escaped apostrophe & blackslash)
> or:
> $sPattern = "[A-Za-z0-9!#$%&()*;:_.'/\\\\ ]";
> (escaped blackslash)
> or:
> $sPattern = <<<_
> [A-Za-z0-9!#$%&()*;:_.'/\\\\ ]
> _;
> (escaped blackslash)

I've probably read 100 pages on this, and no matter what I try it doesn't
work. Including all of what you suggested above - is my PHP possessed?

if(preg_match("/^[A-Za-z0-9!#$%&()*;:_.'/\\ ]+$/", $string)) { gives me
this error.

Warning: preg_match() [function.preg-match]: Unknown modifier '\' in
/constants.php on line 107

So if If you wouldn't mind, could you show me exactly what I need right from
the beginning and explain why it works.

i.e.

if(preg_match(what goes here", $string)) {
Echo "You got it";

attached mail follows:


At 1/22/2007 04:56 PM, Beauford wrote:
>I've probably read 100 pages on this, and no matter what I try it doesn't
>work. Including all of what you suggested above - is my PHP possessed?
>
>if(preg_match("/^[A-Za-z0-9!#$%&()*;:_.'/\\ ]+$/", $string)) { gives me
>this error.
>
>Warning: preg_match() [function.preg-match]: Unknown modifier '\' in
>/constants.php on line 107
>
>So if If you wouldn't mind, could you show me exactly what I need right from
>the beginning and explain why it works.
>
>i.e.
>
>if(preg_match(what goes here", $string)) {
>Echo "You got it";

Beauford,

Because you're using forward slashes /.../ to delimit your pattern,
regexp is using the / in your character class to terminate your pattern:

         /^[A-Za-z0-9!#$%&()*;:_.'/

Then it's looking at the subsequent characters as pattern modifiers
and gacking on the backslash. Even if you had a character there that
it could accept as a pattern modifier, the character class would be
incomplete (no closing bracket) so the pattern is doomed to fail.

You need to escape that forward slash in the character class:

         preg_match("/^[A-Za-z0-9!#$%&()*;:_.'\/

Also, you've got only two backslashes in your char class. PHP is
reducing this to a single backslash before the space character. I
think you intend this to be two backslashes in the pattern so you
need four backslashes in PHP:

         preg_match("/^[A-Za-z0-9!#$%&()*;:_.'\/\\\\ ]+$/", $string)

Regards,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com

attached mail follows:


Roman Neuhauser wrote:
> # davidemomentum.co.uk / 2007-01-22 22:03:30 +0000:
>> Roman Neuhauser wrote:
>>> Can I see the rewrite log for a single request now? Please make sure
>>> it's only one request.
>> http://paste.lisp.org/display/35791
>
> Are you sure you added the NS flag? It looks like the RewriteRules
> are applied to the result of the original rewrite.
>
> And, I see TWO requests for addfriend:
>
> rewrite 'section/addfriend/will' -> 'index.php?cmd=section/addfriend&username=will'
> rewrite 'section/addfriend/templates/js/jquery.js' -> 'index.php?cmd=section/addfriend&username=templates/js/jquery.js'

and what's the bet that this second rewritten url is the bogey man here.

there is no way in hell that [a released version of] php is so borked that it's capable
returning a value from a function and then going on to running code that occurs in the function
after the return statement that returned the value. no way, no how.

>
>

attached mail follows:


On Tue, 2007-01-23 at 02:43 +0100, Jochem Maas wrote:
>
> there is no way in hell that [a released version of] php is so borked that it's capable
> returning a value from a function and then going on to running code that occurs in the function
> after the return statement that returned the value. no way, no how.

Borked for PHP sure... but there are languages where that semantic is
perfectly valid :)

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Robert Cummings wrote:
> On Tue, 2007-01-23 at 02:43 +0100, Jochem Maas wrote:
>> there is no way in hell that [a released version of] php is so borked that it's capable
>> returning a value from a function and then going on to running code that occurs in the function
>> after the return statement that returned the value. no way, no how.
>
> Borked for PHP sure...

it's the lang I know best, I think you'll agree that it's *highly* unlikely such an
extreme level of brokeness (as far as php is concerned) would creep into a release version.

> but there are languages where that semantic is
> perfectly valid :)

I would not have thought so but then again my skills and experience are somewhat
limited in the grand scheme of things.

you've twanged my interest, please name the language you were thinking of
when you wrote that last comment :-)

>
> Cheers,
> Rob.

attached mail follows:


On Tue, 2007-01-23 at 03:01 +0100, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Tue, 2007-01-23 at 02:43 +0100, Jochem Maas wrote:
> >> there is no way in hell that [a released version of] php is so borked that it's capable
> >> returning a value from a function and then going on to running code that occurs in the function
> >> after the return statement that returned the value. no way, no how.
> >
> > Borked for PHP sure...
>
> it's the lang I know best, I think you'll agree that it's *highly* unlikely such an
> extreme level of brokeness (as far as php is concerned) would creep into a release version.
>
> > but there are languages where that semantic is
> > perfectly valid :)
>
> I would not have thought so but then again my skills and experience are somewhat
> limited in the grand scheme of things.
>
> you've twanged my interest, please name the language you were thinking of
> when you wrote that last comment :-)

Well, my own BlobbieScript supports a retval keyword that returns a
value to the caller and then continues on as a separate thread. But I
can't take credit for the concept. I spoke with an imp of another MUD
that mentioned it in passing, so I implemented the functionality
realizing it's utility. So I know at least one other language supports
it, and not my own, but I'm not aware of it's name.

Why would you do it? Imagine a function in a game script that is invoked
for a return value, but upon probing for that return value an action is
triggered. Depending on when you want that action to trigger you can
either do it before returning the value or wait until afterwards. Some
languages would have you set up timed event handler (such as
setTimeout() in JavaScript), but why bother if you're already running...
instead just sleep until ready... this delayed action is what follows
the return value and removes the cumbersome nature of setting up an
event handler. The additional advantage of this method is you retain all
the variables of the current calling scope without having to either pass
them along or create a closure with an anonymous function.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Jochem Maas wrote:
>> rewrite 'section/addfriend/will' -> 'index.php?cmd=section/addfriend&username=will'
>> rewrite 'section/addfriend/templates/js/jquery.js' -> 'index.php?cmd=section/addfriend&username=templates/js/jquery.js'
>
> and what's the bet that this second rewritten url is the bogey man here.

Yeah it was - the JS library was being requested and rewritten to the
PHP file. Seems some data was being added to the variable in the
function before it was being checked empty and so not returning false as
it should have done.

Thanks for everyone's help.

David

attached mail follows:


> Sorry for troubling all again.
> I am trying to use the Pear DB_ldap for the above scripts.
>
> Does any one have any sample code for ldap_connect () ldap_search etc.

http://php.net/ldap_connect

http://php.net/ldap_search

Both pages have examples.

If you have a specific problem then post it.

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


On 1/23/07, Chris <dmagickgmail.com> wrote:
>
> > Sorry for troubling all again.
> > I am trying to use the Pear DB_ldap for the above scripts.
> >
> > Does any one have any sample code for ldap_connect () ldap_search etc.
>
> http://php.net/ldap_connect
>
> http://php.net/ldap_search
>
> Both pages have examples.
>
> If you have a specific problem then post it.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
Thanx for replying Chris.

I am in process to modify my existing php scripts to a more neater/compact code.

In current scripts certain code ( ldap_connect , ldap_bind , if connet
error show error page etc ) is repeated many times.

This makes the scripts very bulky and even small changes that need to
be done are very difficult to implement.

That's why I am looking for some thing with a ready functions for the
above which I can use. I believe PEAR DB_ldap has it. But very little
documentation is avaliable.

So I was searching for any sample scripts.

-----
My current script:
user edit page
<?php
require 'validate.php' // included on every page to check logged in user.

bind to ldap else error..

show a form to user to edit user details.

post to update script.

disconnect ldap.

?>

on update
<?php
validate user

bind to ldap else .....

check if any changes need to be done to the user .( compare before &
after values in the POST variables )
create the array for modfiy
do ldap_modify
in case error shout , else tell all is ok.

ldap_disconnect.
?>

The problem is, for separate edit pages I have written separate update
pages. Any new object to edit needs a new edit page & a relevent
update page.

I believe if I can use functions this can be reduced to just one
update page with fewer edit pages.

Very sorry for this long mail.

Thanx & Regards
Ram

attached mail follows:


I need PHP to find out if a jpeg file uses progressive encoding. None
of the standard exif or image functions seem to be able to tell me
that. (please correct me if I'm wrong)

Can anybody help me?

TIA

Gerry

attached mail follows:


I have a db field that contains zip codes separated by comas.

I am trying to get php to return all of the rows that contain a particular
zip code.

 

$query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";

$result = mysql_query($query)

or die ("could not connect to db");

$row = mysql_fetch_row($result);

 

 

this works if there is only one row that contains that zip code.

 

If there is more than one row that contains the zip, it returns 0 rows.
('It' being MYSQL that returns 0 rows. I checked this by running the query
directly to the DB)

 

Any ideas are very much appreciated.

 

Thanks,

 

Don

 

 

attached mail follows:


Don wrote:
> I have a db field that contains zip codes separated by comas.
>
> I am trying to get php to return all of the rows that contain a particular
> zip code.
>
>
>
> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
>
> $result = mysql_query($query)
>
> or die ("could not connect to db");
>
> $row = mysql_fetch_row($result);

http://php.net/mysql_fetch_assoc has a better example.

When there are many rows returned you need to loop to show them all:

while ($row = mysql_fetch_assoc($result)) {
   print_r($row);
}

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


I appreciate your quick response, but I think the problem I'm having is in
the query. Is WHERE MATCH () the proper format to use for getting multiple
rows from the DB? Or is there something else I'm missing?

Don wrote:
> I have a db field that contains zip codes separated by comas.
>
> I am trying to get php to return all of the rows that contain a particular
> zip code.
>
>
>
> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
>
> $result = mysql_query($query)
>
> or die ("could not connect to db");
>
> $row = mysql_fetch_row($result);

http://php.net/mysql_fetch_assoc has a better example.

When there are many rows returned you need to loop to show them all:

while ($row = mysql_fetch_assoc($result)) {
   print_r($row);
}

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


Don wrote:
> I appreciate your quick response, but I think the problem I'm having is in
> the query. Is WHERE MATCH () the proper format to use for getting multiple
> rows from the DB? Or is there something else I'm missing?

Please don't top post, it's hard to follow what's going on and who's
replied.

Sorry, I misread your email.

"Match against" is meant to be for fulltext searches, that includes some
limitations.

http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html

Specifically the last 3-4 paragraphs.

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


Don wrote:
> I have a db field that contains zip codes separated by comas.
>
> I am trying to get php to return all of the rows that contain a particular
> zip code.
>
>
>
> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
>
> $result = mysql_query($query)
>
> or die ("could not connect to db");
>
> $row = mysql_fetch_row($result);

http://php.net/mysql_fetch_assoc has a better example.

When there are many rows returned you need to loop to show them all:

while ($row = mysql_fetch_assoc($result)) {
   print_r($row);
}

Don wrote:
> I appreciate your quick response, but I think the problem I'm having
> is in the query. Is WHERE MATCH () the proper format to use for
> getting multiple rows from the DB? Or is there something else I'm
> missing?

Please don't top post, it's hard to follow what's going on and who's
replied.

Sorry, I misread your email.

"Match against" is meant to be for fulltext searches, that includes some
limitations.

http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html

Specifically the last 3-4 paragraphs.

~~~~~~~

Alright,

I learned 2 things....
What top post is....lol (sorry)

And don't' skim through the manual.... programming isn't like legos where
you can look at the picture and put it together....

query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip' in
Boolean mode)";

Made all the difference... I missed the part about stop words and had only 2
entries in my DB.

So thanks for pointing that out.

Don

attached mail follows:


Don wrote:
> I have a db field that contains zip codes separated by comas.
>
> I am trying to get php to return all of the rows that contain a particular
> zip code.
>
>
>
> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";

try this

$query = "SELECT * FROM info WHERE column LIKE '{$zip}'";

>
> $result = mysql_query($query)
>
> or die ("could not connect to db");
>
> $row = mysql_fetch_row($result);
>
>
>
>
>
> this works if there is only one row that contains that zip code.
>
>
>
> If there is more than one row that contains the zip, it returns 0 rows.
> ('It' being MYSQL that returns 0 rows. I checked this by running the query
> directly to the DB)
>
>
>
> Any ideas are very much appreciated.
>
>
>
> Thanks,
>
>
>
> Don
>
>
>
>
>
>

attached mail follows:


On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> Don wrote:
> > I have a db field that contains zip codes separated by comas.
> >
> > I am trying to get php to return all of the rows that contain a particular
> > zip code.
> >
> >
> >
> > $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
>
> try this
>
> $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";

I would use

$query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";

greets
Zoltán Németh

>
> >
> > $result = mysql_query($query)
> >
> > or die ("could not connect to db");
> >
> > $row = mysql_fetch_row($result);
> >
> >
> >
> >
> >
> > this works if there is only one row that contains that zip code.
> >
> >
> >
> > If there is more than one row that contains the zip, it returns 0 rows.
> > ('It' being MYSQL that returns 0 rows. I checked this by running the query
> > directly to the DB)
> >
> >
> >
> > Any ideas are very much appreciated.
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Don
> >
> >
> >
> >
> >
> >
>

attached mail follows:


On 1/23/07, Németh Zoltán <znemethalterationx.hu> wrote:
> On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> > Don wrote:
> > > I have a db field that contains zip codes separated by comas.
> > >
> > > I am trying to get php to return all of the rows that contain a particular
> > > zip code.
> > >
> > >
> > >
> > > $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
> >
> > try this
> >
> > $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";
>
> I would use
>
> $query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";

And how are you going to index that? That's going to be extremely slow
as the size of the table grows.

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
> On 1/23/07, Németh Zoltán <znemethalterationx.hu> wrote:
> > On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> > > Don wrote:
> > > > I have a db field that contains zip codes separated by comas.
> > > >
> > > > I am trying to get php to return all of the rows that contain a particular
> > > > zip code.
> > > >
> > > >
> > > >
> > > > $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
> > >
> > > try this
> > >
> > > $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";
> >
> > I would use
> >
> > $query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";
>
> And how are you going to index that? That's going to be extremely slow
> as the size of the table grows.
>

well, yes.

better solution is to not store the zip codes in one field with commas,
but in a separate table which relates to this one. and then you could
use a query like

$query = "SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
AND t2.zip = '{$zip}'";

greets
Zoltán Németh

attached mail follows:


Németh Zoltán wrote:
> On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
>> On 1/23/07, Németh Zoltán <znemethalterationx.hu> wrote:
>>> On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
>>>> Don wrote:
>>>>> I have a db field that contains zip codes separated by comas.
>>>>>
>>>>> I am trying to get php to return all of the rows that contain a particular
>>>>> zip code.
>>>>>
>>>>>
>>>>>
>>>>> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
>>>> try this
>>>>
>>>> $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";
>>> I would use
>>>
>>> $query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";
>> And how are you going to index that? That's going to be extremely slow
>> as the size of the table grows.
>>
>
> well, yes.
>
> better solution is to not store the zip codes in one field with commas,
> but in a separate table which relates to this one. and then you could
> use a query like
>
> $query = "SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
> AND t2.zip = '{$zip}'";
>
> greets
> Zoltán Németh
>
But, since the op is working with existing data, what is the performance
difference between using LIKE or LOCATE?

Pro's vs. Con's

attached mail follows:


On k, 2007-01-23 at 00:58 -0800, Jim Lucas wrote:
> Németh Zoltán wrote:
> > On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
> >> On 1/23/07, Németh Zoltán <znemethalterationx.hu> wrote:
> >>> On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> >>>> Don wrote:
> >>>>> I have a db field that contains zip codes separated by comas.
> >>>>>
> >>>>> I am trying to get php to return all of the rows that contain a particular
> >>>>> zip code.
> >>>>>
> >>>>>
> >>>>>
> >>>>> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
> >>>> try this
> >>>>
> >>>> $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";
> >>> I would use
> >>>
> >>> $query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";
> >> And how are you going to index that? That's going to be extremely slow
> >> as the size of the table grows.
> >>
> >
> > well, yes.
> >
> > better solution is to not store the zip codes in one field with commas,
> > but in a separate table which relates to this one. and then you could
> > use a query like
> >
> > $query = "SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
> > AND t2.zip = '{$zip}'";
> >
> > greets
> > Zoltán Németh
> >
> But, since the op is working with existing data, what is the performance
> difference between using LIKE or LOCATE?
>
> Pro's vs. Con's
>
>
>

oops I just made a simple performance test and the result showed me that
LIKE is faster (in my test it was twice as faster than LOCATE)

sorry for my ignorance, I did not know that

greets
Zoltán Németh

attached mail follows:


On 1/23/07, Jim Lucas <listscmsws.com> wrote:
> Németh Zoltán wrote:
> > On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
> >> On 1/23/07, Németh Zoltán <znemethalterationx.hu> wrote:
> >>> On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
> >>>> Don wrote:
> >>>>> I have a db field that contains zip codes separated by comas.
> >>>>>
> >>>>> I am trying to get php to return all of the rows that contain a particular
> >>>>> zip code.
> >>>>>
> >>>>>
> >>>>>
> >>>>> $query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";
> >>>> try this
> >>>>
> >>>> $query = "SELECT * FROM info WHERE column LIKE '{$zip}'";
> >>> I would use
> >>>
> >>> $query = "SELECT * FROM info WHERE LOCATE('{$zip}', column) > 0";
> >> And how are you going to index that? That's going to be extremely slow
> >> as the size of the table grows.
> >>
> >
> > well, yes.
> >
> > better solution is to not store the zip codes in one field with commas,
> > but in a separate table which relates to this one. and then you could
> > use a query like
> >
> > $query = "SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
> > AND t2.zip = '{$zip}'";
> >
> > greets
> > Zoltán Németh
> >
> But, since the op is working with existing data, what is the performance
> difference between using LIKE or LOCATE?
>
> Pro's vs. Con's

This is getting pretty OT but that's my fault... so I'll post this and
if anyone has any questions send them off-list ;)

This stuff isn't mysql specific, it should be the same across all types of db's.

This:

LIKE '{$zip}'

will be able to use an index on the field because there are no
wildcards involved, so it's much the same as field='{$zip}'. I have no
idea if databases can make this conversion internally, but in theory
it should be the same.

If it's like this:

like '{$zip}%'

that means $zip is at the start of the field and you could use a
partial index (eg on the first 10 characters of the field, search
relevant database docs for how to do that).

If it's like this:

like '%{$zip}'

then $zip is at the end of the field and you'd probably benefit from
creating an extra database field, reversing the last "X" characters,
creating an index and using that for searching (and create a database
trigger to keep it up to date).

If it's like this:

like '%{$zip}%'

there's not much of a chance for that to use an index because the
string can be anywhere in the field.

LOCATE will be much the same as this because it has to find the string
somewhere in the whole field, then return it's position. Actually it
will probably be a lot worse because of that.

Hopefully that makes things as clear as mud! ;)

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


I'm trying to figure out what the desired behavior is of using the
return function to bail out of an include page.

I did some testing, and this is what I concluded.

First, I created the following file:

<?php
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";
?>

I then called it as follows:
include('test.php');
include('test.php');
include('test.php');

The output is:
blah blah blah blah

Second, I changed the test.php file to be the following:

<?php
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";

function myFunc($test) {

}
?>

When I load the page now, it throws the following error: PHP Fatal
error: Cannot redeclare myfunc()

It appears that if there are functions in the include page that you
can't use return to bail out. What is the desired functionality in this
case? Is this a bug in how php handles it? or was return never designed
to be used this way?

Any thoughts are appreciated.

--
Aaron Axelsen
listsfrozenpc.net

Great hosting, low prices. Modevia Web Services LLC -- http://www.modevia.com

attached mail follows:


Aaron Axelsen wrote:
> I'm trying to figure out what the desired behavior is of using the
> return function to bail out of an include page.
>
> I did some testing, and this is what I concluded.
>
> First, I created the following file:
>
> <?php
> if (defined('TEST_LOADED')) {
> return;
> }
> define('TEST_LOADED',true);
> echo "blah blah blah blah<br/>";
> ?>
>
> I then called it as follows:
> include('test.php');
> include('test.php');
> include('test.php');
>
> The output is:
> blah blah blah blah
>
> Second, I changed the test.php file to be the following:
>
> <?php
> if (defined('TEST_LOADED')) {
> return;
> }
> define('TEST_LOADED',true);
> echo "blah blah blah blah<br/>";
>
> function myFunc($test) {
>
> }
> ?>
>
> When I load the page now, it throws the following error: PHP Fatal
> error: Cannot redeclare myfunc()
>
> It appears that if there are functions in the include page that you
> can't use return to bail out. What is the desired functionality in this
> case? Is this a bug in how php handles it? or was return never designed
> to be used this way?

It's not a bug.

When you include a file, the whole file is loaded in to memory.

Then php decides (based on your code decisions) about what to do with
all of that code.

See http://www.php.net/include, specifically:

If there are functions defined in the included file, they can be used in
the main file independent if they are before return() or after. If the
file is included twice, PHP 5 issues fatal error because functions were
already declared, while PHP 4 doesn't complain about functions defined
after return().

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


Aaron Axelsen wrote:
> I'm trying to figure out what the desired behavior is of using the
> return function to bail out of an include page.
>
> I did some testing, and this is what I concluded.
>
> First, I created the following file:
>
> <?php
> if (defined('TEST_LOADED')) {
> return;
> }
> define('TEST_LOADED',true);
> echo "blah blah blah blah<br/>";
> ?>
>
> I then called it as follows:
> include('test.php');
> include('test.php');
> include('test.php');
>
> The output is:
> blah blah blah blah
>
> Second, I changed the test.php file to be the following:
>
> <?php
> if (defined('TEST_LOADED')) {
> return;
> }
> define('TEST_LOADED',true);
> echo "blah blah blah blah<br/>";
>
> function myFunc($test) {
>
> }
> ?>
>
> When I load the page now, it throws the following error: PHP Fatal
> error: Cannot redeclare myfunc()
>
> It appears that if there are functions in the include page that you
> can't use return to bail out. What is the desired functionality in this
> case? Is this a bug in how php handles it? or was return never designed
> to be used this way?
>
> Any thoughts are appreciated.

Hi Aaron,

Unfortunately, the only way you can prevent the parse error is to use a
conditional function, return won't cut is, as the file is re-parsed
every time you include it, and all classes/functions are re-parsed
before the run-time if() is processed.

<?php
if (!function_exists('myFunc')) {
function myFunc($test) {
}
}
?>

This will work, but does slow down opcode caches and introduce potential
instability with them, as the added complexity is very unfriendly to
optimization.

Of course, you are much better off taking advantage of the
include_once[1] language construct, or separating your
need-to-be-included-many-times file from any function or class definitions.

Greg

http://www.php.net/include_once

attached mail follows:


-----Original Message-----
From: Aaron Axelsen [mailto:listsfrozenpc.net]
Sent: 23 January 2007 06:12
To: php-generallists.php.net
Subject: [PHP] using return in include files

I'm trying to figure out what the desired behavior is of using the
return function to bail out of an include page.

I did some testing, and this is what I concluded.

First, I created the following file:

<?php
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";
?>

I then called it as follows:
include('test.php');
include('test.php');
include('test.php');

The output is:
blah blah blah blah

Second, I changed the test.php file to be the following:

<?php
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";

function myFunc($test) {

}
?>

When I load the page now, it throws the following error: PHP Fatal
error: Cannot redeclare myfunc()

It appears that if there are functions in the include page that you
can't use return to bail out. What is the desired functionality in this
case? Is this a bug in how php handles it? or was return never designed
to be used this way?

Any thoughts are appreciated.

--
Aaron Axelsen
listsfrozenpc.net

------------------------------------

Include works as though the "include" statement line is replaced by the code
that is being included. So try the following exercise and it should become
obvious why you're getting that error: copy-and-paste the code from test.php
into the code that "includes" test.php for each line that includes test.php,
and then delete each of those include lines (I'll comment them out). You end
up with:

<?php
// include('test.php');
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";

function myFunc($test) {

}

// include('test.php');
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";

function myFunc($test) {

}

// include('test.php');
if (defined('TEST_LOADED')) {
        return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";

function myFunc($test) {

}
?>

Run that and you should get exactly the same error. Interestingly under php4
neither your code nor my expanded version of your code throws an error, so I
assume you're using php5?

If you're trying to avoid including the file more than once you could use
"include_once", but I've had problems with that - the file was previously
included but not in the same scope, so it wasn't included second time it was
called and yet none of the included file's contents existed. The way I got
round it was by assigning a value in the include file, and then testing for
that value before including the file.

For example:

test.php
<?php
$testphp_loaded = TRUE; // <- must be outside any function or braces
.
.
.
?>

main.php
<?php
if (!$testphp_loaded) {
    require('test.php');
}
?>

You can't use a define for this because it has a much wider scope and you
end up with the same problem as using "include_once".

Arno

attached mail follows:


Hello php developers:
I am having a problem with the following code:
OS: FreeBSD v6.0
Apache 1.3.34
php 5.1.2
-> $cont is an array produced from opening and reading a
directory:
for($i = 0; $i < count($cont); $i++)
      {
        print $cont[$i].'<br>';
         if(is_file($cont[$i]))
           {
              print "is file: ".$cont[$i].'<br>';
              //array_push($files, $cont[$i]);
             }
        else if(is_dir($cont[$i]))
             {
                 print "is dir: ".$cont[$i]."<br>";
                  //array_push($dirs, $cont[$i]);
              }
       }

The print statements produce the following:

collections
groups
in
index.php
lists.php
new_multi.php
new_single.php
out
pref_code
pref_funct.php
process.php
requests
rlists
routing.php
send.php
steps.php
store
templates

is dir: templates <- only directory recognized (extra line breaks
added here for readability)

usr_config.php
usr_pref.php

everything without an extension is a directory
You will notice that the only directory detected
by this code is templates. There are no files
detected by this code. Does this have something
to do with stat cache? I want to make one array
with directories and one array with files. I can't
see any syntax or logic problems.
Thanks in advance;
JK

attached mail follows:


jekillen wrote:
> Hello php developers:
> I am having a problem with the following code:
> OS: FreeBSD v6.0
> Apache 1.3.34
> php 5.1.2
> -> $cont is an array produced from opening and reading a
> directory:
> for($i = 0; $i < count($cont); $i++)
> {
> print $cont[$i].'<br>';
> if(is_file($cont[$i]))
> {
> print "is file: ".$cont[$i].'<br>';
> //array_push($files, $cont[$i]);
> }
> else if(is_dir($cont[$i]))
> {
> print "is dir: ".$cont[$i]."<br>";
> //array_push($dirs, $cont[$i]);
> }
> }

I'd be guessing it's a path issue.

Try prefixing the is_dir and is_file calls with the path to the
directory they are in:

$basedir = '/whatever';

for($i = 0; $i < count($cont); $i++) {
   $fullpath = $basedir . '/' . $cont[$i];
   if (is_file($fullpath)) {
   .....
}

--
Postgresql & php tutorials
http://www.designmagick.com/

attached mail follows:


Haven't really looked at it - but elseif is one word - or do you mean
else then an if...

Respectfully,
Ligaya Turmelle

-----Original Message-----
From: jekillen [mailto:jekillenprodigy.net]
Sent: Tuesday, January 23, 2007 4:03 PM
To: PHP General List
Subject: [PHP] having trouble with is_file() and is_dir() on 5.1.2

Hello php developers:
I am having a problem with the following code:
OS: FreeBSD v6.0
Apache 1.3.34
php 5.1.2
-> $cont is an array produced from opening and reading a
directory:
for($i = 0; $i < count($cont); $i++)
      {
        print $cont[$i].'<br>';
         if(is_file($cont[$i]))
           {
              print "is file: ".$cont[$i].'<br>';
              //array_push($files, $cont[$i]);
             }
        else if(is_dir($cont[$i]))
             {
                 print "is dir: ".$cont[$i]."<br>";
                  //array_push($dirs, $cont[$i]);
              }
       }

The print statements produce the following:

collections
groups
in
index.php
lists.php
new_multi.php
new_single.php
out
pref_code
pref_funct.php
process.php
requests
rlists
routing.php
send.php
steps.php
store
templates

is dir: templates <- only directory recognized (extra line breaks added
here for readability)

usr_config.php
usr_pref.php

everything without an extension is a directory You will notice that the
only directory detected by this code is templates. There are no files
detected by this code. Does this have something to do with stat cache? I
want to make one array with directories and one array with files. I
can't see any syntax or logic problems.
Thanks in advance;
JK

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

attached mail follows:


> everything without an extension is a directory
> You will notice that the only directory detected
> by this code is templates. There are no files
> detected by this code. Does this have something
> to do with stat cache? I want to make one array
> with directories and one array with files. I can't
> see any syntax or logic problems.
> Thanks in advance;
> JK
>

As far as I know is_dir and is_file require a full path , as chris
mentioned, how are you populating $cont;

clive

attached mail follows:


On Jan 22, 2007, at 10:20 PM, Chris wrote:

> jekillen wrote:
>> Hello php developers:
>> I am having a problem with the following code:
>> OS: FreeBSD v6.0
>> Apache 1.3.34
>> php 5.1.2
>> -> $cont is an array produced from opening and reading a
>> directory:
>> for($i = 0; $i < count($cont); $i++)
>> {
>> print $cont[$i].'<br>';
>> if(is_file($cont[$i]))
>> {
>> print "is file: ".$cont[$i].'<br>';
>> //array_push($files, $cont[$i]);
>> }
>> else if(is_dir($cont[$i]))
>> {
>> print "is dir: ".$cont[$i]."<br>";
>> //array_push($dirs, $cont[$i]);
>> }
>> }
>
>
> I'd be guessing it's a path issue.
>
> Try prefixing the is_dir and is_file calls with the path to the
> directory they are in:
>
> $basedir = '/whatever';
>
> for($i = 0; $i < count($cont); $i++) {
> $fullpath = $basedir . '/' . $cont[$i];
> if (is_file($fullpath)) {
> .....
> }
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/

Ok, I hope I can get this to work. The code
I copied here was code that was in the directory
reading loop, where I would have guess that
it would have the path info, but it did the same
thing. But I will take you suggestion.
Thanks for the reply;
JK

attached mail follows:


try using this, from php manual, clive

<?php

echo filetype('/etc/passwd'); // file
echo filetype('/etc/'); // dir

?>

attached mail follows:


# jekillenprodigy.net / 2007-01-22 23:26:06 -0800:
> On Jan 22, 2007, at 10:20 PM, Chris wrote:
> >$basedir = '/whatever';
> >
> >for($i = 0; $i < count($cont); $i++) {
> > $fullpath = $basedir . '/' . $cont[$i];
> > if (is_file($fullpath)) {
> > .....
> >}
>
> Ok, I hope I can get this to work. The code
> I copied here was code that was in the directory
> reading loop, where I would have guess that
> it would have the path info, but it did the same
> thing.

readdir() returns only a basename, you need to be in
the directory you're traversing (opendir(".") or
opendir($dir); chdir($dir)). Compare this:

function is_file() { return test -f $1; }
function is_dir() { return test -d $1; }
function file_exists() { return test -e $1; }

mkdir child
touch child/a child/b child/c
echo current directory: $(pwd)
for f in $(ls child); do
  is_file $f && echo is_file $f
  is_dir $f && echo is_dir $f
  file_exists $f && echo file_exists $f
  is_file child/$f && echo is_file child/$f
  is_dir child/$f && echo is_dir child/$f
  file_exists child/$f && echo file_exists child/$f
done

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


# neuhausersigpipe.cz / 2007-01-23 09:14:15 +0000:
> readdir() returns only a basename, you need to be in
> the directory you're traversing (opendir(".") or
> opendir($dir); chdir($dir))

... or prefix the basenames with the path you used in the
opendir() call.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


Thank you for your help. I see what you are doing different. I don't
understand how the quotient works there. I will sometime. I also don't
understand the HEREDOC concept.

I wanted colors alternating to allow for a better read.

I still have not solved the problem with listing the genre in its own row,
alone at the beginning of each section of genre (the start of each unique
genre which is the ORDER BY in the statement).

Thanks for the code. I need to learn how to write more eloquently like you.

If anyone can figure out the a row listing for the genres, that would be
soooo cool.

"Jim Lucas" <listscmsws.com> wrote in message
news:45B4E882.5050905cmsws.com...
> Here is my rendition of your script. Give it a shot...
>
> Let me know if you have any question about what is going on.
>
> I was curious, what is the point of having the alternating column colors?
> Was that your intention?
>
> <?php
>
> function invlistONE(){
> dbconnect('connect');
> $invlist = mysql_query("SELECT * FROM sp_dvd
> ORDER BY dvdGenre");
>
>
> echo <<<HEREDOC
>
> <style type="text/css">
> .dvdDisplay th {
> font-size: 9pt;
> text-align: left;
> }
> .dvdDisplay td {
> font-size: 8pt;
> }
> </style>
>
> <table cellspacing="0" id='dvdDisplay">
> <thead>
> <tr>
> <th width="20" class="body">DVD ID</th>
> <th width="225">TITLE</th>
> <th width="75" class="body">GENRE 1</th>
> <th width="75">GENRE 2</th>
> <th width="75" class="body">GENRE 3</th>
> <th width="10">ACT</th>
> <th width="10" class="body">QTY</th>
> <th width="10">BCK</b></th>
> <th width="10" class="body">HLD</th>
> <th width="10">INC</b></th>
> <th width="50" class="body">OG USR</th>
> <th width="30">OUT DATE</th>
> <th width="55" class="body">OUT USR</th>
> <th width="30">IN DATE</th>
> <th width="50" class="body">IN USR</th>
> <th width="10">CY</th>
> </tr>
> </thead>
> <tbody>
>
> HEREDOC;
>
> $count = 0;
> while ( $row = mysql_fetch_array( $invlist ) ) {
>
> if ( $count % 1 ) {
> $rowColor = '#c1c1c1';
> } else {
> $rowColor = '';
> }
>
> echo <<<HEREDOC
>
> <tr bgcolor="{$rowColor}">
> <td class='body'>{$row['dvdId']</td>
> <td>{$row['dvdTitle']}</td>
> <td class='body'>{$row['dvdGenre']}</td>
> <td>{$row['dvdGenre2']}</td>
> <td class='body'>{$row['dvdGenre3']}</td>
> <td>{$row['dvdActive']}</td>
> <td class='body'>{$row['dvdOnHand']}</td>
> <td>{$row['backordered']}</td>
> <td class='body'>{$row['dvdHoldRequests']}</td>
> <td>{$row['incomingInverntory']}</td>
> <td class='body'>{$row['ogUserId']}</td>
> <td>{$row['outDate']}</td>
> <td class='body'>{$row['outUserId']}</td>
> <td>{$row['inDate']}</td>
> <td class='body'>{$row['inUserId']}</td>
> <td>{$row['cycles']}</td>
> </tr>
>
> HEREDOC;
>
> $count++;
>
> echo '</tbody></table>';
> }
> }
>
> ?>

attached mail follows:


# brandontruzul.com / 2007-01-22 22:55:50 -0800:
> "Jim Lucas" <listscmsws.com> wrote in message
> news:45B4E882.5050905cmsws.com...
> > $count = 0;
> > while ( $row = mysql_fetch_array( $invlist ) ) {
> >
> > if ( $count % 1 ) {
> > $rowColor = '#c1c1c1';
> > } else {
> > $rowColor = '';
> > }
> >
> > echo <<<HEREDOC
> >
> > <tr bgcolor="{$rowColor}">
> > <td class='body'>{$row['dvdId']</td>
> > <td>{$row['dvdTitle']}</td>
> > <td class='body'>{$row['dvdGenre']}</td>
> > <td>{$row['dvdGenre2']}</td>
> > <td class='body'>{$row['dvdGenre3']}</td>
> > <td>{$row['dvdActive']}</td>
> > <td class='body'>{$row['dvdOnHand']}</td>
> > <td>{$row['backordered']}</td>
> > <td class='body'>{$row['dvdHoldRequests']}</td>
> > <td>{$row['incomingInverntory']}</td>
> > <td class='body'>{$row['ogUserId']}</td>
> > <td>{$row['outDate']}</td>
> > <td class='body'>{$row['outUserId']}</td>
> > <td>{$row['inDate']}</td>
> > <td class='body'>{$row['inUserId']}</td>
> > <td>{$row['cycles']}</td>
> > </tr>
> >
> > HEREDOC;
> >
> > $count++;
> >
> > echo '</tbody></table>';
> > }
> > }
> >

> I don't understand how the quotient works there. I will sometime.
> I also don't understand the HEREDOC concept.
>
> I wanted colors alternating to allow for a better read.
 
Ignore the heredoc thing, the "quotient" (remainder after division)
works just like it worked in your math class, but it should be

    if ( $count % 2 ) {
        $rowColor = '#c1c1c1';
    } else {
        $rowColor = '';
    }

Although I'd use

    $rowColors = array('', '#c1c1c1');
    ...
    $rowColor = $rowColors[$count % 2];

> I still have not solved the problem with listing the genre in its own row,
> alone at the beginning of each section of genre (the start of each unique
> genre which is the ORDER BY in the statement).
>
> Thanks for the code. I need to learn how to write more eloquently like you.
>
> If anyone can figure out the a row listing for the genres, that would be
> soooo cool.

You want something like this?

genre | #id | title | #id | title | #id | title
-------+-----+---------------+-----+---------------+-----+--------
horror | 123 | Scary Movie 1 | 456 | Scary Movie 2 | ... | ....
comedy | 234 | Funny Movie 1 | 456 | Funny Movie 2 | ... | ....

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


What I WANT to see is something like this

DVD ID | TITLE | GENRE 1 | GENRE 2 | GENRE 3 | ACT |
QTY BCK | HLD | INC | OG USR | OUT DATE | OUT USR | IN DATE |
IN USR CY

GENRE: ACTION - 1 TITLES
20860023 | Movie name | ACTION | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0

GENRE: COMEDY - 2 TITLES
20860023 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
20860006 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0

What I HAVE RIGHT NOW IS:

DVD ID | TITLE | GENRE 1 | GENRE 2 | GENRE 3 | ACT |
QTY BCK | HLD | INC | OG USR | OUT DATE | OUT USR | IN DATE |
IN USR CY

20860023 | Movie name | ACTION | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
20860023 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
20860006 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0

Thanks for you help :) I appreciate it very much.

"Roman Neuhauser" <neuhausersigpipe.cz> wrote in message
news:20070123081704.GA1063dagan.sigpipe.cz...
># brandontruzul.com / 2007-01-22 22:55:50 -0800:
>> "Jim Lucas" <listscmsws.com> wrote in message
>> news:45B4E882.5050905cmsws.com...
>> > $count = 0;
>> > while ( $row = mysql_fetch_array( $invlist ) ) {
>> >
>> > if ( $count % 1 ) {
>> > $rowColor = '#c1c1c1';
>> > } else {
>> > $rowColor = '';
>> > }
>> >
>> > echo <<<HEREDOC
>> >
>> > <tr bgcolor="{$rowColor}">
>> > <td class='body'>{$row['dvdId']</td>
>> > <td>{$row['dvdTitle']}</td>
>> > <td class='body'>{$row['dvdGenre']}</td>
>> > <td>{$row['dvdGenre2']}</td>
>> > <td class='body'>{$row['dvdGenre3']}</td>
>> > <td>{$row['dvdActive']}</td>
>> > <td class='body'>{$row['dvdOnHand']}</td>
>> > <td>{$row['backordered']}</td>
>> > <td class='body'>{$row['dvdHoldRequests']}</td>
>> > <td>{$row['incomingInverntory']}</td>
>> > <td class='body'>{$row['ogUserId']}</td>
>> > <td>{$row['outDate']}</td>
>> > <td class='body'>{$row['outUserId']}</td>
>> > <td>{$row['inDate']}</td>
>> > <td class='body'>{$row['inUserId']}</td>
>> > <td>{$row['cycles']}</td>
>> > </tr>
>> >
>> > HEREDOC;
>> >
>> > $count++;
>> >
>> > echo '</tbody></table>';
>> > }
>> > }
>> >
>
>> I don't understand how the quotient works there. I will sometime.
>> I also don't understand the HEREDOC concept.
>>
>> I wanted colors alternating to allow for a better read.
>
> Ignore the heredoc thing, the "quotient" (remainder after division)
> works just like it worked in your math class, but it should be
>
> if ( $count % 2 ) {
> $rowColor = '#c1c1c1';
> } else {
> $rowColor = '';
> }
>
> Although I'd use
>
> $rowColors = array('', '#c1c1c1');
> ...
> $rowColor = $rowColors[$count % 2];
>
>> I still have not solved the problem with listing the genre in its own
>> row,
>> alone at the beginning of each section of genre (the start of each unique
>> genre which is the ORDER BY in the statement).
>>
>> Thanks for the code. I need to learn how to write more eloquently like
>> you.
>>
>> If anyone can figure out the a row listing for the genres, that would be
>> soooo cool.
>
> You want something like this?
>
> genre | #id | title | #id | title | #id | title
> -------+-----+---------------+-----+---------------+-----+--------
> horror | 123 | Scary Movie 1 | 456 | Scary Movie 2 | ... | ....
> comedy | 234 | Funny Movie 1 | 456 | Funny Movie 2 | ... | ....
>
>
> --
> How many Vietnam vets does it take to screw in a light bulb?
> You don't know, man. You don't KNOW.
> Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


Brandon Bearden wrote:
> What I WANT to see is something like this
>
> DVD ID | TITLE | GENRE 1 | GENRE 2 | GENRE 3 | ACT |
> QTY BCK | HLD | INC | OG USR | OUT DATE | OUT USR | IN DATE |
> IN USR CY
>
> GENRE: ACTION - 1 TITLES
> 20860023 | Movie name | ACTION | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
>
> GENRE: COMEDY - 2 TITLES
> 20860023 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
> 20860006 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
>
>
>
>
> What I HAVE RIGHT NOW IS:
>
> DVD ID | TITLE | GENRE 1 | GENRE 2 | GENRE 3 | ACT |
> QTY BCK | HLD | INC | OG USR | OUT DATE | OUT USR | IN DATE |
> IN USR CY
>
> 20860023 | Movie name | ACTION | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
> 20860023 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
> 20860006 | Movie name | COMEDY | | | 1 | 1 | 0 | 10000000 |
> 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0
>
>
> Thanks for you help :) I appreciate it very much.
>
>
> "Roman Neuhauser" <neuhausersigpipe.cz> wrote in message
> news:20070123081704.GA1063dagan.sigpipe.cz...
>> # brandontruzul.com / 2007-01-22 22:55:50 -0800:
>>> "Jim Lucas" <listscmsws.com> wrote in message
>>> news:45B4E882.5050905cmsws.com...
>>>> $count = 0;
>>>> while ( $row = mysql_fetch_array( $invlist ) ) {
>>>>
>>>> if ( $count % 1 ) {
>>>> $rowColor = '#c1c1c1';
>>>> } else {
>>>> $rowColor = '';
>>>> }
>>>>
>>>> echo <<<HEREDOC
>>>>
>>>> <tr bgcolor="{$rowColor}">
>>>> <td class='body'>{$row['dvdId']</td>
>>>> <td>{$row['dvdTitle']}</td>
>>>> <td class='body'>{$row['dvdGenre']}</td>
>>>> <td>{$row['dvdGenre2']}</td>
>>>> <td class='body'>{$row['dvdGenre3']}</td>
>>>> <td>{$row['dvdActive']}</td>
>>>> <td class='body'>{$row['dvdOnHand']}</td>
>>>> <td>{$row['backordered']}</td>
>>>> <td class='body'>{$row['dvdHoldRequests']}</td>
>>>> <td>{$row['incomingInverntory']}</td>
>>>> <td class='body'>{$row['ogUserId']}</td>
>>>> <td>{$row['outDate']}</td>
>>>> <td class='body'>{$row['outUserId']}</td>
>>>> <td>{$row['inDate']}</td>
>>>> <td class='body'>{$row['inUserId']}</td>
>>>> <td>{$row['cycles']}</td>
>>>> </tr>
>>>>
>>>> HEREDOC;
>>>>
>>>> $count++;
>>>>
>>>> echo '</tbody></table>';
>>>> }
>>>> }
>>>>
>>> I don't understand how the quotient works there. I will sometime.
>>> I also don't understand the HEREDOC concept.
>>>
>>> I wanted colors alternating to allow for a better read.
>> Ignore the heredoc thing, the "quotient" (remainder after division)
>> works just like it worked in your math class, but it should be
>>
>> if ( $count % 2 ) {
>> $rowColor = '#c1c1c1';
>> } else {
>> $rowColor = '';
>> }
>>
>> Although I'd use
>>
>> $rowColors = array('', '#c1c1c1');
>> ...
>> $rowColor = $rowColors[$count % 2];
>>
>>> I still have not solved the problem with listing the genre in its own
>>> row,
>>> alone at the beginning of each section of genre (the start of each unique
>>> genre which is the ORDER BY in the statement).
>>>
>>> Thanks for the code. I need to learn how to write more eloquently like
>>> you.
>>>
>>> If anyone can figure out the a row listing for the genres, that would be
>>> soooo cool.
>> You want something like this?
>>
>> genre | #id | title | #id | title | #id | title
>> -------+-----+---------------+-----+---------------+-----+--------
>> horror | 123 | Scary Movie 1 | 456 | Scary Movie 2 | ... | ....
>> comedy | 234 | Funny Movie 1 | 456 | Funny Movie 2 | ... | ....
>>
>>
>> --
>> How many Vietnam vets does it take to screw in a light bulb?
>> You don't know, man. You don't KNOW.
>> Cause you weren't THERE. http://bash.org/?255991
>

This should give you an idea of what you should have for displaying the
header/genre/section name

$oldGenre = '';
while( $row = fetch_row() ) {
     if ( $oldGenre != $row['genre'] ) {
         echo '<tr><th align="left" colspan="16">'.
                  $row['genre'].'</td></tr>';
         $oldGenre = $row['genre'];
     }
     // format the following with your table
     print_r($row);
}

Also, be warned, I noticed that I missed something in my first reply to
you. I have the closing table tag inside the while loop. So you need
to move that outside the while loop.

Jim