jonw118 Posted January 6, 2009 Share Posted January 6, 2009 I'd appreciate any help someone could lend! Basically I have a script that shows 1 image. Under it is a remove button. Here is the remove code for it on the page: <? if(!empty($row2['image'])) { ?> <img src="<? echo $row2['thumb'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo1"> <? }?> So, when you remove an image it calls remove_image.php: <? include ("define.php"); $sql="update inputinfo set image='',thumb='' where id='$id'"; $rez=mysql_query($sql,$dblnk); header('location: edit.php?id='.$id); ?> Simple enough. But, here's my problem. I added two more pics into the database. For the new images that are uploaded to the database I am using the following (which displays fine): <? if(!empty($row2['image2'])) { ?> <img src="<? echo $row2['thumb2'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo2"> <? }?> and <? if(!empty($row2['image3])) { ?> <img src="<? echo $row2['thumb3'];?>"> <a href="remove_image.php?id=<? echo $row2['id'];?>">Remove Image</a> <? } else { ?> <input type="file" name="photo3"> <? }?> But #2 & #3 will not delete correctly. Sometimes they do, sometimes they don't. Depends if previous images and such are deleted. That remove_image.php was updated to (and I know my problem is in here). Seems like it stalls out on this script for some reason: <? include ("define.php"); $sql="update inputinfo set image='',thumb='' where id='$id'"; $sql="update inputinfo set image2='',thumb2='' where id='$id'"; $sql="update inputinfo set image3='',thumb3='' where id='$id'"; $rez=mysql_query($sql,$dblnk); header('location: edit.php?id='.$id); ?> Is there something I am missing that should inserted in between each line of $sql? Again, I'd really appreciate some advise! Quote Link to comment Share on other sites More sharing options...
cytech Posted January 6, 2009 Share Posted January 6, 2009 Hey jonw118, It is becuase you are re-defining $sql each time. So if you wanted to do it the way you had setup you would need to run $rez=mysql_query($sql,$dblnk); after each $sql you have setup. I suggest combining the queries together, something like this: $sql="update inputinfo set image='',thumb='', image2='', thumb2='', image3='', thumb3='' where id='$id'"; Hope that helps! Quote Link to comment Share on other sites More sharing options...
jonw118 Posted January 7, 2009 Author Share Posted January 7, 2009 Awesome! Thank you so much, I really appreciate it... going to try that out in a second. Quote Link to comment 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.