php-general Digest 16 Jun 2010 21:02:45 -0000 Issue 6802

Topics (messages 306190 through 306213):

Re: export from one server to another
        306190 by: Richard Quadling

Re: SQL Syntax
        306191 by: Carlos Medina
        306192 by: Jan Reiter
        306193 by: Jan Reiter
        306194 by: Carlos Medina
        306203 by: Andrew Ballard

Unknown error with imagecreatefromjpeg() on specific GD/PHP versions.
        306195 by: Jeff MacDonald
        306196 by: Daniel Brown
        306197 by: Daniel Brown
        306198 by: Richard Quadling
        306199 by: Jeff MacDonald
        306200 by: Jeff MacDonald
        306201 by: Richard Quadling
        306202 by: Jeff MacDonald

Re: SQL Syntax [improved SQL]
        306204 by: Jan Reiter
        306205 by: Tommy Pham

Re: Another parse problem
        306206 by: tedd
        306207 by: Daniel P. Brown
        306212 by: Robert Cummings
        306213 by: Shawn McKenzie

Re: Seeking developer for short term project
        306208 by: Dev Job

User's IP Validation
        306209 by: Juan Rodriguez Monti
        306210 by: Bob McConnell
        306211 by: David Cesal

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On 16 June 2010 09:42, Merlin Morgenstern <[email protected]> wrote:
>
>
> On Tue, 15 Jun 2010 11:26 +0100, "Richard Quadling"
> <[email protected]> wrote:
>> On 15 June 2010 11:00, Merlin Morgenstern <[email protected]> wrote:
>> > HI there,
>> >
>> > I am thinking about building a partner network where partners can export
>> > content to my server which will then be imported. It should be as easy as
>> > possible for the partner and not rely on any special php functions.
>> >
>> >
>> > The best way to do this I guess is to deliver them a php file which will
>> > create a xml structure that I can import. The problem I have now is, how to
>> > transfer this xml-file to my server? Of course I could do this via FTP, but
>> > then they need to have FTP enabled inside their php installation. This 
>> > might
>> > scare some partners away.
>> >
>> > Does anybody have a good suggestion on how to do this?
>> >
>> > Thank you for any hint,
>> >
>> > Merlin
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> We have just done something similar. We went down the SOAP route as
>> this allows third parties to be able to take our WSDL file (which
>> describes the services we offer) and create their own code from it,
>> essentially wrapping the SOAP comms in a class of language x. I used a
>> slightly modified wsdl2php class from sourceforge to create my client
>> classes for our own service, rather than manually creating them, as a
>> proof of concept. So wsdl2java, wsdl2net (if such things exist) would
>> do a similar job.
>>
>> For us, the biggest advantage of SOAP over say REST was that SOAP is a
>> documented standard (with all its faults). We can supply a single
>> document which is man and machine readable and fully describes our
>> service. Admittedly, we used the Zend SOAP, WSDL and AutoDiscovery
>> classes for all of this, so really, we did VERY little in terms of
>> creating the SOAPy bits.
>>
>> We have an Authentication service and then a series of services which
>> retrieve and supply data. We incorporated version control into all the
>> classes. So, V1 is where we are today. As we increase functionality,
>> we can incorporate a "superseded by" mechanism, which the end-user can
>> take into account if they so wish. The WSDL file will have the latest
>> info, they can re-generate their classes from the WSDL file and then
>> take advantage of the new functionality.
>>
>> If we find a problem which essentially breaks the contract, we can
>> kill a version. And if if has a superseded by, we are again,
>> automatically informing the client of the newer code.
>>
>> Add to that live (default), test (we think this is what you asked for)
>> and dev (this is where we are at the moment if you really want to see
>> something) requests for a particular version. As dev becomes test, the
>> dev is "killed" and "superseded by" the test and then the same for the
>> test -> live (with test's not being killed).
>>
>> So. A simple enough setup, but allows us to move at our own pace in
>> terms of further development, allows us to incorporate requests and
>> bespoke requests to meet the needs of our partners ... all good. And
>> it was good fun doing this. Admittedly, there were a few bugs in the
>> Zend code I had to fix (all patches have been supplied but awaiting
>> someone to commit them to the code).
>>
>> Richard.
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer :
>> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>
>
>
> They have PHP already installed as most of them are using PHPBB or
> another Forum Software.
> How could I allow them to upload XML directly to my server? I could
> provide them with a username and pw on the suse system, but then we have
> the problem that scp must be enabled inside their php version. Same
> problem again like with ftp.
>
> I am searching for a solution which will allow a standard php
> installation to transfer the xml file to my server with login and pw.
>
> Thank you for any further hints.
>
> Merlin
>
> --
> http://www.fastmail.fm - The professional email service
>
>

You can use a simple html form with a file upload. No extensions or
special permissions required for that.

If the form is loaded via https - that proves to THEM who you are. But
for this, you would need to buy a certificate (never done this - not
sure what/how/cost/etc.).

They provide a username and password first so you don't end up having
to receive a MASSIVE file BEFORE you have validated their credentials.

There is a detailed file upload explanation/example in the PHP manual
at http://docs.php.net/file%20upload - Make sure you read through all
5 sections here to get the full info. The user notes are also very
interesting.



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Am 16.06.2010 02:58, schrieb Jan Reiter:
Hi folks!

I'm kind of ashamed to ask a question, as I haven't followed this list very
much lately.



This isn't exactly a PHP question, but since mysql is the most popular
database engine used with php, I figured someone here might have an idea.



I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =>
A(uid,pid) and another table B, containing 3 fields. The picture ID, an
attribute ID and a value for that attribute =>  B(pid,aid,value).



Table B contains several rows for a single PID with various AIDs and values.
Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
image size and AID = 3 always holding a value for the image type)



