Jump to content

jakebur01

Members
  • Content count

    837
  • Joined

  • Last visited

Community Reputation

0 Neutral

About jakebur01

  • Rank
    Prolific Member
  • Birthday 06/23/1986

Profile Information

  • Gender
    Male
  • Location
    USA
  1. jakebur01

    best way to set up tables

    What are a few sources for learning the basics?
  2. jakebur01

    best way to set up tables

    I've read some of your posts and I feel like you come across as insulting to some of the members who are only trying to learn. You are very smart in the area of PHP and MySQL. I realize some are only looking for someone to write their script instead of learn. But, other people are not likely to come back if they feel stupid every time they post code and ask a question.
  3. jakebur01

    best way to set up tables

    How about something like this?: Type id model make category multiple view_all 0 View all F150 Ford Truck F150 Y 1 F150a Ford Truck F150 N 2 F150b Ford Truck F150 N 3 F150c Ford Truck F150 N 4 Viper1 Jetski Boat N 5 Viper2 Jetski Boat N 6 View all Viper3 Jetski Boat Viper3 Y 7 Viper3 Jetski Boat Viper3 N 8 Viper3a Jetski Boat Viper3 N 9 View all Loco2 Train Loco2 Y 10 Loco2 Heavy8 Train Loco2 N 11 Loco2a Heavy8 Train Loco2 N 12 Loco4 Heavy8 Train N
  4. jakebur01

    best way to set up tables

    Yes but there will be cases when I will have multiple versions of a model that are not a series of like versions. My current setup is something like this: Type id model make category multiple 1 F150a Ford Truck F150 2 F150b Ford Truck F150 3 F150c Ford Truck F150 4 Viper1 Jetski Boat 5 Viper2 Jetski Boat 6 Viper3 Jetski Boat Viper3 7 Viper3a Jetski Boat Viper3 8 Loco2 Heavy8 Train Loco2 9 Loco2a Heavy8 Train Loco2 10 Loco4 Heavy8 Train In the case above, F150, Viper3, and Loco2 are the only ones that have multiple versions of the same model.
  5. jakebur01

    best way to set up tables

    Say you have the following: 1 Sample1a 2 Sample1b 3 Sample1c 4 Sample1d 5 Sample2 6 Sample3 7 Sample3a 8 Sample3b I need to be able to display the data in the following format: View all Sample1 Models Sample1a Sample1b Sample1c Sample2 View all Sample3 Models Sample3 Sample3a Sample3b So, in a select box or a list of links I need to put a "View all" of this model if it has multiple versions of the model. A, B, C, D, etc. I didn't know the best way to do this. Should I add an additional column and put Sample1 in it on the Sample1a, Sample1b, etc. columns. Or should I create another table and use the id's from the first table and add Sample1 next to them. The next issue is how to do the query to where I can stick a View all of this model every time you come to a model that has multiple versions.
  6. jakebur01

    I am not getting an image save using imagejpeg()

    I moved it below the : //Resize image to our Specified Size by calling resizeImage function. if($processImage && resizeImage($CurWidth,$CurHeight,$BigImageMaxSize,$DestRandImageName,$CreatedImage,$Quality,$ImageType[$i])) { //Create a square Thumbnail right after, this time we are using cropImage() function if(!cropImage($CurWidth,$CurHeight,$ThumbSquareSize,$thumb_DestRandImageName,$CreatedImage,$Quality,$ImageType[$i])) { echo 'Error Creating thumbnail'; } } Now it works!
  7. jakebur01

    I am not getting an image save using imagejpeg()

    I could try it. Although, it doesn't have any trouble replacing it in the standalone test script without the upload code. Thank's for pointing that out. I'll determine the filetype and change the image***() accordingly. I wonder if it is still processing the image when it is trying to access it. In other words, when the watermark script is trying to access the image, it doesn't see it because the upload script hasn't finished creating it?
  8. jakebur01

    I am not getting an image save using imagejpeg()

    This a regular image upload script I've had and used for a long time. The time has come where I need to add a watermark on images for a particular site. The image upload part is working correctly, meaning the regular upload script puts an image and thumbnail into the directory. I'm attempting to add in this watermark code to watermark the image after it has been resized and put in the directory. You'll see I added the watermark code in after the resizeImage function of the upload script. However, the watermark code is not taking the image and resaving it to the directory. It will in the script above output it to the browser if I comment out the imagejpeg and uncomment the header and imgpng, etc. If I take the watermark code alone and put it in a separate test.php and key in the relative paths to the image that was uploaded using the upload script, it will work and resave the image with the watermark. So, there must be something in the upload script that is conflicting with the watermark script I've added in. When I get home I'll try repositioning it. I may try moving it to after the thumbnail is created and see if it works there.
  9. jakebur01

    I am not getting an image save using imagejpeg()

    The file is writable When I take away the rest of the upload code and put the watermark code on it's on page and manually enter paths for the variables it overrites the image in the directory with the watermarked image fine. There must be something in my surrounding upload code that's throwing a wrench in things.
  10. $watername is writable and when I echo $watername it shows the full path and filename to the image. The upload process that goes on before this watermark code does fine and the image and thumbnail is going into the directory fine. The image outputs to the browser fine with the watermark logo when I uncomment that part of the code out. I'm not sure why it's not saving/replacing the file in the directory. I'm also not getting any errors when I turn reporting E_ALL on. It does work when I create a blank test page with only watermark part of the code and manually type in the paths. <?php error_reporting(E_ALL); $listingid = 0; $primaryimage=0; $valid_formats = array("jpg", "png", "gif", "bmp"); $max_file_size = 100 * 1024 * 1024; //100 mb $path = "UploadImages/test/images/"; // Upload directory $count = 0; //Some Settings $ThumbSquareSize = 167; //Thumbnail will be 200x200 $BigImageMaxSize = 800; //Image Maximum height or width $ThumbPrefix = "thumb_"; //Normal thumb Prefix $DestinationDirectory = "UploadImages/test/images/"; //Upload Directory ends with / (slash) $Quality = 90; ini_set('memory_limit', '-1'); // maximum memory! if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){ // Loop $_FILES to execute all files //foreach ($_FILES['files']['name'] as $f => $name) { // some information about image we need later. $ImageName = $_FILES['files']['name']; $ImageSize = $_FILES['files']['size']; $TempSrc = $_FILES['files']['tmp_name']; $ImageType = $_FILES['files']['type']; if (is_array($ImageName)) { $c = count($ImageName); for ($i=0; $i < $c; $i++) { $processImage = true; $RandomNumber = rand(0, 9999999999); // We need same random name for both files. if(!isset($ImageName[$i]) || !is_uploaded_file($TempSrc[$i])) { echo '<h3>Error occurred while trying to process'.$ImageName[$i].', may be file too big!</h3>'; //output error } else { //Validate file + create image from uploaded file. switch(strtolower($ImageType[$i])) { case 'image/png': $CreatedImage = imagecreatefrompng($TempSrc[$i]); break; case 'image/gif': $CreatedImage = imagecreatefromgif($TempSrc[$i]); break; case 'image/jpeg': case 'image/pjpeg': $CreatedImage = imagecreatefromjpeg($TempSrc[$i]); break; default: $processImage = false; //image format is not supported! } //get Image Size list($CurWidth,$CurHeight)=getimagesize($TempSrc[$i]); //Get file extension from Image name, this will be re-added after random name $ImageExt = substr($ImageName[$i], strrpos($ImageName[$i], '.')); $ImageExt = str_replace('.','',$ImageExt); //Construct a new image name (with random number added) for our new image. $NewImageName = $RandomNumber.'.'.$ImageExt; //Set the Destination Image path with Random Name $thumb_DestRandImageName = $DestinationDirectory.$ThumbPrefix.$NewImageName; //Thumb name $DestRandImageName = $DestinationDirectory.$NewImageName; //Name for Big Image $watername = $DestRandImageName; resizeImage($CurWidth,$CurHeight,$BigImageMaxSize,$DestRandImageName,$CreatedImage,$Quality,$ImageType[$i]); // Load the stamp and the photo to apply the watermark to $stamp = imagecreatefrompng('images/logo.png'); $im = imagecreatefromjpeg("$watername"); // Set the margins for the stamp and get the height/width of the stamp image $marge_right = 10; $marge_bottom = 10; $sx = imagesx($stamp); $sy = imagesy($stamp); // Copy the stamp image onto our photo using the margin offsets and the photo // width to calculate positioning of the stamp. imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); // Output and free memory //header('Content-type: image/png'); //imagepng($im); /* $filename = "$watername"; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; } */ //echo "$watername"; imagejpeg($im, $watername , 90); imagedestroy($im); //Resize image to our Specified Size by calling resizeImage function. if($processImage && resizeImage($CurWidth,$CurHeight,$BigImageMaxSize,$DestRandImageName,$CreatedImage,$Quality,$ImageType[$i])) { //Create a square Thumbnail right after, this time we are using cropImage() function if(!cropImage($CurWidth,$CurHeight,$ThumbSquareSize,$thumb_DestRandImageName,$CreatedImage,$Quality,$ImageType[$i])) { echo 'Error Creating thumbnail'; } } /*At this point we have succesfully resized and created thumbnail image We can render image to user's browser or store information in the database For demo, we are going to output results on browser. //Get New Image Size // list($ResizedWidth,$ResizedHeight)=getimagesize($DestRandImageName); echo '<table width="100%" border="0" cellpadding="4" cellspacing="0">'; echo '<tr>'; echo '<td align="center"><img src="uploads/'.$ThumbPrefix.$NewImageName.'" alt="Thumbnail" height="'.$ThumbSquareSize.'" width="'.$ThumbSquareSize.'"></td>'; echo '</tr><tr>'; echo '<td align="center"><img src="uploads/'.$NewImageName.'" alt="Resized Image" height="'.$ResizedHeight.'" width="'.$ResizedWidth.'"></td>'; echo '</tr>'; echo '</table>'; /* // Insert info into database table! mysql_query("INSERT INTO myImageTable (ImageName, ThumbName, ImgPath) VALUES ($DestRandImageName, $thumb_DestRandImageName, 'uploads/')"); }else{ echo '<h3>Error occurred while trying to process <strong>'.$ImageName[$i].'</strong>! Please check if file is supported</h3>'; //output error } */ } } } /* if ($_FILES['files']['error'][$f] == 4) { continue; // Skip file if any error found } if ($_FILES['files']['error'][$f] == 0) { if ($_FILES['files']['size'][$f] > $max_file_size) { $message[] = "$name is too large!."; continue; // Skip large files } elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){ $message[] = "$name is not a valid format"; continue; // Skip invalid file formats } else{ // No error found! Move uploaded files $ext = end(explode('.', $name)); $newname = rand(10,10000) . rand(10,1000) . "." . "$ext"; if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$newname)) { $count++; // Number of successfully uploaded files } } } */ //} } // This function will proportionally resize image function resizeImage($CurWidth,$CurHeight,$MaxSize,$DestFolder,$SrcImage,$Quality,$ImageType) { //Check Image size is not 0 if($CurWidth <= 0 || $CurHeight <= 0) { return false; } //Construct a proportional size of new image $ImageScale = min($MaxSize/$CurWidth, $MaxSize/$CurHeight); $NewWidth = ceil($ImageScale*$CurWidth); $NewHeight = ceil($ImageScale*$CurHeight); if($CurWidth < $NewWidth || $CurHeight < $NewHeight) { $NewWidth = $CurWidth; $NewHeight = $CurHeight; } $NewCanves = imagecreatetruecolor($NewWidth, $NewHeight); // Resize Image if(imagecopyresampled($NewCanves, $SrcImage,0, 0, 0, 0, $NewWidth, $NewHeight, $CurWidth, $CurHeight)) { switch(strtolower($ImageType)) { case 'image/png': imagepng($NewCanves,$DestFolder); break; case 'image/gif': imagegif($NewCanves,$DestFolder); break; case 'image/jpeg': case 'image/pjpeg': imagejpeg($NewCanves,$DestFolder,$Quality); break; default: return false; } if(is_resource($NewCanves)) { imagedestroy($NewCanves); } return true; } } //This function corps image to create exact square images, no matter what its original size! function cropImage($CurWidth,$CurHeight,$iSize,$DestFolder,$SrcImage,$Quality,$ImageType) { //Check Image size is not 0 if($CurWidth <= 0 || $CurHeight <= 0) { return false; } //abeautifulsite.net has excellent article about "Cropping an Image to Make Square" //http://www.abeautifulsite.net/blog/2009/08/cropping-an-image-to-make-square-thumbnails-in-php/ if($CurWidth>$CurHeight) { $y_offset = 0; $x_offset = ($CurWidth - $CurHeight) / 2; $square_size = $CurWidth - ($x_offset * 2); }else{ $x_offset = 0; $y_offset = ($CurHeight - $CurWidth) / 2; $square_size = $CurHeight - ($y_offset * 2); } $NewCanves = imagecreatetruecolor($iSize, $iSize); if(imagecopyresampled($NewCanves, $SrcImage,0, 0, $x_offset, $y_offset, $iSize, $iSize, $square_size, $square_size)) { switch(strtolower($ImageType)) { case 'image/png': imagepng($NewCanves,$DestFolder); break; case 'image/gif': imagegif($NewCanves,$DestFolder); break; case 'image/jpeg': case 'image/pjpeg': imagejpeg($NewCanves,$DestFolder,$Quality); break; default: return false; } if(is_resource($NewCanves)) { imagedestroy($NewCanves); } return true; } } ?> P.S. Where did everybody go? It's been a few years since I was last on here, but there was a lot more activity back then.
  11. jakebur01

    Trouble displaying two images per row

    That's correct mac_gyver. There are not any missing images. I saw that after I used print_r ($images) like nik_jain suggested. How could I alter the code so that the first row will display two images?
  12. jakebur01

    Trouble displaying two images per row

    It's only image #2. If I have 29 images, #2 is the only one missing. I looked at the source and the image is missing all together. <img width = "200" src='PW-Files/10/images/1255967188.jpg'><br><img width = "200" src='PW-Files/10/images/1279977704.jpg'><img width = "200" src='PW-Files/10/images/1831679637.jpg'><br><img width = "200" src='PW-Files/10/images/2652035406.jpg'><img width = "200" src='PW-Files/10/images/3335979548.jpg'><br><img width = "200" src='PW-Files/10/images/4176309676.jpg'><img width = "200" src='PW-Files/10/images/428132950.jpg'><br><img width = "200" src='PW-Files/10/images/5397313372.jpg'><img width = "200" src='PW-Files/10/images/5406659459.jpg'><br><img width = "200" src='PW-Files/10/images/6463512950.jpg'><img width = "200" src='PW-Files/10/images/6660251971.jpg'><br><img width = "200" src='PW-Files/10/images/6978163793.jpg'><img width = "200" src='PW-Files/10/images/7276068595.jpg'><br><img width = "200" src='PW-Files/10/images/775470584.jpg'><img width = "200" src='PW-Files/10/images/871558021.jpg'><br><img width = "200" src='PW-Files/10/images/8794863931.jpg'><img width = "200" src='PW-Files/10/images/8799152527.jpg'><br><img width = "200" src='PW-Files/10/images/9769868608.jpg'><img width = "200" src='PW-Files/10/images/9896351471.jpg'><br>
  13. I am trying to display two images per row. Will add in table tags later so it will look nicer. Anyway, it is leaving off the second image. So, I have 6 images and image number two is blank. $dirname = "Files/$listingid/images/"; $images = glob($dirname."*"); /* $html .= '<table width="100%">'; foreach($images as $image){ $html .= "<tr><td><center>"; $html .="<img src=\"$image\" width=\"300\">"; $html .= "</a></center></td>"; $html .= "</td></tr>"; } $html .= "</table>"; */ $countImages = count($images) ; $imagesPerRow = 2; for ($i = 0 ; $i < $countImages; $i++) { //display image here $image = $images[$i] ; $html .= "<img width = \"200\" src='$image'>" ; if ($i % $imagesPerRow == 0) { //have displayed an entire row $html .= '<br>' ; } }
  14. jakebur01

    mpdf and google static maps api

    CroNiX I have a license. Besides that doesn't make any sense to me. Google Earth Pro lets you export images and pdf's. Right now they can print a picture of the map off of the webpage, my only problem is that I have my content ( details, images, etc.) in tabs. So, If you print the page you are only going to get whats displayed in the active tab. By putting everything on pages in a pdf that will allow them to print everything they need on individual pages. Or I could e-mail them a copy to print. I'm not doing anything illegal, they would print the map anyway.
×

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.