php-general Digest 30 Jul 2007 06:21:13 -0000 Issue 4932

Topics (messages 259773 through 259795):

Re: PDO_SQLite Transactions
        259773 by: Nathan Nobbe

Re: About XSL Transformation
        259774 by: Nathan Nobbe
        259781 by: Kelvin Park
        259788 by: Andrew Ballard

Re: Rules of Engagement
        259775 by: Nathan Nobbe
        259778 by: Colin Guthrie
        259783 by: Tom Ray [Lists]
        259793 by: Micky Hulse

Re: Profile / Debug w/o server modification?
        259776 by: Nathan Nobbe

PHP Rating system
        259777 by: Chris Carter

Re: Authentication
        259779 by: Stut

Re: need insights on encrypting and uploading ASCII file using PHP
        259780 by: Stut

Re: Pirate PHP books online?
        259782 by: Tom Ray [Lists]
        259790 by: Larry Garfield

Re: Dealing with ImageMagick from PHP
        259784 by: Eric Holt (PHP List)
        259787 by: Al

Bizarre array create error
        259785 by: Ken Tozier
        259786 by: Ken Tozier
        259792 by: Tom Ray [Lists]
        259794 by: Ken Tozier
        259795 by: Paul Novitski

Re: HTML Email Composing Problem.
        259789 by: Chris

php not working anymore in IIS
        259791 by: Guus Ellenkamp

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 ---
i had this same problem when trying to do a select directly after an insert
w/ pdo + sqlite3 transactions.
solution in that case was to use last_insert_id (or whatever the actual pdo
method is called, cant remember
and too lazy to lookup, atm :))
anyway if you want to do an update after an insert just use a trigger.

-nathan

On 7/29/07, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
>
> I was indeed trying to update the record I just inserted, the thing is
> though, if I remove all other queries and keep just
> PDO->beginTransaction();
> PDO->prepare();
> PDOstatement->execute();
> PDOstatement->closeCursor();
> PDO->commit();
>
> it still returns such an error. Which is very odd indeed...
>
> As for what I'm trying, it's true that this wasn't the best way of doing
> it, but there's actually more code involved with slightly different
> (read: more) changes being done and retrieved from various (non-PDO
> SQLite db) places.
>
> I've removed the Transactions and it works fine =/
>
> - Tul
>
> Richard Lynch wrote:
> > I suspect that you are trying to update the record you just inserted.
> >
> > That may just not be possible in the transaction model, for whatever
> > internal purposes.
> >
> > It also seems kind of backwards to me at least.
> >
> > Why not just do the file move and error checking before you even
> > bother to insert, and then do a single statement, which won't even
> > need a transaction, since any one statement is atomic.
> >
> > Perhaps I'm missing something, but it seems like you've needlessly
> > complicated the DB side of things.
> >
> > On Sat, July 28, 2007 8:57 pm, M. Sokolewicz wrote:
> >> I've been having this problem for a while now,
> >> when I use transactions in SQLite with PDO it stalls on me with an
> >> error
> >> stating my statements are in progress.
> >> I've tried closing all cursors to my statements, but that does not
> >> seem
> >> to resolve this for me. This is my code,
> >> (obviously shortened quite a bit)
> >>
> >> I hope someone could help me figure out what's going wrong, could it
> >> be
> >> that I can't run an update yet because
> >> the transaction has not been commited yet?? (sounds a bit odd to me)
> >>
> >> <?php
> >> // setup an SQLite db connection via PDO, this is in $db
> >> try {
> >>      // $fileName, $fileDesc and $fileType are all existing, cleaned,
> >> checked values
> >>      $statement = $db->prepare('INSERT INTO Files (file_name,
> file_desc,
> >> file_type, file_filename) VALUES (?, ?, ?, ?)');
> >>      $statement->execute(array($fileName, $fileDesc, $fileType, ''));
> >>
> >>      $id = $db->lastInsertId();
> >>
> >>      $statement->closeCursor();
> >>
> >>      $res = move_uploaded_file($tmp_file, $new_file);
> >>
> >>      if($res === false) {
> >>          $db->rollBack();
> >>
> >>          echo 'error';
> >>          exit;
> >>      } else {
> >>          $statement = $db->prepare('UPDATE Files SET file_filename=?
> WHERE
> >> file_id=?');
> >>          $statement->execute(array($new_file, $id));
> >>
> >>          $statement->closeCursor();
> >>
> >>          OG::$db->commit();
> >>      }
> >> } catch(Exception $e) {
> >>      var_dump($e);
> >> }
> >>
> >> And the Exception I recieve (there is only one commit in the file, due
> >> to shortening for posting
> >> the line listed here is incorrect):
> >>
> >> object(PDOException)#7 (7) {
> >>    ["message:protected"]=>
> >>    string(88) "SQLSTATE[HY000]: General error: 1 cannot commit
> >> transaction - SQL statements in progress"
> >>    ["string:private"]=>
> >>    string(0) ""
> >>    ["code:protected"]=>
> >>    string(5) "HY000"
> >>    ["file:protected"]=>
> >>    string(43) "/home/tularis/public_html/t/createFile.php"
> >>    ["line:protected"]=>
> >>    int(95)
> >>    ["trace:private"]=>
> >>    array(1) {
> >>      [0]=>
> >>      array(6) {
> >>        ["file"]=>
> >>        string(43) "/home/tularis/public_html/t/createFile.php"
> >>        ["line"]=>
> >>        int(95)
> >>        ["function"]=>
> >>        string(6) "commit"
> >>        ["class"]=>
> >>        string(3) "PDO"
> >>        ["type"]=>
> >>        string(2) "->"
> >>        ["args"]=>
> >>        array(0) {
> >>        }
> >>      }
> >>    }
> >>    ["errorInfo"]=>
> >>    array(3) {
> >>      [0]=>
> >>      string(5) "HY000"
> >>      [1]=>
> >>      int(1)
> >>      [2]=>
> >>      string(54) "cannot commit transaction - SQL statements in
> >> progress"
> >>    }
> >> }
> >>
> >> --
> >> 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 ---
build or modify the xml w/ php.
or pickup a book on xsl :)