The goal is now to join table A on table B using pid, and selecting the rows
based on MULTIPLE  attributes.



So the result should only contain rows for images, that relate to an
attribute ID = 1 (size) that is bigger than 100 AND!!!!!!! an attribute ID =
5 that equals 'jpg'.



I know that there is an easy solution to this, doing it in one query and I
have the feeling, that I can almost touch it with my fingertips in my mind,
but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
CRAZY!!!!!!



I appreciate your thoughts on this.



Regards,

Jan


Hi Jan,
i think the problem here is the architecture of your database and not the sql queries. Sure, there are a whay to solve this, but i think it is better (for the software maintainment and further work in your code), that you take 5 minutes and redesign your tables. In my opinion, your attribute,value pair table, should be a extern table with relation to table b. As for know, i dont know what you want to do, but i think, when the user have more than one picture with more attributes each picture, your query will be slow. By increasing the attributes count, you will show, the queries and the maintainment of code will be hard.

I have some links here but i am sure, you will find more in google ;-)

Regards

Carlos


Links: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
http://en.wikipedia.org/wiki/Entity-attribute-value_model
http://weblogs.sqlteam.com/davidm/articles/12117.aspx

--- End Message ---
--- Begin Message ---
Richard, Carlos, Simcha and Nigel,


Thank you all for your answers on this matter. When I read Simcha's mail, it
hit me like a hammer! 
That was what I was looking for! BUT: I have to see, that this creates way
to much overhead, as I have to use  INNER JOIN instead of LEFT JOIN, or an
equvalent subquery.

I'm currently testing with temporary tables to filter the data before going
into the real query. 

As this is not a real project, just me testing the pros and cons of speed
versus flexibility of exactly this table structure, there is no need to
restructure the tables. 

I use 30,000 images as sample data, 7 attributes each.

What I have for the images is 3 tables. 

table picture
        pid(primary):   the id of the picture
        uid(index):     the user id, to whom the image belongs
        

table picture_attribute
        aid(primary):   the id of the attribute
        name(index):    a name for that attribute e.g. fsize


table picture_attrib_rel (unique over pid,aid - to avoid the same attribute
twice 
        pid(index):     the picture, this row belongs to
        aid(index):     the type of attribute this row describes
        val_int(NULL):  a field for integer values      |
        val_vc(NULL):   a field for string values       | my class decides
wich of these value types to use,
the other is NULL

My class emulates a foreign_key behavior on aid between picture_attribute
and picture_attrib_rel.


THANK YOU ALL!!

Regards,

Jan


--- End Message ---
--- Begin Message ---
Thank you, for your response!

I'm testing with exactly that table structure to evaluate flexibility vs
speed. I only use images, as it gives me easy a vast amount of sample date.
I'm testing with 30,000 images. :-)

So far I was testing multi-table joins in various combinations, trying to
help mysql's optimization routines using IN() etc. 

But comparing for 2 attributes costs 1.8 seconds/ query with 7 attributes
per image and 30,000 images. 
Not acceptable. ;-)

Views without conditions on the values resulted in no speed advantages.
(figures ... ) 

