Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    7

    Unanswered: update function in mysql and php

    i've some trouble about update in mysql...this is my senario guyz, i can update the title,content,image of the product but if i will not update the image then save it directly the image will no longer display and the what I've stored in the database the path was change. My problem is, how i can make a condition statement if the file is set then it will still the same but if not then it change the new picture been uploaded this my code for that but it's function:


    if(isset($_REQUEST['hidden_file'])){ <!-- this how i check if the picture is updated or not !>
    $strProdImg=$_REQUEST['hidden_file'];
    //$strProdImg = "picture";

    }
    if(isset($_FILES['file'])){
    //$strProdImg = "picz";
    $strProdImg=$_FILES['file']['name'];
    $tmp_name=$_FILES['file']['tmp_name'];
    $strProdImg = "../../upload/productImage/". $strProdImg;
    move_uploaded_file($tmp_name,$strProdImg);
    }
    <!-- end of my condition !>



    $strID= QuerySafeString(strtoupper($_REQUEST["txtID"]));
    $strTitle= QuerySafeString($_REQUEST["txtTitle"]);
    $strDescription= QuerySafeString($_REQUEST["txtDescription"]);
    //$ProdImg = QuerySafeString($_FILES["file"]);
    $id=$_REQUEST['id'];





    if (($strID !="") && ($strID!="0"))
    {
    $strsql="UPDATE product SET prod_name='" . SQLSafeString($strTitle) ;
    $strsql.= "',prod_description ='" . SQLSafeString($strDescription) ;
    $strsql.= "',img_prod ='" . $strProdImg ;





    $strsql.= "' WHERE prod_id=" . SQLSafeString($strID);
    $var1=$conclass->Execute ($strsql,$strErrorMessages);
    if ($strErrorMessages!="")
    {
    $strErrorMessages = "Could not update the information. " . $strErrorMessages;
    }
    }

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so you are setting $strProdImg either from hidden_file or file
    what happens if neither variable is set?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2008
    Posts
    7
    it's possible to happen because either of those variable has their own value....

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what happens if neither variable is set?
    where do you get the image from if its not in file or strprodimg, afterall thats the symptom you are reporting..

    if you dont update the data you see no image
    i suspect that you need to set a value from your db

    also im not a fan of your code
    there could be a value in both strprodimg AND 'file', your code would overwrite the strprodimg with the value in 'file'.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •