Jump to content

cmgmyr

Members
  • Posts

    1,278
  • Joined

  • Last visited

    Never

Posts posted by cmgmyr

  1. if you have a user id in the table that is associated with the zip before you do the insert you can see if there are any records where the user and the zip are the same as that wants to do the insert.

     

    So:

    1. Do select statement

    2. count rows

    3.

     

    if($count == 0){

    //Insert statement

    }

     

    And you are done. So they can reload the page as much as they want and it will only insert once

  2. Hey Guys,

    This is my script that I use for image resizing. I have a client on php5 and now i'm just getting those little red x's. He does have GD library and it is running. What do I need to change in order for it to work?

     

    <?php
    
       header("Content-type: image/jpeg");
       $source = imagecreatefromjpeg($src);
       $orig_w=imagesx($source);
       $orig_h=imagesy($source);
       
       //See if there is a different height and width
       
       if(!$_GET['wmax']){
       		$wmax=100;
       }
       if(!$_GET['hmax']){
       		$hmax=100;
       }
       $quality=90;
       $bgcol=000000;
       
       if ($orig_w>$wmax || $orig_h>$hmax)
       {
           $thumb_w=$wmax;
           $thumb_h=$hmax;
           if ($thumb_w/$orig_w*$orig_h>$thumb_h) 
               $thumb_w=round($thumb_h*$orig_w/$orig_h); 
           else 
               $thumb_h=round($thumb_w*$orig_h/$orig_w);
       } else
       {
           $thumb_w=$orig_w;
           $thumb_h=$orig_h;
       }
       if (!@$bgcol)
       {
           $thumb=imagecreatetruecolor($thumb_w,$thumb_h);
           imagecopyresampled($thumb,$source,
                               0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h);
       }
       else
       {
           $thumb=imagecreatetruecolor($wmax,$hmax);
           imagefilledrectangle($thumb,0,0,$wmax-1,$hmax-1,intval($bgcol,16));
           imagecopyresampled($thumb,$source,
                               round(($wmax-$thumb_w)/2),round(($hmax-$thumb_h)/2),
                               0,0,$thumb_w,$thumb_h,$orig_w,$orig_h);
       }
       if (!@$quality) $quality=90;
       imagejpeg($thumb,"",$quality);
       imagedestroy($thumb);
    ?> 
    

     

    Thanks,

    -Chris

  3. Hey guys, thanks for the help. What I did is just at another statement for php5 ... to do nothing. When I uploaded it everything worked great. Here it is:

    <?php
    $phpver = phpversion();
    if ($phpver < '4.1.0') {
    $_GET = $HTTP_GET_VARS;
    $_POST = $HTTP_POST_VARS;
    $_SERVER = $HTTP_SERVER_VARS;
    }
    
    if($phpver > '5.0'){
    //Do nothing
    }
    else if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) {
    if (extension_loaded('zlib')) {
    	ob_end_clean();
    	ob_start('ob_gzhandler');
    }
    } else if ($phpver > '4.0') {
    if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    	if (extension_loaded('zlib')) {
    		$do_gzip_compress = TRUE;
    		ob_start(array('ob_gzhandler',5));
    		ob_implicit_flush(0);
    	}
    }
    }
    $phpver = explode(".", $phpver);
    $phpver = "$phpver[0]$phpver[1]";
    if ($phpver >= 41) {
    $PHP_SELF = $_SERVER['PHP_SELF'];
    }
    
    if (!ini_get("register_globals")) {
    import_request_variables('GPC');
    }
    
    ?>

     

    Is this right? (it works :))

  4. Ok here is what I have right now:

    <?php
    $phpver = phpversion();
    if ($phpver < '4.1.0') {
    $_GET = $HTTP_GET_VARS;
    $_POST = $HTTP_POST_VARS;
    $_SERVER = $HTTP_SERVER_VARS;
    }
    if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) {
    if (extension_loaded('zlib')) {
    	ob_end_clean();
    	ob_start('ob_gzhandler');
    }
    } else if ($phpver > '4.0') {
    if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    	if (extension_loaded('zlib')) {
    		$do_gzip_compress = TRUE;
    		ob_start(array('ob_gzhandler',5));
    		ob_implicit_flush(0);
    	}
    }
    }
    $phpver = explode(".", $phpver);
    $phpver = "$phpver[0]$phpver[1]";
    if ($phpver >= 41) {
    $PHP_SELF = $_SERVER['PHP_SELF'];
    }
    
    if (!ini_get("register_globals")) {
    import_request_variables('GPC');
    }
    
    ?>

     

    Right now I have a client with php 5.1.6 and currently this script makes it freeze up. How can I make this compatable with PHP 5?

     

    Thanks,

    -Chris

×
×
  • 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.