Fix for deprecated mysql_real_escape_string()
-
This plugin is great, but after changing hosts (PHP 5.5) it stopped working for me. The warning “PHP Warning: mysql_real_escape_string(): A link to the server could not be established in ../advanced-custom-sort/acs.php on line 225” ultimately resulted in a SQL syntax error.
Here’s is a fix, which I think would be backwards-compatible:
- $group_name = mysql_real_escape_string($group_name); - $group_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$group_name' AND post_type = 'acs' LIMIT 1"); + $group_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = '%s' AND post_type = 'acs' LIMIT 1", $group_name));
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Fix for deprecated mysql_real_escape_string()’ is closed to new replies.