-nathan

On 7/29/07, Kelvin Park <[EMAIL PROTECTED]> wrote:
>
> I have an XML file with 10 products with their registered dates(dates
> when they were created).
> My XSL code is set so that it sorts the products in descending
> order(latest to oldest) by registered dates.
> I tried to declare xsl:variable to increment within xsl:for-each,
> however I ran in to some dead ends.
> How do I print only the 5 latest products?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Nathan Nobbe wrote:
this is basically a design decision on your part. since you are working w/ 2 programming languages, ie. php and xsl, you will need to determine how much logic is implemented in each language. i would recommend you devise a scheme early on in your application lifetime and stay consitent w/ the decisions
you make.
it will save you headaches in the long run.

-nathan

On 7/29/07, *Kelvin Park* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Nathan Nobbe wrote:
    > build or modify the xml w/ php.
    > or pickup a book on xsl :)
    >
    > -nathan
    >
    > On 7/29/07, *Kelvin Park* <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
    > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
    wrote:
    >
    >     I have an XML file with 10 products with their registered
    dates(dates
    >     when they were created).
    >     My XSL code is set so that it sorts the products in descending
    >     order(latest to oldest) by registered dates.
    >     I tried to declare xsl:variable to increment within
    xsl:for-each,
    >     however I ran in to some dead ends.
    >     How do I print only the 5 latest products?
    >
    >     --
    >     PHP General Mailing List (http://www.php.net/)
    >     To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >
    Thanks!

    I checked out sitepoint's XSL book, and figured it out. I tried to
    do it
    with PHP, for me it seemed just a little bit more work than XSL
    transformation.


Since I'm not very familiar with XSL most of my applications are in PHP and XML (parsed from MYSQL). I have the current project's design planned out with just PHP/XML, however I felt like it was more convenient to just do the latest item print out part with XSL (couple of files). I might run in to some challenges when I get to pagination, I was thinking whether I should deviate a little bit from the plan to create XML/XSL pagination of list of items. This might just become all hybrid code with PHP and XSL, which I'm not looking forward to have.
--- End Message ---
--- Begin Message ---
> I tried to declare xsl:variable to increment within xsl:for-each,
> however I ran in to some dead ends.

Variables in XSL are not most programmers think of when they hear the
term "variable". They are variable in the sense that they can be
assigned a value at run-time, but they are really more like constants.
Once set, they can't be changed.

> How do I print only the 5 latest products?

Assuming you've correctly ordered the products by date (dates are
handled as strings in XSL, so you'll want to make sure you're using
the correct date format to get them to sort correctly), you can add
something like "... and position() &lt;= 5" in your node test.

--- End Message ---
--- Begin Message ---
gmail seems to consume these 'double replies' transparently w/ its
'conversations'.

i never notice them :)

sorry to everyone who gets hit w/ the extra mail when i hit reply-to-all.

youll have to forgive my laziness, its just easier that way.

-nathan