I see chances, that temporary tables will speed things up a bit. I'm testing
that next. 
Another attempt could be to switch DB engines from InnoDB to MyISAM ... I'll
see what it results in. :D.


This is just a private test on a sandbox machine. I earn my living flying
airliners, not programming.

Thanks and Regards,
Jan


-----Original Message-----
From: [email protected] [mailto:[email protected]] 
Sent: Wednesday, June 16, 2010 2:49 PM
To: MYSQL General List
Cc: Jan Reiter
Subject: Re: [PHP] SQL Syntax

Hi!


Daniel Brown wrote:
>     [Top-post.]
> 
>     You'll probably have much better luck on the MySQL General list.
> CC'ed on this email.
> 
> 
> On Tue, Jun 15, 2010 at 20:58, Jan Reiter <[email protected]> wrote:
>> Hi folks!
>>
>> [[...]]
>>
>> I have 2 tables. Table A containing 2 fields. A user ID and a picture ID
=>
>> A(uid,pid) and another table B, containing 3 fields. The picture ID, an
>> attribute ID and a value for that attribute => B(pid,aid,value).
>>
>> Table B contains several rows for a single PID with various AIDs and
values.
>> Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for
the
>> image size and AID = 3 always holding a value for the image type)
>>
>> The goal is now to join table A on table B using pid, and selecting the
rows
>> based on MULTIPLE  attributes.
>>
>> So the result should only contain rows for images, that relate to an
>> attribute ID = 1 (size) that is bigger than 100 AND!!!!!!! an attribute
ID =
>> 5 that equals 'jpg'.
>>
>> [[...]]

You need to do a multi-table join, table A joined to one instance of
table B for each attribute relevant to your search.

Roughly, syntax not tested, it is something like
   SELECT a.uid, a.pid FROM a JOIN b AS b1 ON a.pid=b1.pid
                              JOIN b AS b2 ON a.pid=b2.pid
                              JOIN ...
          WHERE b1.aid = 1 AND b1.value > 100
            AND b2.aid = 3 AND b2.value = 5
            AND ...
(assuming 'jpg' is coded as 5, what I take from your text).

Now, I see some difficulties with this:
1) You are using the "value" column for anything, that may cause data
   type problems.
2) AFAIR, there was a post recently claiming the alias names (b1, b2,
   ...) could not be used in WHERE conditions, and the recommendation
   was to replace WHERE by HAVING.
3) If you need to support many attributes in one search, the number of
   tables joined grows, and the amount of data to handle (cartesian
   product!) will explode.
   What works fine with 3 criteria on 10 pictures (10 * 10 * 10 = 1000)
   may totally fail with 4 criteria on 200 pictures
   (200**4 = 800.000.000 = 800 million)
4) The more different attributes you store per picture, the larger your
   table B will become, and this will make the data grow for each join
   step.
   If you store 4 attributes each for 200 pictures, table B will already
   have 800 entries. In itself, that isn't much, but now the 4-way join
   will produce a cartesian product of
      800**4 = 8**4 * 100**4 = 4096 * 100.000.000 = 409.600.000.000
   combinations.
   In your place, I would use a separate table for attributes which are
   expected to be defined for all pictures, like size and image type.
   Then your general attributes table B will hold much fewer rows, thus
   each join step will profit.
5) Because of that explosion, it may be better to work with a temporary
   table, joining it to B for one attribute and thus reducing the data,
   then looping over such a step for all the relevant attributes.

Good luck in experimenting!


Jörg

-- 
Joerg Bruehe,  MySQL Build Team,  [email protected]
Sun Microsystems GmbH,   Komturstrasse 18a,   D-12099 Berlin
Geschaeftsfuehrer: Juergen Kunz
Amtsgericht Muenchen: HRB161028


--- End Message ---
--- Begin Message ---
Am 16.06.2010 15:50, schrieb Jan Reiter:
Richard, Carlos, Simcha and Nigel,


Thank you all for your answers on this matter. When I read Simcha's mail, it
hit me like a hammer!
That was what I was looking for! BUT: I have to see, that this creates way
to much overhead, as I have to use  INNER JOIN instead of LEFT JOIN, or an
equvalent subquery.

I'm currently testing with temporary tables to filter the data before going
into the real query.

As this is not a real project, just me testing the pros and cons of speed
versus flexibility of exactly this table structure, there is no need to
restructure the tables.

I use 30,000 images as sample data, 7 attributes each.

What I have for the images is 3 tables.

table picture
        pid(primary):   the id of the picture
        uid(index):     the user id, to whom the image belongs
        

