close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Delete file not working

Thread began 5/30/2019 6:32 am by Justin@AdventDesign | Last modified 5/30/2019 2:34 pm by Ray Borduin | 632 views | 9 replies |

Justin@AdventDesign

Delete file not working

For some reason, I can't get the delete file function to work. It was originally a part of the wizard. It wasn't working so I tried reinstalling it. I have multiple deletes. But it doesn't work with just one either. Do you see anything obvious in the file I'm missing?

Attached Files
tbl_images_results.php
Sign in to reply to this post

Ray BorduinWebAssist

You have a delete redirect after you delete the row in the database and the delete file code is below that. Just move the delete row from table code (lines 11-22) below the delete files code (ending at line 61), and I think that will fix it.

Sign in to reply to this post
Did this help? Tips are appreciated...

Justin@AdventDesign

Man I thought we had it. I had tried reordering before and kept running into errors, but i think it was because i moved the delete function before the query. I ordered just as you suggested. No errors, but it still doesn't want to delete the files.

Updated file attached.

Attached Files
tbl_images_results.php
Sign in to reply to this post

Ray BorduinWebAssist

I see now that you are deleting images using a row from the main recordset, but that recordset isn't filtered based on the record being deleted. That means the images from the first row are being deleted, not necessarily the images from the row you are deleting.

Maybe add a second recordset to the page specifically to get the row being deleted. Filter it with the value: <?php echo($_POST["WADADeleteRecordID"]); ?>

Then use that recordset to reference the images that need to be deleted. (and sorry this means the first row of your recordset had the images from it deleted already in your testing most likely)

Sign in to reply to this post
Did this help? Tips are appreciated...

Justin@AdventDesign

Forgive my ignorance but I can't quite figure out how to code that query:


<?php
$rsDeleteFile = new WA_MySQLi_RS("rsDeleteFile",$framework_connect,1);
$rsDeleteFile->setQuery("SELECT id, `file` FROM tbl_images WHERE id = ?");
$rsDeleteFile->bindParam("i", "".($_POST["WADADeleteRecordID"]) ."", "-1"); //colname
$rsDeleteFile->execute();
?>

Also, wouldn't this have to come after the delete function so the WADADeleteRecordID would be defined, but then that would be after the redirect.

Sign in to reply to this post

Justin@AdventDesign

I went back and looked at one of my previous projects that was done under the old mySQL function rather than mySQLi, and in the past we didn't have to do a separate query. Is it mySQLi that causes us to have to do it differently?

Sign in to reply to this post

Ray BorduinWebAssist

The WADADeleteRecordID is from the POST (a hidden form element), so no it doesn't have to be after the delete function.

The query you have appears to be correct to me.

Sign in to reply to this post
Did this help? Tips are appreciated...

Ray BorduinWebAssist

The WADADeleteRecordID is from the POST (a hidden form element), so no it doesn't have to be after the delete function.

The query you have appears to be correct to me.

Sign in to reply to this post
Did this help? Tips are appreciated...

Justin@AdventDesign

I thought so too but it throws this error when I load the page:

Undefined index: WADADeleteRecordID in /Applications/XAMPP/xamppfiles/htdocs/sites/abm-sites/team-construction/sitecontrol/tbl_images_results.php on line 42
SiteControl by Advent Design

Sign in to reply to this post

Ray BorduinWebAssist

This line:

$rsDeleteFile->bindParam("i", "".($_POST["WADADeleteRecordID"]) ."", "-1"); //colname

should be:

$rsDeleteFile->bindParam("i", "".(isset($_POST["WADADeleteRecordID"])?$_POST["WADADeleteRecordID"]:"") ."", "-1"); //colname

since the form post value won't exist until after the form has posted.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...