On 7/29/07, Lester Caine <[EMAIL PROTECTED]> wrote:
>
> Daniel Brown wrote:
> >     As a relatively-new contributor to this list (read: under 2
> > years), I realize that I have no business requesting a change, but
> > I'll breech etiquette and hope for the best.
> >
> >     Can we update the filters on the list to have the reply-to address
> > header marked to the php-general address?
>
> At the risk of extending the religious war ....
>
> I'm with you Daniel, but I think it has been decided that what we ACTUALLY
> need is a fix at the reception end. Some email clients will allow you to
> set a
> reply address for a folder ( apparently ) which is actually what *I* could
> do
> with, so all [PHP] email goes in the php-general folder, and when I hit
> reply
> I get a list reply address, just like I get a news list address on news
> folders. Unfortunately the other religious war erupts when you ask for
> that at
> the client end and many of the same people who INSIST that replies should
> be
> changed to be private then insist that its not appropriate to allow the
> client
> end to change them back :(
>
> So until SeaMonkey adds the facility to set a folder reply address I'm
> stuck
> like you with remembering to hit 'reply all' on the relatively few lists
> that
> still work the old school way ;) Actually rather than doing that I TRY to
> be
> nice and replace the private reply address with the list address - so I
> don't
> get those duplicate replies that are not getting filtered out when someone
> 'reply alls' my posts ;)
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
> L.S.Caine Electronic Services - http://home.lsces.co.uk
> MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
>     As a relatively-new contributor to this list (read: under 2
> years), I realize that I have no business requesting a change, but
> I'll breech etiquette and hope for the best.
> 
>     Can we update the filters on the list to have the reply-to address
> header marked to the php-general address?  The reason I ask this is
> because, when people are on vacation (such as Juan is now), we receive
> responses to our personal addresses.  Secondly, we have to continually
> "Reply All" the messages, which - though it's not a problem - can
> cause issues when attempting to respond to those "[URGENT]" replies.
> Third, our addresses are included in gmane, et al, which is an
> inherent risk --- I understand.
> 
>     Maybe it's just the ramblings of someone attempting to read and
> type on a limited-bandwidth mobile device while bored due to delays in
> mass-transit facilities (here, read: I'm fucking exhausted, and yes, I
> dropped the "F" bomb).  In either case, it's not conducive to a new
> contributor to have to weed through "vacation response" messages each
> time he/she replies to the list.

I agree here.

I am on many lists and if I'm interested in something then I expect
people to expect me to read the list for replies. But for noobs, the
personal reply is quite good.

I guess the rule should be "public list -> reply to poster",
"subscription list -> reply to list".

AFAIK Gmane etc. can be configured to obfuscate email addresses -
certainly other lists I read through Gmane are...

Col

--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:
Daniel Brown wrote:
    As a relatively-new contributor to this list (read: under 2
years), I realize that I have no business requesting a change, but
I'll breech etiquette and hope for the best.

    Can we update the filters on the list to have the reply-to address
header marked to the php-general address?  The reason I ask this is
because, when people are on vacation (such as Juan is now), we receive
responses to our personal addresses.  Secondly, we have to continually
"Reply All" the messages, which - though it's not a problem - can
cause issues when attempting to respond to those "[URGENT]" replies.
Third, our addresses are included in gmane, et al, which is an
inherent risk --- I understand.

    Maybe it's just the ramblings of someone attempting to read and
type on a limited-bandwidth mobile device while bored due to delays in
mass-transit facilities (here, read: I'm fucking exhausted, and yes, I
dropped the "F" bomb).  In either case, it's not conducive to a new
contributor to have to weed through "vacation response" messages each
time he/she replies to the list.

I agree here.

I am on many lists and if I'm interested in something then I expect
people to expect me to read the list for replies. But for noobs, the
personal reply is quite good.

I guess the rule should be "public list -> reply to poster",
"subscription list -> reply to list".

AFAIK Gmane etc. can be configured to obfuscate email addresses -
certainly other lists I read through Gmane are...

Col

Well I think my only issue with it is that this is a group discussion list. We all ask for help, advice, suggestions or just bounce ideas off each other. When you hit that "Reply" button and it just goes to the person who made the post you're replying to it no long becomes a group discussion but a private one. The other issue is that during these private discussions the public version continues and if the solution is found in private the others don't know it and could actually spend time answering/helping with a problem that was fixed last Tuesday but no one knew because it was just a thread between two people.

As for your rule, I think it's flawed. All lists, private or public, require you to subscribe in some way. They don't magically pick up that they should send email to a certain address, they have to be told. If the list is meant to be a discussion list then all the replies should go to the list by default.
--- End Message ---
--- Begin Message ---
Tom Ray [Lists] wrote:
Well I think my only issue with it is that this is a group discussion ...<snip>...
to the list by default.

I agree with Tom.

I ussually hit reply, and take a few seconds to delete all the emails except the list email -- not very hard. :)



--
Wishlists: <http://snipurl.com/1gqpj>
   Switch: <http://browsehappy.com/>
     BCC?: <http://snipurl.com/w6f8>
       My: <http://del.icio.us/mhulse>

--- End Message ---
--- Begin Message ---
richard,

ive seen plenty of scenarios where the dev box has to be pretty tough
itself.  i think
it depends mostly on how much load its taking on.    say you have 30
developers
or so working on a few different viirtual sites simultaneously.  now add in
the problems
that occur during development, like my favorite, the infinite loop.  yeah
ive seen dev boxes
just chill at 99% cpu and we're taking 2xp3 xeon w/ a few gigs of ram in it.
 not saying