table picture_attribute
        aid(primary):   the id of the attribute
        name(index):    a name for that attribute e.g. fsize


table picture_attrib_rel (unique over pid,aid - to avoid the same attribute
twice
        pid(index):     the picture, this row belongs to
        aid(index):     the type of attribute this row describes
        val_int(NULL):  a field for integer values      |
        val_vc(NULL):   a field for string values       | my class decides
wich of these value types to use,
the other is NULL

My class emulates a foreign_key behavior on aid between picture_attribute
and picture_attrib_rel.


THANK YOU ALL!!

Regards,

Jan

Hi Jan,
pherhaps because i am working in a projekt with pictures too, but the way i found to solve this was over the same as you are doing now. I took a nm relation with attributes of picture configurations (configuration means width, height, print_material, ink and so one) and add it to the relation on a temp table (only for the search).

Regards

Carlos

--- End Message ---
--- Begin Message ---
On Tue, Jun 15, 2010 at 8:58 PM, Jan Reiter <[email protected]> wrote:
> Hi folks!
>
> I'm kind of ashamed to ask a question, as I haven't followed this list very
> much lately.
>
> This isn't exactly a PHP question, but since mysql is the most popular
> database engine used with php, I figured someone here might have an idea.
>
> I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =>
> A(uid,pid) and another table B, containing 3 fields. The picture ID, an
> attribute ID and a value for that attribute => B(pid,aid,value).
>
> Table B contains several rows for a single PID with various AIDs and values.
> Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
> image size and AID = 3 always holding a value for the image type)

This is known as an EAV (Entity-Attribute-Value) design. It is usually
(some would say always) a very bad idea to implement this in a
relational database. and this is no exception.

> The goal is now to join table A on table B using pid, and selecting the rows
> based on MULTIPLE  attributes.
>
> So the result should only contain rows for images, that relate to an
> attribute ID = 1 (size) that is bigger than 100 AND!!!!!!! an attribute ID =
> 5 that equals 'jpg'.
>
> I know that there is an easy solution to this, doing it in one query and I
> have the feeling, that I can almost touch it with my fingertips in my mind,
> but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
> CRAZY!!!!!!

The easy solution is to redesign the tables. There are a lot of
reasons why this design is usually a very bad idea. For starters, what
should be a simple query is anything but simple, as you have just
discovered. What's more, there is no simple way (if any way at all)
for your design to prevent an image from having a mime-type of 20174
or a size of 'jpg'.

Andrew

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

One of my developers is reporting a problem on our Live server but not our 
devel server.

Specifically when someon uploads a photo taken by a KODAK EASYSHARE C813, and 
that image gets processed by imagecreatefromjpeg(), the function returns false.

Our Devel Server Info [this works fine]
        PHP Version : 5.2.6-3
        GD Version: 2.0 or higher.
        EXIF Version: 1.4

Our Live Server Info [this one is the one that fails]
        PHP Version: 5.2.13
        GD Version : 2.0.34 compatible
        EXIF Version : 1.4
        
To see an example of this in action, 

Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
Not working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n

http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
        
Does anyone have any ideas or suggestions of where to look next?

Jeff.

--- End Message ---
--- Begin Message ---
On Wed, Jun 16, 2010 at 10:26, Jeff MacDonald <[email protected]> wrote:
[snip!]
>
> To see an example of this in action,
>
> Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
> Not working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n
>
> http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
>
> Does anyone have any ideas or suggestions of where to look next?

    If your code is an accurate representation, and not just an
example to demonstrate the function source in action, then that's your
problem (which I doubt, of course), as you're specifically calling the
value of $_GET['i'] to determine which static image to display.  Also,
you use $_GET['i'] == w.  Since 'w' is not a constant, it will revert
to using the literal w, but that's not such great form there, Spanky.
;-P

    Is the image loaded from the local filesystem directly, or is it
using an HTTP or other over-the-wire call?  If it's not local, check
to ensure that you have the URL fopen option enabled.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--- End Message ---
--- Begin Message ---
On Wed, Jun 16, 2010 at 10:26, Jeff MacDonald <[email protected]> wrote:
> Hi Everyone,
>
> One of my developers is reporting a problem on our Live server but not our 
> devel server.
[snip!]
>
> Does anyone have any ideas or suggestions of where to look next?

    Error logs.  See what the non-working error logs show for that.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--- End Message ---
