How to make MySQL search queries with quotes

Woah there. You’ve just opened up a can of SQL injection. I use the default get_query_var(‘s’) that I believe is automatically escaped by wordpress. Not quite – get_search_query() will do that, but get_query_var( ‘s’ ) gets the “raw” value. Regardless, always use wpdb::prepare or similar escaping before executing SQL: $query = $wpdb->prepare( “SELECT * FROM … Read more

Creating an Angular factory from custom database table

Guess I should have read the error page more carefully, because it contained the answer in plain English. In the factory request is should simply match the request to the response signature (an array in my case), thus becoming: angular.module(“app”).controller(“MainController”, [“$scope”, “commentRepository”, function ($scope, commentRepository) { commentRepository.query(function(data) { $scope.comments = data; }); }]); Instead of … Read more

direct query to post_meta table

If I understand correctly you wish to retrieve your meta data from the database? Try looking at this WP function: https://developer.wordpress.org/reference/functions/get_metadata/ This will allow you to get the meta data you require dependent on the type of data you want to get, such as post meta data or page meta data etc. An additional read … Read more

What argument does my function need to echo get_results() query results

Why don’t you just do.. add_action( ‘wp_head’, ‘quick_qs_db_css’, 100 ); function quick_qs_db_css() { ?> global $wpdb; $table_name = $wpdb->prefix . ‘qs_css’; $db_css = $wpdb->get_results( ” SELECT qs_the_css FROM $table_name WHERE qs_css_id = 1 ” ); <style type=”text/css” id=”db-css”> <?php echo $db_css[0]->qs_the_css; //outputs null ?> </style> <?php } Seeing as you are using it everytime head … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)