OP is dealing w/ sucha scenario just daying sometimes dev boxes need some
juice too.
i found out about the linux vserver
project<http://linux-vserver.org/Welcome_to_Linux-VServer.org>only
recently, but this is a nice solution.  you
can get one decent box and throw dev, qa, stage, w/e on there.  (and
obviously thata
may not be practical depending on hardware reqs)

if youre running linux that is :)

-nathan

On 7/29/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>
> On Fri, July 27, 2007 10:01 pm, Instruct ICC wrote:
> >>From: "Richard Lynch" <[EMAIL PROTECTED]>
> >> > But xdebug and apd are probably moot.
> >> >
> >> > BTW, I'm not using separate development and production machines.
> >>
> >>Right there is your first problem.
> >>
> >>Solve that first.
> >
> > If you mean get a dev box.  You don't know how long I've been asking
> > for one
> > to match the production box.
>
> Your dev box should only match in software versions (okay, and any
> really funky specialized hardware like a hardware random number
> generator MAYBE).
>
> Don't ask them for a Gigaplex Mu-on 16-cpu 64 Gig RAM 4 Terabyte hard
> drive box.
>
> Take an old box out of your closet and install the same versions of
> the OS, Webserver, DB, and PHP and call it done.
>
> Now, a QA box, where you do load-testing and serious "release
> candidate" testing, yeah, THAT should match the production box, if at
> all possible...
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hi,

I am trying for a php rating code that can utilized for a restaurant
requirement. First of all I am not sure if there is database that is obvious
with rating system. In case it is or even if its not, is there some site and
code available from where the code can be used.

I have tried some but most of them do not work.

Please advice,

Chris.
-- 
View this message in context: 
http://www.nabble.com/PHP-Rating-system-tf4166430.html#a11853841
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
Dan Shirah wrote:
I looked on PHP.net but I couldn't not find anything suitable to answer my
question.

Within PHP, is there a way to pull the name of the user that is currently
logged into the PC?

I know with some of the _SERVER functions you can pull the IP of the machine
and other data, is there a function within this family that would work?

I'm assuming you're after "transparent authentication" where the user doesn't need to do anything to authenticate with the site. This is only possible with IE as the client on an NT domain with the server on the same domain. If you're using IIS on the server then it's as easy as removing anonymous and basic authentication from the site/directory. If you're using Apache or something else you need to find an extension/module that provides NTLM authentication, but not all of the ones I tried fully supported the transparent side of it.

I implemented this for a corporate intranet a while back in Apache on FreeBSD with mod_ntlm (Google for it - dunno if it's still maintained). That was in 2004 and information was sparse, but with a bit of research and *lots* of experimenting I was able to get it to work.

To be perfectly honest, if I were doing it again I'd save the time and use IIS on the server - sooo much easier.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Fri, July 27, 2007 3:21 pm, John A DAVIS wrote:
We have various labs that submit coliform sample results in an ASCII
file, quoted/comma delimited.

We are being asked to encrypt this file for internet transfer. We are
also being asked to create a secure process by which to transfer this
file across the interent.

Currently:
the lab pushes and button and generates the ASCII file (12 columns)
the lab logs in to a PHP webpage and uses the file upload input to
submit the file.
If data is valid, file is saved on our server in a folder where we can
pull it into the respective tables.


Be nice to have some insights on how to encrypt this file at the
source and how to transfer the file securely. We keep hearing the
words, "digital signature".

If the concern is about during the TRANSFER of the data, SSL should be
enough to satisfy virtually any requirement.

The data is encrypted during the transfer.

Where they get "digital signature" from, I dunno...

Encrypting it at the source and decrypting it at the destination
before you transfer it encrypted via SSL is kinda pointless...

Unless there is an untrusted individual handling it somewhere between
Lab and upload, or between your receipt and stuffing it into your
tables?

It's possible they want it digitally signed so they can verify the source. SSL won't help here.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---

Really, I had expected more mature commentary from the adults on this list.

So did I. I expect adults to display morality and values.


Really? Have you hung out with many computer geeks? Oh..wait..morality..I thought you said maturity. Pardon me. :)
--- End Message ---
--- Begin Message ---
On Sunday 29 July 2007, Dotan Cohen wrote:
> On 29/07/07, Larry Garfield <[EMAIL PROTECTED]> wrote:
> > 1) Something can be illegal without it being theft.  The idea that "if
> > it's not theft then it must be OK" is the bullshit argument that I am
> > pointing out as bullshit.
>
> That's a valid point, but you are playing lawyer's games. "It's not
> theft, it's QQQ, which is different from theft in X Y and Z". Nobody
> likes lawyers or their games. Call it what you will, copyright
> infringement is taking something without paying for it.

You can call whatever you want anything you want, but that doesn't make it 
true.  For instance, no, copyright infringement is NOT "taking something 
without paying for it".  Copyright infringement is duplicating "an expression 
of an idea that is fixed in a medium" without the permission of the copyright 
holder.  Money doesn't enter into it.