--- Begin Message ---
On 16 June 2010 15:26, Jeff MacDonald <[email protected]> wrote:
> Hi Everyone,
>
> One of my developers is reporting a problem on our Live server but not our 
> devel server.
>
> Specifically when someon uploads a photo taken by a KODAK EASYSHARE C813, and 
> that image gets processed by imagecreatefromjpeg(), the function returns 
> false.
>
> Our Devel Server Info [this works fine]
>        PHP Version : 5.2.6-3
>        GD Version: 2.0 or higher.
>        EXIF Version: 1.4
>
> Our Live Server Info [this one is the one that fails]
>        PHP Version: 5.2.13
>        GD Version : 2.0.34 compatible
>        EXIF Version : 1.4
>
> To see an example of this in action,
>
> Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
> Not working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n
>
> http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
>
> Does anyone have any ideas or suggestions of where to look next?
>
> Jeff.
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The @ is suppressing this notice ...

Notice: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
Corrupt JPEG data: 31 extraneous bytes before marker 0xd9


-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
>    If your code is an accurate representation, and not just an
> example to demonstrate the function source in action, then that's your
> problem (which I doubt, of course), as you're specifically calling the
> value of $_GET['i'] to determine which static image to display.  Also,
> you use $_GET['i'] == w.  Since 'w' is not a constant, it will revert
> to using the literal w, but that's not such great form there, Spanky.
> ;-P

I'm a sys admin, not a php developer. So I hacked up just enough code to 
demonstrate how the function was failing.
> 
>    Is the image loaded from the local filesystem directly, or is it
> using an HTTP or other over-the-wire call?  If it's not local, check
> to ensure that you have the URL fopen option enabled.

They're both local. The next poster in the this thread answered this for me 
anyways.

Jeff.

> 
> -- 
> </Daniel P. Brown>
> [email protected] || [email protected]
> http://www.parasane.net/ || http://www.pilotpig.net/
> We now offer SAME-DAY SETUP on a new line of servers!
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
On 2010-06-16, at 11:37 AM, Richard Quadling wrote:

> On 16 June 2010 15:26, Jeff MacDonald <[email protected]> wrote:
>> Hi Everyone,
>> 
>> One of my developers is reporting a problem on our Live server but not our 
>> devel server.
>> 
>> Specifically when someon uploads a photo taken by a KODAK EASYSHARE C813, 
>> and that image gets processed by imagecreatefromjpeg(), the function returns 
>> false.
>> 
>> Our Devel Server Info [this works fine]
>>        PHP Version : 5.2.6-3
>>        GD Version: 2.0 or higher.
>>        EXIF Version: 1.4
>> 
>> Our Live Server Info [this one is the one that fails]
>>        PHP Version: 5.2.13
>>        GD Version : 2.0.34 compatible
>>        EXIF Version : 1.4
>> 
>> To see an example of this in action,
>> 
>> Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
>> Not working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n
>> 
>> http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
>> 
>> Does anyone have any ideas or suggestions of where to look next?
>> 
>> Jeff.
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 
> The @ is suppressing this notice ...
> 
> Notice: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
> Corrupt JPEG data: 31 extraneous bytes before marker 0xd9

Thanks!

I guess I'm wondering why this works on the Devel server but not the live?

Jeff.


--- End Message ---
--- Begin Message ---
On 16 June 2010 15:37, Richard Quadling <[email protected]> wrote:
> On 16 June 2010 15:26, Jeff MacDonald <[email protected]> wrote:
>> Hi Everyone,
>>
>> One of my developers is reporting a problem on our Live server but not our 
>> devel server.
>>
>> Specifically when someon uploads a photo taken by a KODAK EASYSHARE C813, 
>> and that image gets processed by imagecreatefromjpeg(), the function returns 
>> false.
>>
>> Our Devel Server Info [this works fine]
>>        PHP Version : 5.2.6-3
>>        GD Version: 2.0 or higher.
>>        EXIF Version: 1.4
>>
>> Our Live Server Info [this one is the one that fails]
>>        PHP Version: 5.2.13
>>        GD Version : 2.0.34 compatible
>>        EXIF Version : 1.4
>>
>> To see an example of this in action,
>>
>> Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
>> Not working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n
>>
>> http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
>>
>> Does anyone have any ideas or suggestions of where to look next?
>>
>> Jeff.
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> The @ is suppressing this notice ...
>
> Notice: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
> Corrupt JPEG data: 31 extraneous bytes before marker 0xd9

Using djpeg -verbose notworking.jpg

