I have this code:
add_action( 'delete_post', 'my_delete_function' );
function my_delete_function($post_id) {
global $wpdb;
$achievement = get_the_category($post_id);
$h = $achievement[0]->cat_ID;
$s = ''.str_replace('"', '', $h);
$p = var_dump(htmlentities($s));
$wpdb->query("INSERT INTO ".$wpdb->prefix."votes (post, votes, guests, usersinks, guestsinks) VALUES('', ".$p.", '', '', '') ") or die(mysql_error());
}
mySQL keeps throwing this error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '', '', '')' at line 1
Ive ran the same query in phpMyAdmin, replacing the php vars with values and it works fine
Additionally, ive made sure the the value of $s is just a number by using the echo function on a blank page.
Any help is appreciated
var_dump($s);right before the last line to check what you're outputting. If it contains HTML, usevar_dump(htmlentities($s));