Jump to content

zq29

Staff Alumni
  • Posts

    2,752
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by zq29

  1. This should get you on your way...
    [code]<?php
    function thumbnail($image_path,$thumb_path,$image_name) {
        $max_width = 75;
        $max_height = 75;

        $size = getimagesize($image_path.$image_name);
        $width = $size[0];
        $height = $size[1];

        if($width != FALSE && $height != FALSE) {
            $x_ratio = $max_width / $width;
            $y_ratio = $max_height / $height;

            if(($width <= $max_width) && ($height <= $max_height)) {
                $disp_width = $width;
                $disp_height = $height;
            } elseif(($x_ratio * $height) < $max_height) {
                $disp_height = ceil($x_ratio * $height);
                $disp_width = $max_width;
            } else {
                $disp_width = ceil($y_ratio * $width);
                $disp_height = $max_height;
            }
        } else {
            return false;
        }

        $src_img = imagecreatefromjpeg($image_path.$image_name);
        $dst_img = imagecreatetruecolor($disp_width,$disp_height);

        imagecopyresized($dst_img,$src_img,0,0,0,0,$disp_width,$disp_height,imagesx($src_img),imagesy($src_img));
        imagejpeg($dst_img, $thumb_path.$image_name);
        return true;
    }
    ?>[/code]
  2. I've never done this before, but here's where I'd start if I wanted to:
    [0] Read the documentation for your mail server software
    [0] Figure out how to create an account with the command line
    [0] Use PHPs system functions to run these commands

    As far as building the interface for your users to log in and check their mail, I'd read though the section of the PHP manual entitled [url=http://uk2.php.net/manual/en/ref.imap.php]LXIII. IMAP, POP3 and NNTP Functions[/url].
  3. [quote author=fenway link=topic=107126.msg429417#msg429417 date=1157566652]
    No problem... you were simply returning N**3 rows.  I've done that before, on a 4-table join, before I switched to join syntax, and accidentally return >9 trillion records.  That'll take down a server real fast, trust me.
    [/quote]All I did was remove references to tables I wasn't actually using from the 'FROM' part of my query. Would it be possible for you to elaborate on what you mean by 'join syntax'? I've done a bit of searching here and there and I can only find references to left and right joins, and I don't think that is what I need here...
  4. Hi guys, I'm having a problem with a query that is generated by some PHP code. Here's the first which pretty much just crashes my machine, I have to kill the mysql process to get my machine back in a useable state:
    [code]SELECT DISTINCT(l.`company`), l.`id`, l.`bullets`, l.`level`, l.`address_1`, l.`address_2`, l.`town`, l.`postcode`, l.`telephone`, l.`email`, l.`map`, l.`website`
    FROM `listings` as l, `listing_category` as lc, `categories` as c
    WHERE ((l.`company` LIKE '% car %' OR l.`company` LIKE 'car %' OR l.`company` LIKE '% car' OR l.`company` LIKE 'car'))
    ORDER BY l.`level` DESC, l.`top` ASC, l.`company` ASC[/code]
    And here's the second query, that is pretty much the same as the one above, except that it queries a different table, this one returns results instantly:
    [code]SELECT DISTINCT(l.`company`), l.`id`, l.`bullets`, l.`level`, l.`address_1`, l.`address_2`, l.`town`, l.`postcode`, l.`telephone`, l.`email`, l.`map`, l.`website`
    FROM `listings` as l, `listing_category` as lc, `categories` as c
    WHERE (((c.`name` LIKE '% car %' OR c.`name` LIKE 'car %' OR c.`name` LIKE '% car' OR c.`name` LIKE 'car') AND c.`id`=lc.`category_id` AND lc.`listing_id`=l.`id`))
    ORDER BY l.`level` DESC, l.`top` ASC, l.`company` ASC[/code]

    Can anyone offer any insight as to why the first one is giving me problems?

    Oh, the first table holds around 3000 records, the second about 500. Could this be the reason? If so, any ideas on how to optimise the queries?
  5. [quote author=redarrow link=topic=106956.msg429089#msg429089 date=1157540375]
    I went to the link as you said and looked at the website and had a play, the way the website desiner has acheved this function is using a search function.
    [/quote]Thanks for that contribution redarrow...
  6. I don't think this is an Apache configuration issue - I know what you mean though as a site I visit regularly doesn't display full sized images in FireFox, I just get a bunch of garbage text. I have a feeling it's an OS issue, but I don't know for sure. But as far as I know, there are no configuration options for image support in Apache.
  7. Does the company you bought the domain from have a forwarding service? I get all my domains from 123-reg.co.uk and I have the option to forward my domains somewhere else but keep the forwarding domain in the location bar. It's probably done with frames or something...
  8. I think I understand, but why are several records getting the same ID? If the user closes his browser 6 times and then pays on the 7th, I'd assume you'd only want the seventh basket marked as paid with the other 6 being left marked as 'abandoned basket'.

    Why are you storing the baskets in a temporary table anyway? For saving abandoned baskets, or so that if a user does close their browser their basket is saved for their next visit? Even still, I don't understand how you're getting duplicate rows in the table...
  9. I take it that your code is deleting all of the rows with the supplied id, and not just the duplicates, right? I think it might help if you use a LIMIT in your DELETE query...
    [code]<?php
    $result = mysql_query("SELECT * FROM `payment_info` WHERE `id`='$id'") or die(mysql_error());
    $count = mysql_num_rows($result);
    if($count > 1) {
        $limit = $count - 1;
        mysql_query("DELETE FROM `payment_info` WHERE `id`='$id' LIMIT $limit") or die(mysql_error());
    }
    ?>[/code]

    ID fields are commonly regarded as unique fields, if you are finding you have ID fields with the same numbers in you have a problem somewhere. Deleting those fields is not the solution, preventing them from appearing in the first place would be more ideal.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.