Independent JPEG Group's DJPEG, version 7  27-Jun-2009
Copyright (C) 2009, Thomas G. Lane, Guido Vollbeding
Start of Image
Miscellaneous marker 0xe1, length 17066
Miscellaneous marker 0xe2, length 118
Miscellaneous marker 0xe2, length 514
Miscellaneous marker 0xe2, length 43270
Define Huffman Table 0x01
Define Huffman Table 0x11
Define Huffman Table 0x00
Define Huffman Table 0x10
Define Quantization Table 1  precision 0
Define Quantization Table 0  precision 0
Define Restart Interval 113
Start Of Frame 0xc0: width=1800, height=1200, components=3
    Component 1: 2hx2v q=0
    Component 2: 1hx1v q=1
    Component 3: 1hx1v q=1
Start Of Scan: 3 components
    Component 1: dc=0 ac=0
    Component 2: dc=1 ac=1
    Component 3: dc=1 ac=1
  Ss=0, Se=63, Ah=0, Al=0
Unexpected marker 0xd2
Corrupt JPEG data: 31 extraneous bytes before marker 0xd9
End Of Image




-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
On 2010-06-16, at 11:44 AM, Richard Quadling wrote:

> On 16 June 2010 15:37, Richard Quadling <[email protected]> wrote:
>> On 16 June 2010 15:26, Jeff MacDonald <[email protected]> wrote:
>>> Hi Everyone,
>>> 
>>> One of my developers is reporting a problem on our Live server but not our 
>>> devel server.
>>> 
>>> Specifically when someon uploads a photo taken by a KODAK EASYSHARE C813, 
>>> and that image gets processed by imagecreatefromjpeg(), the function 
>>> returns false.
>>> 
>>> Our Devel Server Info [this works fine]
>>>        PHP Version : 5.2.6-3
>>>        GD Version: 2.0 or higher.
>>>        EXIF Version: 1.4
>>> 
>>> Our Live Server Info [this one is the one that fails]
>>>        PHP Version: 5.2.13
>>>        GD Version : 2.0.34 compatible
>>>        EXIF Version : 1.4
>>> 
>>> To see an example of this in action,
>>> 
>>> Working function : http://www.equipmentsearch.com/~jeff/tmp/image.php?i=w
>>> Not working function : 
>>> http://www.equipmentsearch.com/~jeff/tmp/image.php?i=n
>>> 
>>> http://www.equipmentsearch.com/~jeff/tmp/image.php.txt is the code.
>>> 
>>> Does anyone have any ideas or suggestions of where to look next?
>>> 
>>> Jeff.
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> 
>>> 
>> 
>> The @ is suppressing this notice ...
>> 
>> Notice: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
>> Corrupt JPEG data: 31 extraneous bytes before marker 0xd9
> 
It would seem our Devel server has GD 2.0.36

Our Live server has GD 2.0.34

So Presumably if i upgrade live it should work. 

Jeff.

> 
> -- 
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling


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

this is the solution I came up with, that is over 10 times faster than my
first attemps.

Tested @31,871 entries in table 'picture' and 222,712 entries in table
'picture_attrib_rel'. 

Old Version:

SELECT * FROM picture as p 

INNER JOIN picture_attrib_rel as pr1 
ON (p.pid = pr1.pid)

INNER JOIN  picture_attrib_rel as pr2 
ON (p.pid = pr2.pid and pr2.val_int < 1500)

WHERE pr1.aid = 2 AND pr1.val_int >= 1500 
AND pr2.aid = 5 AND pr2.val_int < 1000

Takes about 1.9 Seconds on average to return.

The version with temporary tables:

DROP temporary table if exists tmp_size;
DROP temporary table if exists tmp_qi;

CREATE temporary table tmp_size
  SELECT pid FROM picture_attrib_rel 
  WHERE aid = 2 AND val_int >= 1500;
CREATE temporary table tmp_qi
  SELECT pid FROM picture_attrib_rel 
  WHERE aid = 5 AND val_int < 1000;
        
SELECT pid,uid FROM tmp_size JOIN tmp_qi USING(pid) JOIN pictures
USING(pid);

DROP temporary table if exists tmp_size;
DROP temporary table if exists tmp_qi;

This takes 0.12 seconds to return, which is quite bearable for now. 


Thanks again for all your input!