If copyright infringement were "taking something without paying for it", then 
anyone who's ever installed PHP is guilty of copyright infringement unless 
they sent Rasmus a check.  That is, of course, nonsense.

> > 3) At no point in this conversation have I ever said that I engage in or
> > support copyright infringement, and I am insulted that you would accuse
> > me of such without any evidence or justification to back it up.
>
> You are insinuating it. 

And you are making things up.

> I was also accused of supporting copyright 
> infringement earlier in the thread, yet I was not insulted. Don't be
> so sensitive. There are bigger jerks than me on the Internet. And I
> was not targeting you specifically. I was targeting your comments.
>
> > I am pointing out that you are saying things that are *factually
> > inaccurate by the laws of the United States*.  And for that you accuse me
> > of copyright infringement and being immoral?  That is without a doubt the
> > most offensive comment I've seen on this list so far.  I would say I
> > expect an apology, but given that you fall back on insulting someone's
> > ethics just because they don't buy into the same lie that the media
> > cartels have been spreading that you do I won't hold my breath.
>
> I never said anything about the laws of the United States. I don't
> even live there, what do I care about their laws? I am, however, a
> moral human being, and that is my motivation.

I am not as familiar with the laws of Canada, the EU, or Australia (I'm 
assuming you're probably in one of those), but my understanding is that the 
law is similar in those countries, except less restrictive on duplication 
than US laws are; at least for now.

> > Really, I had expected more mature commentary from the adults on this
> > list.
>
> So did I. I expect adults to display morality and values.

It's not just a simple lawyer game.  The distinction does make a difference.  
Here's why:

A great many people -- myself included but also the Creative Commons folks, 
the FSF, many open source developers, and many others -- believe the current 
system of copyright law to be fundamentally flawed.  Not that we shouldn't 
have copyright, but that the current form of copyright is broken.  A work 
restricted for an entire generation after the original author is 
dead?  "Digital Restriction Management" software that makes even Fair Use a 
felony?  Retroactively extending copyright terms?  Making experimentation 
with either art or technology either prohibited or prohibitively expensive?  
Yes, broken.  

As many people in this thread have already stated, most artists/authors don't 
actually benefit from this system.  The public certainly doesn't.  The only 
people who actually benefit from it are the Robert Igers (Disney President, 
CEO, and COO) and Britney Spears of the world.  Those people, however, have 
spent the last 40 years trying to convince people that copyright is 
really "property", and therefore is a moral right as inviolate as Life, 
Liberty, and Pursuit of Happiness.  Witness your own reply, where you quite 
openly accuse me of not having "morality and values" because I dare say that 
copyright infringement is not a mortal sin.  You have bought into a lie.

And the rank-and-file artists and authors of the world do not benefit from 
perpetuating that lie.  The current direction the law is moving, toward more 
restrictions on the exchange of information, is bad for anyone who isn't 
Robert Iger or Britney Spears.  That's why it is important to confront and 
correct that lie.  It must be corrected before copyright can be sanely 
reformed to benefit the public (its supposed goal) and original 
artists/authors, not a select few mega-corps.  

At no point have I said that copyright infringement is not illegal.

At no point have I said that copyright infringement is a good thing.

At no point have I encouraged people to engage in copyright infringement.

At every point, I have pointed out what the law actually says, and why it says 
it.

And for that, I am accused of having no morality and values.

Yes, I do take this issue very seriously, as should anyone who works in an 
information-creating job.  

I highly recommend Larry Lessig's book "Free Culture": 

http://free-culture.cc/

You can even download it free, not for money, legally, without it being 
copyright infringement.  How about that.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message --- Al: Thanks, sorry for messaging this to the list. Can you point me in the direction of the official phpList forum?

Thanks a ton,
 --Eric





Al wrote:
You'd be far better off asking your questions on the phpList forum.

There are a number of hints on the forum for speeding up things. Plus, look in the examples section.

Eric Holt (PHP List) wrote:
Hello everyone.  This is my first post to the list, so bare with me :)

I have written an application for a client that is used in the Event Photography business. It handles taking photographs, categorizing them, making thumbnails of them, and allows parents(customers) to view the photos and order them. It runs on LAMP, and it really works great.

For the past two years, we've used ImageMagick v4.2.9 to process the thumbnails. Image quality was decent enough, but the main reason for 4.2.9 was SPEED. In my testing, 4.2.9 was quite a bit faster than the lastest releases (in the 6.x.x series). Anyway -- the clients decided they wanted me to do some work on the image quality, so I finally decided to move up to ImageMagick v.6.3.4.

Right now, I call ImageMagick from a "exec" call in PHP. When I first wrote the application, it was the quickest and easiest way for me to get it working. Command-line ImageMagick is pretty simple.

So, with ImageMagick 6.3.4, with the sharpening and compression I'm now using, the clients are absolutely in love with the thumbnail quality -- even though the amount of time it takes to make the thumbnails is much longer. They've asked if anything can be done about that, but I think I've optimized the shell script as much as possible.

