angelsRock Posted October 14, 2007 Share Posted October 14, 2007 i got error on the if part in mysql query..!! :'( <?php if(is_uploaded_file($_FILES[image1][tmp_name])) { $imagename1 = basename($_FILES['image1']['name']); $newimage1 = "art/" . $imagename1; $thumbimage="thumbs/" . $imagename; echo $_FILES['image1']['type']; if(move_uploaded_file($_FILES[image1][tmp_name],$newimage1)) { echo"<p class=good>FIRST PICTURE UPLOADED OK</p>"; } else { echo"<p class=error>PICTURE ERROR</p>"; } } mysql_select_db($db); $query = "update premium_propertyad set address='".$_POST[address]."', area='".$_POST[area]."', state='".$_POST[state]."', type1='".$_POST[type1]."', type2='".$_POST[type2]."', type3='".$_POST[type3]."', selling_price='".$_POST[selling_price]."', rental_price='".$_POST[rental_price]."', land_area='".$_POST[land_area]."', buildup_area='".$_POST[buildup_area]."', tenure='".$_POST[tenure]."', bedroom_num='".$_POST[bedroom_num]."', bathroom_num='".$_POST[bathroom_num]."', remarks='".$_POST[remarks]."'," if($_FILES['image1']['name']>0 || $_FILES['image2']['name']>0|| $_FILES['image3']['name']>0) { $query = $query & "photo1='$imagename1',photo1='$imagename1',photo1='$imagename1'," } $query= $query& " facilities='$facilities' where username='".$_SESSION[username]."' and premPropertyID='".$_POST[basic_id]."' "; echo $query; echo mysql_error(); $result=mysql_query($query);?> i want to update the page.. if the picture are not change.. so it will just update the record .. where the previous picture willl be remained... Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/ Share on other sites More sharing options...
trq Posted October 14, 2007 Share Posted October 14, 2007 Pardon? Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369177 Share on other sites More sharing options...
angelsRock Posted October 14, 2007 Author Share Posted October 14, 2007 ohh.. the above page is the edit page.. the user descriptions and pictures will be shown.. if user want to update the data but not the picture .. mean the <input type="file" size=50 name="image1"> will be left blank.. if i update the blank value.. it will overwrite the previous picture.. so i put the above code like that .. but it prompt me error on the <?php if($_FILES['image1']['name']>0 || $_FILES['image2']['name']>0|| $_FILES['image3']['name']>0) { $query = $query & "photo1='$imagename1',photo1='$imagename1',photo1='$imagename1'," }?> Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369199 Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 if your not passing a file then why check for the file ? just move the code that updates the mysql out of the routine that check for the files and, add a new checking routine to check if the entries are blank.. Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369204 Share on other sites More sharing options...
angelsRock Posted October 14, 2007 Author Share Posted October 14, 2007 <?php if(is_uploaded_file($_FILES[image1][tmp_name])) { $imagename1 = basename($_FILES['image1']['name']); $newimage1 = "art/" . $imagename1; $thumbimage="thumbs/" . $imagename; echo $_FILES['image1']['type']; if(move_uploaded_file($_FILES[image1][tmp_name],$newimage1)) { echo"<p class=good>FIRST PICTURE UPLOADED OK</p>"; } else { echo"<p class=error>PICTURE ERROR</p>"; } } mysql_select_db($db); $query = "update premium_propertyad set address='".$_POST[address]."', area='".$_POST[area]."', state='".$_POST[state]."', type1='".$_POST[type1]."', type2='".$_POST[type2]."', type3='".$_POST[type3]."', selling_price='".$_POST[selling_price]."', rental_price='".$_POST[rental_price]."', land_area='".$_POST[land_area]."', buildup_area='".$_POST[buildup_area]."', tenure='".$_POST[tenure]."', bedroom_num='".$_POST[bedroom_num]."', bathroom_num='".$_POST[bathroom_num]."', remarks='".$_POST[remarks]."'," if($_FILES['image1']['name']>0 || $_FILES['image2']['name']>0|| $_FILES['image3']['name']>0) { $query = $query & "photo1='$imagename1',photo1='$imagename1',photo1='$imagename1'," } $query= $query& " facilities='$facilities' where username='".$_SESSION[username]."' and premPropertyID='".$_POST[basic_id]."' "; echo $query; echo mysql_error(); $result=mysql_query($query);?> if your not passing a file then why check for the file ? sorry... i don get what u meant.. i do everything in a page.. if($_FILES['image1']['name']>0 || $_FILES['image2']['name']>0|| $_FILES['image3']['name']>0) the above is to check whether any picture exist in the <input type=file> my idea is to check out of that 3 <input type=file> , if one got value.. then it will update the $query = $query & "photo1='$imagename1',photo1='$imagename1',photo1='$imagename1'," thanks for hlep Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369212 Share on other sites More sharing options...
angelsRock Posted October 14, 2007 Author Share Posted October 14, 2007 anyone can help??? :'( Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369239 Share on other sites More sharing options...
darkfreaks Posted October 14, 2007 Share Posted October 14, 2007 u need to check whether the input is empty <?php if (empty($_FILES['image1']['name'] || $_FILES['image2']['name']|| $_FILES['image3']['name'])) { echo "You Cant Upload Without a Picture";}?> Quote Link to comment https://forums.phpfreaks.com/topic/73188-multiple-pictures/#findComment-369336 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.