Jump to content

leitning_strike

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

leitning_strike's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I don't see a input with the name 'Initials' in your form anywhere
  2. that is the right code... if you are getting that error then you have a mistake in a different place... maybe spaces/special characters in the $name variable?... use it enclosed in ' EDIT: I just read that you figure it out... good yeah, thanks though
  3. Ah I'm a bleeping idiot (or I've been up way too long). I forgot the single quotes around $name in the query
  4. RE Muddy Funster: There's no error on the upload, it proceeds to resize, thumbnail and add to the database, but it does so as a duplicate file name RE Maq: Obviously I'm testing it with a duplicate file name RE mikosiko: I tried that but I get a 'supplied argument is not a valid mysql resource' warning and still no loop
  5. I've got a script where the client can upload pictures. The pictures are then resized, thumbnailed, and added to the database. In the process I'm trying to search the database for a duplicate file name and create a new name if necessary: $userfile = 'userfile' . $i; $tmpLoc = $_FILES[$userfile]['tmp_name']; $name = $_FILES[$userfile]['name']; $error = $_FILES[$userfile]['error']; $type = $_FILES[$userfile]['type']; $temp = 'album' . $i; $album = $_POST[$temp]; if($error > 0) { echo "Error on $name: "; switch ($error) { case 1: echo "File exceeded upload_max_filesize"; break; case 2: echo "File exceeded max_file_size"; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } echo "</div>"; exit; } // Check for name duplicates and deal with $query = "SELECT * FROM pictures WHERE src = $name"; $result = mysql_query($query); if($result) $dup = true; while($dup) { echo "Duplicate file name $name <br />"; $ext; if($type == 'image/gif') $ext = '.gif'; else if($type == 'image/jpeg') $ext = '.jpg'; else if($type == 'image/png') $ext = '.png'; else die("Error: Unsupported file type"); $x = 0; $name = $x . $ext; echo "Checking $name <br />"; $query = "SELECT * FROM pictures WHERE src = $name"; $result = mysql_query($query); if(!$result) { $dup = false; echo "File successfully renamed to $name to avoid duplicate <br />"; } $x++; } I don't get any errors of any sort, it just never enters the loop
  6. Still don't get where you're getting %d from? Don't you need to do: $sql = sprintf("INSERT INTO messages (firstname, intItemID, message) VALUES ('$name', '%d', '$message')", $intItemID);
  7. You could fetch the number of items in the drop down menu and dynamically calculate/set the height of the div. And if it's going under another element set the z-index high.
  8. You're using UPDATE syntax for an INSERT query $sql = " INSERT INTO messages SET firstname = '$name', intItemID = '%d', message = '$message'" should be $sql = "INSERT INTO messages (firstname, intItemID, message) VALUES ('$name', '%d', '$message')";
  9. Started working. Not sure what happened, didn't change any code between not working and working, but thanks anyway.
  10. Not sure if I understood your question but you could add a column with a name along the lines of 'hex', and associate hexadecimal codes with the names. Then when you want to write it you can do something like: $query = "SELECT * FROM regUsers"; $result = mysql_query($query); $n = mysql_num_rows($result); for($i = 0; $i < $n; $i++) { $row = mysql_fetch_object($result); echo "<p style='color:" . $row->hex . "'>" . $row->name . "</p><br />"; }
  11. Include the original text in a hidden input type and check whether the hidden input and textarea input match
  12. I'm working on a fairly straight forward facet of an image gallery application where the client can upload a zip file full of photos and it extracts them one by one to a temp folder, resizes it and moves it to the pic folder, creates a thumbnail, then deletes it from the temp folder All that works fine, but I'm testing it in a situation where I'm uploading a 56 MB zip file, my max_file_size is 128 MB, and it gives me the 'max_file_size' error. Anyone else ever have this problem or have any ideas on how to solve it?
  13. Just got done working on a similar problem. You can do it with GD, but GD will make it look terrible when resizing, so I used ImageMagick from the command line, but you must have it installed on your server. First, use GD to figure out the dimensions of your new image with ratios: $picName = // The name of the image file $picDir = // The directory the image file is stored in $picPath = $picDir . $picName; // Get the original size of the image $info = getimagesize($picPath); $width = $info[1]; $height = $info[2]; // Set the max sizes $maxWidth = 300; $maxHeight = 320; // Compute Max to Original Ratios $xRatio = $maxWidth / $width; $yRatio = $maxHeight / $height; // Set New Sizes // If original size is fine if(($xRatio >= 1) && ($yRatio >= 1)) { $newWidth = $width; $newHeight = $height; } // If vertically long else if($height > $width) { $newHeight = $maxHeight; $newWidth = ceil($width * $yRatio); } // If horizontally long else { $newHeight = ceil($height * $xRatio); $newWidth = $maxWidth; } Once you have your new dimensions (and are able to call ImageMagick from the command line) you can execute the command 'mogrify' to resize an image without changing it's path or 'convert' to resize and move an image. I'll show both here, resizing the original and then creating a thumbnail with dimensions 70x70. $thumbPath = $picDir . '/thumbs/' . $picName; $resizeIt = 'mogrify -resize ' . $newWidth . 'x' . $newHeight . ' ' . $picPath; exec($resizeIt); $thumbIt = 'convert ' . $picPath . ' -resize 70x70 ' . $thumbPath; exec($thumbIt); Hope that helps
×
×
  • 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.