Now, after that long rambling... My question is this: Would I see a big speed improvement by using the ImageMagick extension built into PHP (MagicWand, is it called?)? I'd hate to spend all the time recoding the application to work with MagicWand, only to find out that I dont end up with any performance increase -- or worse of all, a decrease.

I wasnt convinced either way, from the Googling I had done on the subject, so I thought I would post the question to the PHP list.

A little more background here, before I go: PHP iterates through a directory of full-sized images, directly out of the camera, and "exec"'s a shell script "thumbcreation.sh" with the details of what ImageMagick needs to do, and where it needs to store the new thumbnails. The script calls convert, which creates a medium sized thumbnail (333x500), and then from that creates a small thumbnail (80x120) from the medium. Then, the script calls composite, where is adds a watermark to the medium size thumbnail, and saves it in the watermarked directory.

In my initial testing, years ago, I found that ImageMagick v4.2.9 was faster than the internal GD library... however, I havnt touched GD since my initial testing. Perhaps GD would be faster now than IM v6.3.4(?).

Okay, I've rambled on plenty now, for my first post. I greatly appreciate any advice anyone on the list could provide.


THANKS!!!
 --Eric


--- End Message ---
--- Begin Message ---
Google imagemagik forums

Eric Holt (PHP List) wrote:
Al: Thanks, sorry for messaging this to the list. Can you point me in the direction of the official phpList forum?

Thanks a ton,
 --Eric





Al wrote:
You'd be far better off asking your questions on the phpList forum.

There are a number of hints on the forum for speeding up things. Plus, look in the examples section.

Eric Holt (PHP List) wrote:
Hello everyone.  This is my first post to the list, so bare with me :)

I have written an application for a client that is used in the Event Photography business. It handles taking photographs, categorizing them, making thumbnails of them, and allows parents(customers) to view the photos and order them. It runs on LAMP, and it really works great.

For the past two years, we've used ImageMagick v4.2.9 to process the thumbnails. Image quality was decent enough, but the main reason for 4.2.9 was SPEED. In my testing, 4.2.9 was quite a bit faster than the lastest releases (in the 6.x.x series). Anyway -- the clients decided they wanted me to do some work on the image quality, so I finally decided to move up to ImageMagick v.6.3.4.

Right now, I call ImageMagick from a "exec" call in PHP. When I first wrote the application, it was the quickest and easiest way for me to get it working. Command-line ImageMagick is pretty simple.

So, with ImageMagick 6.3.4, with the sharpening and compression I'm now using, the clients are absolutely in love with the thumbnail quality -- even though the amount of time it takes to make the thumbnails is much longer. They've asked if anything can be done about that, but I think I've optimized the shell script as much as possible.

Now, after that long rambling... My question is this: Would I see a big speed improvement by using the ImageMagick extension built into PHP (MagicWand, is it called?)? I'd hate to spend all the time recoding the application to work with MagicWand, only to find out that I dont end up with any performance increase -- or worse of all, a decrease.

I wasnt convinced either way, from the Googling I had done on the subject, so I thought I would post the question to the PHP list.

A little more background here, before I go: PHP iterates through a directory of full-sized images, directly out of the camera, and "exec"'s a shell script "thumbcreation.sh" with the details of what ImageMagick needs to do, and where it needs to store the new thumbnails. The script calls convert, which creates a medium sized thumbnail (333x500), and then from that creates a small thumbnail (80x120) from the medium. Then, the script calls composite, where is adds a watermark to the medium size thumbnail, and saves it in the watermarked directory.

In my initial testing, years ago, I found that ImageMagick v4.2.9 was faster than the internal GD library... however, I havnt touched GD since my initial testing. Perhaps GD would be faster now than IM v6.3.4(?).

Okay, I've rambled on plenty now, for my first post. I greatly appreciate any advice anyone on the list could provide.


THANKS!!!
 --Eric


--- End Message ---
--- Begin Message ---
Hi

I'm trying to assign two fields of an object returned from a MySQL query and have stumbled upon the most bizarre PHP bug where I can't create two arrays in succession.

Here's the MySQL query with two dummy fields to be filled in later

select *, 0 as dummy_1, 0 as dummy_2 from table

Here's how I'm grabbing the query results

$result                 = array();
while ($row = mysql_fetch_object($query_result))
{
        $result[]       = $row;
}

Once that's done, I try to set two of the rows to arrays like this

$result-> dummy_1    = array(1, 2, 3, 4);
$result-> dummy_2    = array('a', 'b', 'c', 'd');

If I comment out either of the above lines, the script works but with both uncommented, it seems to drop dead. It doesn't even return an error.

I rebooted my system thinking PHP might have gotten into a funky state but that didn't work. I retyped the function from scratch but it still breaks on these two lines. I did a "show invisibles" and "show spaces" in BBEdit to see if there was a hidden character, none found. I did a hex dump to see if there was a hidden character that BBEdit was missing, nope. And I haven't upgraded PHP in a year so it's not a question of an unstable update.

