psychowolvesbane Posted February 3, 2008 Share Posted February 3, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/89116-solved-please-can-anyone-help-me/ Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Numbers should not be surrounded by quotes. This.... if(mysql_affected_rows($conn) == "1") should be.... if(mysql_affected_rows($conn) == 1) etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/89116-solved-please-can-anyone-help-me/#findComment-456428 Share on other sites More sharing options...
psychowolvesbane Posted February 3, 2008 Author Share Posted February 3, 2008 Thanks Thorpe, I knew it had to be something obvious but it seems to have worked before even with the quotes because the $Added=true and $NotExec= false were activated as usual when the sql ran perfectly, strange. Quote Link to comment https://forums.phpfreaks.com/topic/89116-solved-please-can-anyone-help-me/#findComment-456437 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.