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
https://forums.phpfreaks.com/topic/89116-solved-please-can-anyone-help-me/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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