I've been doing assignments like the above for 3 years and never had a problem and in fact the exact same function works perfectly in another script.This one has me utterly stumped.

Anyone have an idea what might be causing this? Or something else I could try to glean more info about the failure?

Thanks in advance

Ken

--- End Message ---
--- Begin Message ---

On Jul 29, 2007, at 6:49 PM, Ken Tozier wrote:

Hi

I'm trying to assign two fields of an object returned from a MySQL query and have stumbled upon the most bizarre PHP bug where I can't create two arrays in succession.

Here's the MySQL query with two dummy fields to be filled in later

select *, 0 as dummy_1, 0 as dummy_2 from table

Here's how I'm grabbing the query results

$result                 = array();
while ($row = mysql_fetch_object($query_result))
{
        $result[]       = $row;
}

Once that's done, I try to set two of the rows to arrays like this

$result-> dummy_1    = array(1, 2, 3, 4);
$result-> dummy_2    = array('a', 'b', 'c', 'd');

Oops. Left out a step. This is actually how I'm doing the assignments

$result[0]-> dummy_1 = array(1, 2, 3, 4);
$result[0]-> dummy_2 = array('a', 'b', 'c', 'd');



If I comment out either of the above lines, the script works but with both uncommented, it seems to drop dead. It doesn't even return an error.

I rebooted my system thinking PHP might have gotten into a funky state but that didn't work. I retyped the function from scratch but it still breaks on these two lines. I did a "show invisibles" and "show spaces" in BBEdit to see if there was a hidden character, none found. I did a hex dump to see if there was a hidden character that BBEdit was missing, nope. And I haven't upgraded PHP in a year so it's not a question of an unstable update.

I've been doing assignments like the above for 3 years and never had a problem and in fact the exact same function works perfectly in another script.This one has me utterly stumped.

Anyone have an idea what might be causing this? Or something else I could try to glean more info about the failure?

Thanks in advance

Ken

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


--- End Message ---
--- Begin Message ---
Ken Tozier wrote:
Hi

I'm trying to assign two fields of an object returned from a MySQL query and have stumbled upon the most bizarre PHP bug where I can't create two arrays in succession.

Here's the MySQL query with two dummy fields to be filled in later

select *, 0 as dummy_1, 0 as dummy_2 from table

Here's how I'm grabbing the query results

$result            = array();
while ($row = mysql_fetch_object($query_result))
{
    $result[]    = $row;
}

Once that's done, I try to set two of the rows to arrays like this

$result-> dummy_1    = array(1, 2, 3, 4);
$result-> dummy_2    = array('a', 'b', 'c', 'd');

If I comment out either of the above lines, the script works but with both uncommented, it seems to drop dead. It doesn't even return an error.
Is this all of your code? Do you have some sort of output display for your results? Does PHP generally return errors to the browser? When I tried your code above with a test table with four data fields I got this error:
*
Warning*: Attempt to assign property of non-object in */usr/local/apache/htdocs/test-script.php* on line *14 **Warning*: Attempt to assign property of non-object in */usr/local/apache/htdocs/test-script.php* on line *15

*Then I re-read your code and realized that you made $row an object not $result, it's just an array. Changing this:

$result->dummy_1 = array(1, 2, 3, 4); $result->dummy_2 = array('a', 'b', 'c', 'd');
to this:

$row->dummy_1 = array(1, 2, 3, 4); $row->dummy_2 = array('a', 'b', 'c', 'd'); Yielded no errors for me what so ever. However, since it's unclear on what you are doing with this data I can't vouch that it's actually what you need. Double check your display_errors setting in your php.ini and make sure it's set to On. Because you're either not giving us all the code to work with and something else is happening and that's why you don't get the error but not your desired result or you're not displaying the errors.

I've been doing assignments like the above for 3 years and never had a problem and in fact the exact same function works perfectly in another script.This one has me utterly stumped.

Does that script run on the same machine? If it's on another machine is that machine running the same version? I ran this on a server with Apache 2.2.4, PHP 5.2.3 and mySQL 5.0.18. Have you referenced that other script to make sure that it *is* exactly the same?
--- End Message ---
--- Begin Message ---

On Jul 30, 2007, at 12:05 AM, Tom Ray [Lists] wrote:

Ken Tozier wrote:
Hi

I'm trying to assign two fields of an object returned from a MySQL query and have stumbled upon the most bizarre PHP bug where I can't create two arrays in succession.

Here's the MySQL query with two dummy fields to be filled in later

select *, 0 as dummy_1, 0 as dummy_2 from table

Here's how I'm grabbing the query results

$result            = array();
while ($row = mysql_fetch_object($query_result))
{
    $result[]    = $row;
}

Once that's done, I try to set two of the rows to arrays like this

