[wp-hackers] Delete Row - Refreshes Page but not DB
Nikola Nikolov
nikolov.tmw at gmail.com
Sat Oct 19 17:35:46 UTC 2013
About the ajaxurl - yes that is correct. WordPress only defines the global
JS variable ajaxurl on the admin side - so you have to do it yourself in
order to access it on the front-end.
Why are you not using the $file variable in your other code?
// You are assigning $_POST['file'] to the $file variable and not to
$row['file']
$file = $_POST['file'];
$del_image = wp_delete_attachment( $file );
On Sat, Oct 19, 2013 at 8:25 PM, BenderisGreat <greglancaster71 at gmail.com>wrote:
> I thought it looked weird. I spent some time last night working out the
> correct code pasted here, and got it functioning. I dont think I can get
> my
> money back but I will try. I am so glad I have this resource to check with,
> or I would have never had JD showing me the proper way, and then never
> would
> have questioned his code.
>
> I finally got JDs code working but I have to place this in my functions for
> ajax to work:
>
> add_action('wp_head','custom_head');
>
> function custom_head()
> {
> echo '';
> }
>
>
> Is that alright? Otherwise I get ajaxurl undefined error.
>
> Additionally, the json response works too! However one query always fails.
>
> $file = $_POST['file'];
> $del_image = wp_delete_attachment( $row['file'] ); - fail
>
> I also tried this as an sql query:
>
> $file = $_POST['file'];
> $fileQry = $wpdb->prepare("DELETE FROM wp_posts WHERE id = %s", $file);
> $go_fileQry = $wpdb->query($fileQry);
>
> It still fails. It IS possible to run multiple queries this way right?
>
>
>
> --
> View this message in context:
> http://wordpress-hackers.1065353.n5.nabble.com/Delete-Row-Refreshes-Page-but-not-DB-tp42393p42566.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list