Jump to content

[SOLVED] Please can anyone help me?


psychowolvesbane

Recommended Posts

I have a form with an image upload feature, I want it so the move_uploaded_files() script occurs after the INSERT SQL query has successfully been completed, however whenever I try moving the line $move_image into an if statement to try and catch it out it doesn't seem to operate yet works perfectly outside of them unrestricted.

 

Here's my code for that part of the form. Also, take it that the variables and their contents are correct upon entry.

 

...
      $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());
      $db = mysql_select_db($Dbname, $conn);

      $sqlNew = "INSERT INTO Clothing (ClothingCode,Description,ItemType,Price,NUSPrice,AvailableSizes,AvailableColours) VALUES('$ClothingCode','$Description','$ItemType','$Price','$NUSPrice','$AvailableSizes','$AvailableColours')";

      $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error());      		

      if(mysql_affected_rows($conn) == "1")
      {
         $move_image = move_uploaded_file($image_temp, $dirupload.$ClothingCode.".jpg"); // <--- This is the culprit
         $Added = true;
         $NotExec = false;
      }
        elseif(mysql_affected_rows($conn) =="0")
        {
           $Added = false;
           $NotExec = true;
        ?>
           <div style="position:Relative; top:250px; left:200px; width:550px">   
           <span class="errmsg">Could not be added, <?php echo "$ClothingCode";?> may already exist!</span>
           </div>
        <?php
        
        }
        mysql_close($conn);
...

 

Can anyone see what I'm doing wrong?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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