Regards,
Jan


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jan Reiter [mailto:[email protected]]
> Sent: Wednesday, June 16, 2010 8:55 AM
> To: [email protected]
> Subject: Re: [PHP] SQL Syntax [improved SQL]
> 
> Hi,
> 
> this is the solution I came up with, that is over 10 times faster than my
first
> attemps.
> 
> Tested @31,871 entries in table 'picture' and 222,712 entries in table
> 'picture_attrib_rel'.
> 
> Old Version:
> 
> SELECT * FROM picture as p
> 
> INNER JOIN picture_attrib_rel as pr1
> ON (p.pid = pr1.pid)
> 
> INNER JOIN  picture_attrib_rel as pr2
> ON (p.pid = pr2.pid and pr2.val_int < 1500)
> 
> WHERE pr1.aid = 2 AND pr1.val_int >= 1500 AND pr2.aid = 5 AND pr2.val_int
<
> 1000
> 
> Takes about 1.9 Seconds on average to return.
> 
> The version with temporary tables:
> 
> DROP temporary table if exists tmp_size; DROP temporary table if exists
> tmp_qi;
> 
> CREATE temporary table tmp_size
>   SELECT pid FROM picture_attrib_rel
>   WHERE aid = 2 AND val_int >= 1500;
> CREATE temporary table tmp_qi
>   SELECT pid FROM picture_attrib_rel
>   WHERE aid = 5 AND val_int < 1000;
> 
> SELECT pid,uid FROM tmp_size JOIN tmp_qi USING(pid) JOIN pictures
> USING(pid);
> 
> DROP temporary table if exists tmp_size; DROP temporary table if exists
> tmp_qi;
> 
> This takes 0.12 seconds to return, which is quite bearable for now.
> 
> 
> Thanks again for all your input!
> 
> Regards,
> Jan

Jan,

What do you get from this query and how fast does it execute? 

SELECT * FROM picture_attrib_rel par INNER JOIN pictures p ON p.pid =
par.pid WHERE (par.aid = 2 AND par.val_int >= 1500) OR (par.aid = 5 AND
par.val_int < 1000)

Regards,
Tommy


--- End Message ---
--- Begin Message ---
Rob and Daniel:

As expected, both of your submission were excellent. If this was an assignment in one of my classes ("as if" I could teach either of you anything) you would both receive an A+.

Daniel's routine also returned .ie TLD, but that was not stated as a requirement.

Daniel's routine also allow for full-link parsing, but again that was not stated as a requirement.

How to deal with duplicate domains was not addressed in the given and both routines differed on that point.

The given was to parse domain-names, but both routines pulled out sub-domains as well. Perhaps I am wrong in my understanding of what a domain name is, but I would normally look at sub domains as not part of the "domain name". Sub domains are simply extensions of the domain name, am I right or wrong?

In any event, I will be examining both your code because neither is the way I solved the problem. Mine was a bit more verbose and clumsy in comparison. It's always nice to see how the top dog's do it.

Cheers,

tedd

PS: I've been away for the last couple of days.

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Wed, Jun 16, 2010 at 13:22, tedd <[email protected]> wrote:
>
> The given was to parse domain-names, but both routines pulled out
> sub-domains as well. Perhaps I am wrong in my understanding of what a domain
> name is, but I would normally look at sub domains as not part of the "domain
> name". Sub domains are simply extensions of the domain name, am I right or
> wrong?

    Technically, a domain name is anything from the TLD and SLD levels
and below.  An FQDN (commonly called a "hostname") is in the format
cname.sld.tld.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

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


Daniel P. Brown wrote:
On Wed, Jun 16, 2010 at 13:22, tedd <[email protected]> wrote:
The given was to parse domain-names, but both routines pulled out
sub-domains as well. Perhaps I am wrong in my understanding of what a domain
name is, but I would normally look at sub domains as not part of the "domain
name". Sub domains are simply extensions of the domain name, am I right or
wrong?

    Technically, a domain name is anything from the TLD and SLD levels
and below.  An FQDN (commonly called a "hostname") is in the format
cname.sld.tld.

Additionally, extracting top level domains is not so simple since it may have 2 or more parts.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
On 06/14/2010 08:14 AM, tedd wrote:
> Hi gang:
> 
> Considering all the recent parsing, here's another problem to consider
> -- given any text, parse the domain-names out of it.
> 
> You may limit the parsing to the most popular TDL's, such as .com, .net,
> and .org, but the finished result should be an array containing all the
> domain-names found in a text file.
> 
> Cheers,
> 
> tedd


Not extensively tested:

$domains = array();

