Jump to content

bugzy

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by bugzy

  1. I thought it would be simple but it seemed like it's complicated. I want to use the $_FILE twice so that I could have two copy of the image with different names.. I'm doing it like this <?php //resizing image here $ext = ".". pathinfo($_FILES['uploaded_image']['name'], PATHINFO_EXTENSION); $target_path = "../images_item/"; $filename1 = $target_path . $last_id."_medium".$ext; $filename2 = $target_path . $last_id."_large".$ext; $copied1 = move_uploaded_file($_FILES['uploaded_image']['tmp_name'], $filename1); $copied2 = move_uploaded_file($_FILES['uploaded_image']['tmp_name'], $filename2); ?> $_FILES is coming from an html form. Tried it but it only upload once.. Any idea guys?
  2. I'm trying to resize an image on upload Here's the function <?php class SimpleImage { var $image; var $image_type; function me_resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); if( $this->image_type == IMAGETYPE_GIF || $this->image_type == IMAGETYPE_PNG ) { $current_transparent = imagecolortransparent($this->image); if($current_transparent != -1) { $transparent_color = imagecolorsforindex($this->image, $current_transparent); $current_transparent = imagecolorallocate($new_image, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); imagefill($new_image, 0, 0, $current_transparent); imagecolortransparent($new_image, $current_transparent); } elseif( $this->image_type == IMAGETYPE_PNG) { imagealphablending($new_image, false); $color = imagecolorallocatealpha($new_image, 0, 0, 0, 127); imagefill($new_image, 0, 0, $color); imagesavealpha($new_image, true); } } imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?> and I'm calling it like this <?php $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->me_resize(250,400); $image->save($_FILES['uploaded_image']['tmp_name']); ?> and I'm getting this error Any idea guys?
  3. imagecreatefromjpeg() doesn't do any resizing - it just converts a jpeg image to a GD image. From the word converting, so the original image will be a GD file now literally? and imagecreatefromjpeg() doesn't do any and image duplication? like the duplicate one will going to be the GD file? and the original will still be there as is? Just want to be sure guys..
  4. Just a side question guys... Does imagecreatefromjpeg() actually resize the original image on the server side, or it's being resize only on the end-user?
  5. I was researching on how will I able to resize an image on image retrieve and I got this function <?php function me_resize_jpeg( $original_image, $new_height, $new_width, $filename ) { // Resize the original image $image_resized = imagecreatetruecolor($new_width, $new_height); $image_tmp = imagecreatefromjpeg ($original_image); imagecopyresampled($image_resized, $image_tmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_resized, $filename.".jpg", 100); imagedestroy($image_resized); } ?> and I'm using it this way <?php $target_path = "../images_item/"; me_resize_jpeg($target_path.$edit_id.".jpg",'100','50',$target_path.$edit_id); ?> But I'm getting this error: The function is only asking for four parameters and I don't if the function is missing something... Anyone?
  6. Thanks for the suggestion DavidAM I'll definitely look into that.
  7. Thanks guys... I just use in_array.. instead of the complicated codes above.
  8. $ic_row is an array of arrays. You are searching for a scaler value; it will never be found. You probably meant to do $ic_row[$c] = mysql_result($ic_result, $c); This solves it. Thanks DavidAM!
  9. Thorpe I have this merge table name "item_category" where all items' categories are stored. It's all stored using an html checkbox What I'm trying to do, If I want to edit an item category, I'm want to retrieve those categories and check all the those that are listed as category in a checkbox. I'm trying to use "in_array" to store all the stored categories on an iteam. so it's like check all categories in_array(category1, category2) from table category using a forloop to display all categories. I wonder if this is possible using in_array?
  10. Hello.. It only showing those checkboxes that are "checked" and not those who are also "unchecked".. ?
  11. <?php $ic = "Select category_id from item_category where item_id = {$edit_id}"; $ic_result = mysql_query($ic,$connection) or die (mysql_error()); $ic_num = mysql_num_rows($ic_result); for($c = 0; $ic_num > $c; $c++) { $ic_row[$c] = mysql_fetch_array($ic_result); } for($i = 0; $cat_num > $i; $i++) { if(in_array(mysql_result($cat_result,$i,'cat_id'),$ic_row,TRUE)) { echo "<input type=\"checkbox\" name=\"item_cat[]\" value=". mysql_result($cat_result,$i,'cat_id') . " checked=\"checked\" />"; echo mysql_result($cat_result,$i,'cat_name'). "<br>"; } else { echo "<input type=\"checkbox\" name=\"item_cat[]\" value=". mysql_result($cat_result,$i,'cat_id') . " />"; echo mysql_result($cat_result,$i,'cat_name'). "<br>"; } } ?> It's bypassing the first condition and it goes straightly to the else condition... Anyone?
  12. Hello guys.. I have this loop <?php $cat_query = "Select cat_id, cat_name, cat_visibility from category where cat_id != 1 order by cat_position DESC"; $cat_result = mysql_query($cat_query,$connection); $cat_num = mysql_num_rows($cat_result); $ic = "Select category_id from item_category where item_id = {$edit_id}"; $ic_result = mysql_query($ic,$connection) or die (mysql_error()); $ic_num = mysql_num_rows($ic_result); for($i = 0; $cat_num > $i; $i++) { for($c = 0; $ic_num > $c; $c++) { if(mysql_result($ic_result,$c,'category_id') == mysql_result($cat_result,$i,'cat_id')) { echo "<input type=\"checkbox\" name=\"item_cat[]\" value=". mysql_result($cat_result,$i,'cat_id') . " checked=\"checked\" />"; echo mysql_result($cat_result,$i,'cat_name'). "<br>"; } else { echo "<input type=\"checkbox\" name=\"item_cat[]\" value=". mysql_result($cat_result,$i,'cat_id') . " />"; echo mysql_result($cat_result,$i,'cat_name'). "<br>"; } } } ?> the value I'm getting is being doubled like this I'm getting those categories that need to be check, problem is it doubles every value.. Anyone?
  13. Newbie question guys.. Just want to know the best approach on this before I code it. I have this merge table called "item_category" an item could have multiple rows base on how many categories the user chose. I have this on my mind... Delete all the item's rows(using item_ID PK) and then insert it again with the new one. So there's no update sql that will happen, only delete and insert... What do you think guys?
  14. Solved by myself using rtrim. Thanks guys!
  15. Thanks jesirose. It's working though I'm having problem with ","; Here's the new code <?php $query3 = "Update item_category SET category_id=1 where item_id IN ("; for($i=0;$i <= $row;$i++) { $get_id = mysql_result($result2, $i, 'Item'); if(mysql_result($result2,$i,'Total') == 1) { $query3 .= "$get_id,"; } } $query3 .= ")"; $result3 = mysql_query(trim($query3,','),$connection); ?> It's giving me How would I able to remove the comma on the last item_id?
  16. Hello guys base on my research seemed like I can't update multiple rows with different condition in one mysql query.. Any idea guys how can I put this in just one single query? I mean is there a work around?
  17. Again, as much as possible I don't want to put any sql query/statement inside a loop...
  18. Guys the problem is not is_numeric.. "0" digit will always return true using the empty function of php. I have tried if != ""; Not working also.. Any other good alternative for empty function??
  19. Newbie question guys... On my form <?php<input type="text" name="item_stock" size="3" value="<?php if(isset($_POST['submit']) AND is_numeric($_POST['item_stock'])) { echo $item_stock; } ?> I have this validation then <?php $item_stock = me_mysql_prep(trim($_POST['item_stock'])); //validation if(!is_numeric($_POST['item_stock']) AND !empty($_POST['item_stock'])) { $item_sto = ''; } else { $item_sto = "has stock"; } ?> On the validation, it keeps telling me that '0' is not numeric. I also tried using is_int.. but it's not working also.. Anyone?
  20. By that I mean the actual error message PHP gives you. AGain, it only happened when I change the code from my above post.. Maybe I'm putting the first statement on the wrong way?
  21. From this code <?php for($i=0;$i <= $row;$i++) { $get_id = mysql_result($result2, $i, 'Item'); if(mysql_result($result2,$i,'Total') == 1) { $query3 = "Update item_category set category_id=1 where item_id = {$get_id}"; $result3 = mysql_query($query3,$connection) or die (mysql_error()); } } ?> to this <?php $query3 = "Update item_category "; for($i=0;$i <= $row;$i++) { $get_id = mysql_result($result2, $i, 'Item'); if(mysql_result($result2,$i,'Total') == 1) { $query3 .= "SET category_id=1 where item_id = {$get_id},"; } } $result3 = mysql_query(trim($query3,','),$connection) or die (mysql_error()); ?> I have change only the Update portion inside the for loop because I don't want to put a sql statement inside a loop, and I got an error already... Maybe I'm parsing it the wrong way or I place it on top of the loop which interfere it? Anyone?
  22. When I tried to parse it, the code suddenly is gibing me an error <?php $query3 = "Update item_category "; for($i=0;$i <= $row;$i++) { $get_id = mysql_result($result2, $i, 'Item'); if(mysql_result($result2,$i,'Total') == 1) { $query3 .= "SET category_id=1 where item_id = {$get_id},"; } } $result3 = mysql_query(trim($query3,','),$connection) or die (mysql_error()); ?> I believe that I'm parsing the update statement the wrong way.. Anyone?
×
×
  • 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.