$result-> dummy_1    = array(1, 2, 3, 4);
$result-> dummy_2    = array('a', 'b', 'c', 'd');

If I comment out either of the above lines, the script works but with both uncommented, it seems to drop dead. It doesn't even return an error.

Is this all of your code?

No. Here's the full function:
function get_document_type_for_pub($inPubID)
{
$query = "select doc_type.*, 0 as rect, 0 as usable_rect, 0 as usable_width, 0 as usable_height, 0 as column_width, 0 as column_offsets, 0 as box_widths from publication, doc_type where publication.id=".$inPubID." and publication.doc_type=doc_type.id";
        $queryResult                    = $this->db->query_database($query);
        $result                                 = $queryResult[0];
        
        // convert numbers
        $result->id                          += 0;
        $result->page_width  += 0.0;
        $result->page_height         += 0.0;
        $result->top_margin  += 0.0;
        $result->left_margin         += 0.0;
        $result->bottom_margin       += 0.0;
        $result->right_margin        += 0.0;
        $result->column_count        += 0;
        $result->gutter_width        += 0.0;
        $result->folio_height        += 0.0;
        $result->usable_width        += 0.0;
        $result->usable_height       += 0.0;
        $result->column_width        += 0.0;
        
        // calculate derived values
$result->usable_width = $result->page_width - $result->left_margin - $result->right_margin; $result->usable_height = $result->page_height - $result->top_margin - $result->bottom_margin; $result->column_width = ($result->usable_width - $result- >gutter_width * ($result->column_count - 1)) / $result->column_count;
        
        /*------------------------------------------------------*/
        /* Next two lines are where the problem starts                  */
        /* If I comment either of them out the script runs              */
        /* but with both uncommented, it dies
        /*------------------------------------------------------*/
        // create the rect and usable rect records
$result->rect = array(0, 0, $result->page_width, $result- >page_height); $result->usable_rect = array($result->left_margin, $result- >top_margin, $result->usable_width, $result->usable_height);
        
        // create the offset and box width arrays
        $offsets                                = array();
        $widths                                 = array();
        $left                                   = $result->left_margin;
        $width                                  = $result->column_width;
        $inc                                    = $result->column_width + 
$result->gutter_width;
        
        for ($i = 0; $i < $result->column_count; $i++)
        {
                $offsets[]                      = $left;
                $widths[]                       = array('column_width'=> $i + 1, 
'point_width'=> $width);
                $left                           += $inc;
                $width                          += $inc;
        }
        
        $result->column_offsets      = $offsets;
        $result->box_widths          = $widths;
        
        return $result;
}


Do you have some sort of output display for your results?

No. Once it hits the "create the rect and usable rect records" assignments, it's like the script didn't even get called. Nothing returns.

Does PHP generally return errors to the browser?

I'm not using a browser, I'm making direct calls to the script from a Cocoa class on a Mac

Does that script run on the same machine?

Yes. I'm doing all development on my MacBook and the scripts all live in my local web folder.

If it's on another machine is that machine running the same version? I ran this on a server with Apache 2.2.4, PHP 5.2.3 and mySQL 5.0.18. Have you referenced that other script to make sure that it *is* exactly the same?

I cut and pasted it from its original home to a new script and it stopped working.

Thanks for replying Tom. I'll check out the php.ini settings tomorrow

Ken

--- End Message ---
--- Begin Message ---
At 7/29/2007 09:59 PM, Ken Tozier wrote:
        /*------------------------------------------------------*/
        /* Next two lines are where the problem starts                  */
        /* If I comment either of them out the script runs              */
        /* but with both uncommented, it dies
        /*------------------------------------------------------*/
        // create the rect and usable rect records
$result->rect = array(0, 0, $result->page_width, $result- >page_height);

Does this typo exist in your script? "$result- >page_height" with a space between - and >?

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--- End Message ---
--- Begin Message ---
Tom Ray [Lists] wrote:
Chris wrote:
Richard Lynch wrote:
On Thu, July 26, 2007 2:46 pm, Tom Ray [Lists] wrote:
I'm trying to use PHP to compose an HTML formatted email

Don't do that...

3) Spam Assassin doesn't like it either way and tags the email as SPAM
for the following reasons:

 0.6 HTML_SHORT_LENGTH      BODY: HTML is extremely short
 0.0 HTML_MESSAGE           BODY: HTML included in message
 1.5 MIME_BASE64_TEXT       RAW: Message text disguised using base64
encoding

<snip>

However, I would still like to get answers on questions 1 and 2 for future reference so any thoughts would be great.

They're pretty self explanatory.

1) Make your message longer
2) Your message contains html. Your rules are set up to flag anything with html as spam.

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

--- End Message ---
--- Begin Message ---
After changing my php folder from e:\php to f:\php php does not work anymore 
in my webserver. I found out regsvr32 phpisapi.dll gives an error. I 
remember having a similar problem but am not sure what and how.

Anyone know how to fix? 

--- End Message ---

Reply via email to