if(preg_match_all('/[A-Za-z0-9][-A-Za-z0-9\.]*?\.(com|net|org)/i',
$text, $matches)) {
        $domains = array_unique($matches[0]);
}

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Just to clarify, we are looking for a single developer, not a team please.

Thanks!


On Mon, Jun 14, 2010 at 12:46 PM, Dev Job <[email protected]> wrote:

> Our company is looking to hire a PHP Developer for a short term project.
>  We're currently in the last couple weeks of the interview phase to narrow
> down our options.  We are looking for a developer that is comfortable
> working with existing code as well as creating new code.  You must be
> skilled in PHP and MySQL in addition to HTML and javascript.  Experience in
> jQuery is a plus!
>
> We're looking for candidates from the U.S. and UK only right now.
>
> If you meet the requirements and are intersted, please respond with a
> resume and contact information.
>
> We'll be making a decision in the next couple weeks, so please respond
> soon!
>

--- End Message ---
--- Begin Message ---
Hi people,
I would like to know the best way to perform some kind of validation
for an application that I've written.

I have a system that ask through an HTML Form some questions to users.
I use some cookies to save some information from the user side.

However, I would like to implement some code in PHP that would let me
limit to 1 the number of times that the page with the questions was
executed.

I mean, the user fills the HTML's Form, then send it through an HTML
Button, then PHP receives this informations and send an Email
containing the replies to the questions. I would like to limit to one,
the times one single user is able to execute this form.

I thought getting the IP Address, then doing some kind of validation
with it. However I don't know if using cookies is the best idea. I
don't have access to a DataBase for this. So I thought might be a good
idea write to a file in the server the IP, then perform some if to
know if the user already replied the form.

As far as I don't know which is the best way to code this, I felt free
to ask you guys.

Thanks a lot.

Juan

--- End Message ---
--- Begin Message ---
If this is an open site, using the IP won't be any good. We have over
200 people behind our NAT firewall, all of which would show up as coming
from the same IP on your server. Many other networks have the same or a
similar configuration.

If you only allow registered users, add a couple of flags to your user
table and set one of them when they fill out the form. Don't show them
the form after it is set. Having a couple, you can do a couple of
questionnaires simultaneously, and clear the matching flag when you
close the form.

Bob McConnell

-----Original Message-----
From: Juan Rodriguez Monti [mailto:[email protected]] 
Sent: Wednesday, June 16, 2010 2:26 PM
To: [email protected]
Subject: [PHP] User's IP Validation

Hi people,
I would like to know the best way to perform some kind of validation
for an application that I've written.

I have a system that ask through an HTML Form some questions to users.
I use some cookies to save some information from the user side.

However, I would like to implement some code in PHP that would let me
limit to 1 the number of times that the page with the questions was
executed.

I mean, the user fills the HTML's Form, then send it through an HTML
Button, then PHP receives this informations and send an Email
containing the replies to the questions. I would like to limit to one,
the times one single user is able to execute this form.

I thought getting the IP Address, then doing some kind of validation
with it. However I don't know if using cookies is the best idea. I
don't have access to a DataBase for this. So I thought might be a good
idea write to a file in the server the IP, then perform some if to
know if the user already replied the form.

As far as I don't know which is the best way to code this, I felt free
to ask you guys.

Thanks a lot.

Juan

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


--- End Message ---
--- Begin Message ---
Please, don't forget IP address can be same for many users. I see only way with 
cookies. When user deletes cookies, form pops up again. I don't know any better 
way.

David

Sent from my HTC

-----Original Message-----
From: Juan Rodriguez Monti <[email protected]>
Sent: 16. cervna 2010 20:26
To: [email protected]
Subject: [PHP] User's IP Validation

Hi people,
I would like to know the best way to perform some kind of validation
for an application that I've written.

I have a system that ask through an HTML Form some questions to users.
I use some cookies to save some information from the user side.

However, I would like to implement some code in PHP that would let me
limit to 1 the number of times that the page with the questions was
executed.

I mean, the user fills the HTML's Form, then send it through an HTML
Button, then PHP receives this informations and send an Email
containing the replies to the questions. I would like to limit to one,
the times one single user is able to execute this form.

I thought getting the IP Address, then doing some kind of validation
with it. However I don't know if using cookies is the best idea. I
don't have access to a DataBase for this. So I thought might be a good
idea write to a file in the server the IP, then perform some if to
know if the user already replied the form.

As far as I don't know which is the best way to code this, I felt free
to ask you guys.

Thanks a lot.

Juan

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




--- End Message ---

Reply via email to