Questions tagged [mysql]

MySQL is an open-source, relational database management system.

Filter by
Sorted by
Tagged with
0
votes
1answer
2k views

How to add a custom field and incrementing value for all the published posts

I'm trying to add a custom field value "article" and auto - increment value starting from 1 for all the published and new post starting from the first post. I'm trying with the below code in Mysql. ...
0
votes
1answer
21 views

How to improve my non-unique metadata MySQL entries?

I'm working on a plugin for WooCommerce which uses a cpt called Restock. In a Restock post you can enter products ( id ) plus restock. The user can add as many product restock pairs as they want per ...
0
votes
0answers
10 views

How to alter default post gallery settings from SQL?

I want to change my default posts gallery settings value. for example, Size= Full Size, Link to = none, Column = 5 for my all old published gallery. I found some PHP hard code functions for doing this ...
0
votes
1answer
565 views

Comment Approve - Add custom function when comment is approved

I would like to save some PHP memory when quering category page (like 5000 products at once) with average review rating, so I would like to save average rating of reviews every time I will manually ...
0
votes
0answers
17 views

Dynamic dropdown from database table

I need a little help: I want to create a drop-down populated by mysql database table with two options: Select option 1 (regions) Select option 2 (schools) Where in option 2 appears populated according ...
1
vote
1answer
803 views

Uncaught Error: Call to undefined function mysql_connect() - Wordpress installation

Trying to install wordpress without xamp on my local machine. Version info: Wordpress: 5.2.3 PHP: 7.3.9 Apache: 2.4.41 When accessing this url -http://localhost:8080/wordpress/wp-admin/install.php, ...
0
votes
0answers
18 views

Wordpress - Dynamic dropdown from database table [closed]

I'm looking for a solution to get a dynamically populated dropdown from a database table. Any suggestion? I was checking dynamic_dropdown cf7sg, but I don't know how to link database to this function: ...
0
votes
1answer
1k views

wp_insert_user is not working for me?

I have written a code for inserting wordpress user if I try to add new user I am getting an error for wp_insert_user like below : "Catchable fatal error: Object of class WP_Error could not be ...
0
votes
0answers
18 views

How to Capture Gravity Form Entries to PHPMYADMIN [closed]

I created Gravity Form & Create the Database Table at PHPMYADMIN, in which defined field Firstname, Lastname, and Email. For Gravity Form, the code added in function.php as follows: add_action('...
1
vote
1answer
551 views

Create table from array with prepare

Is it possible to create a table with the wpdb::prepare function? I read the documentation and tried to find examples but there where none that helped me. Even creating a table with prepare doesn't ...
0
votes
0answers
17 views

Getting wp_post objects from a single custom INNER JOIN SQL request

I have a custom plugin (written by me) that has, for reasons, got a custom table which contains a post_id field. It makes sense in context. What I currently do is SELECT post_id FROM table_name WHERE ...
0
votes
1answer
44 views

Using AND and bracket grouping in SQL not working

I am trying to combine two conditions in a query but it isn't working. but running the conditions independently works. LEt me explain. When I run this query: SELECT DISTINCT SQL_CALC_FOUND_ROWS ...
0
votes
1answer
742 views

Fix wp_term_relationships slow query in get_posts

I used the Query Monitor plugin to find slow query on my WordPress site. The below-mentioned WP_Query->get_posts() takes about 0.3446 query time out of the total Database Query time of 0.3976. ...
0
votes
1answer
1k views

Update post meta data (custom field) by post link

I have a post in my WordPress website, which has lot of custom fields. I have an Excel sheet with "post link" - "custom field data" combination. That custom field (video URL) is already set for each ...
1
vote
1answer
864 views

MySQL variable in query

I've got tenant portal when I need to show running balance for each transaction. Here's query I've written which does what I need it to do. Problem I've got is that it doesn't work in Wordpress. Here'...
0
votes
1answer
17 views

How to search usermeta table

What is the best way to search usermeta to find a user_id based on a meta_value? For example in usermeta table there is a row with user_id = 123 , meta_key = deviceid and meta_value = 45545. I know ...
3
votes
3answers
48k views

How to use update and delete query in wordpress

First i write manually update, delete, insert and select query and execute data with mysql_query function Like this: Select query $prefix = $wpdb->prefix; $postSql = "SELECT DISTINCT post_id ...
0
votes
2answers
79 views

What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?

I have the following doubt related to the posts table of the WordPress database. I see that when I create a new post in this table are automatically created 2 new rows. 32 1 2014-08-16 15:07:22 ...
3
votes
2answers
2k views

Gaining Login Access via the Database

I have been given a job to amend a Wordpress site. I have only been given access to Cpanel. My questions are can i log in to the back end of Wordpress via Cpanel? If you can't login via Cpanel can i ...
0
votes
1answer
17 views

im using wp-bakery page builder …copy all cone one to anoher page than not display all contant

Warning: mysqli_query(): (HY000/1036): Table 'C:\xampp\tmp#sql328c_1fb_5.MAI' is read only in C:\xampp\htdocs\transportation\wp-includes\wp-db.php on line 2056 some error occures in front end and ...
1
vote
1answer
936 views

Term and sub term from custom post type query

I have created a custom post type and taxonomy for a goods catalogue for a hire website. This works fine. I am trying to generate a report that lists all items and their category and sub category. I ...
0
votes
0answers
17 views

Database error: You have an error in your SQL syntax term_taxonomy

It's been a while since this syntax error has been happening, I tried to look it up, have read articles and forum's posts on this issue, but I still couldn't fix it. It says I have an error on my ...
1
vote
1answer
33 views

Why last row deleted when refresh page

when I refresh page table row deleted and last query deleted when I click on any delete button of other row. Why is this happened? this is table which I displayed <?php ...
1
vote
2answers
31 views

how update data through ajax and jquery

I try to update data through ajax, but it not worked. What I did wrong? Here is jquery ajax code php code in functions.php function update_records(){ global $wpdb; echo $id = $_POST['update_record'...
0
votes
1answer
17 views

Upload media only to DB

I'm using the latest WordPress (5.6) and from what I've found out there's no visible setting for uploading media directly to a DB. Is there such an option somewhere hidden or does WordPress not ...
0
votes
0answers
13 views

WordPress MySQL update DB multiple columns by relationship key

Hello guys. I am trying to figure out how can I update the values of a database's columns with a relational key by passing an array of IDs (relational key), here is my code so far protected function ...
0
votes
0answers
13 views

MYSQL: Create SQL query to search for string and replace

I need to delete a malicious string from 2176 fields following a url redirect hack. I'm pretty vanilla at SQL so some help is much appreciated. I have MYSQL ClI or PHPmyAdmin available to me. The ...
0
votes
2answers
127 views

Replacing javascript link in Wordpress database without getting mysql syntax errors

After a malware attack I am trying to replace a malicious call entries. I keep getting syntax errors due to the configuration of the link. Tried all of the various escape characters to now avail. ...
1
vote
1answer
60 views

why update and delete query not worked in custom table?

this is custom template. I wrote crud by using wordpress query to sent data in custom table of database and get from database, insert query worked, but update and delete query not working. Below I ...
0
votes
2answers
1k views

How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies ...
0
votes
1answer
25 views

Use $wpdb or other PHP script method to find/replace in WP database

I'm hoping to push a bug fix for a custom WordPress plugin my sites use. The plugin registers a shortcode with various attributes. However, there's a bug where one of the attributes is incorrectly ...
7
votes
2answers
178k views

Order by DESC, ASC in custom WP_Query

I need to do multi-level ordering in a query. The issue is with ordering one value DESC and the other ASC as in SQL. The following SQL seems to give me what I want when I run it in terminal: SELECT ...
7
votes
3answers
61k views

How to fetch Data in WordPress using MySQLi or $wpdb

I have custom table like this: useraw 1. id (Primary*) 2. user_ip 3. post_id 4. time I am inserting data in the table using $wpdb->insert($table_name , array('user_ip' => $user_ip, 'post_id'...
0
votes
2answers
662 views

mysql query - how to escape apostrophe?

I've got this query: $tenantsInfo = $wpdb->get_results("SELECT * FROM exp_ten WHERE tenant_number = " . (int) $user->ID); I use some echo to show data on frontend: if ($tenantsInfo) { ...
0
votes
0answers
16 views

select product id & product quantity from orders

I necessary get all products with order_id, order_date, product_id, product_quantity . But with query below i get two rows for 1 product: for _qty and _product_id . I need one row. $posts_table = $...
0
votes
0answers
14 views

Changing the defaults for the _posts table, risky?

I am trying to convert my table type from MyISAM to InnoDb. the _posts table uses zero in date defaults in columns such as post modification date etc instead of NULL. This is an issue in MYSQL 8. Has ...
15
votes
6answers
21k views

Checking if Database Table exists

I read the wordpress codex and professional wordpress. It seems both use something like if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { to determine if the table exists. Is ...
0
votes
1answer
17 views

Query to fetch custom taxonomy along with post title

I have more than 20000 posts and want to filter post based on taxonomy and name which should display the post title ,taxonomy, name,id using MYSQL query.
0
votes
0answers
16 views

Ensure SQL changes carry over

I was working on some site that has the excerpt on a serialized meta field. Since we're not supporting that plugin anymore I just migrated it with SQL. Encoding seems fine here: However on wp-admin: ...
0
votes
1answer
783 views

Pull MySQL data from multiple tables and merge into 1 PHP array

Appreciate help in advance. I am dealing with a bit of a pickle with a formula. I am trying to create a page template that will display a list of users, specific metadata from usermeta table + ...
0
votes
1answer
781 views

The function is deprecated; use mysql_real_escape_string() instead

I don`t know coding. I recently my website stop to work properly. I get this error on the top of on every page loaded. Deprecated: mysql_escape_string(): This function is deprecated; use ...
0
votes
2answers
56 views

Is it good practice to use wpdb->query() function?

I am using custom php code to perform data insertion, deletion, updating and other tasks. I am able to insert data into a table in two different ways, $wpdb->insert($table_name, array('id' => ...
0
votes
0answers
9 views

Error reconnecting to the database while updating/publishing more that 10 posts for a custom post type

I'm using directories pro plugin for one of my client's site and it created a custom post type for listings. The problem that I'm facing is when I'm trying to update/publish more than 10 businesses ...
5
votes
3answers
10k views

Query both first_name and last_name from wp_usermeta at the same time

I'm trying to fetch both the first_name and last_name of all users at the same time, using the wpdb-object and the wp_usermeta table. I can't seem to figure out how to get both in the same query. ...
0
votes
1answer
637 views

Merging development site with live site

Earlier this year I built a client a large website for their organization. After that site was finished and live on the web (not on our development server anymore) they wanted the company I work for ...
5
votes
2answers
32k views

Scanning Database for malicious Data

After a site of a friend has been hacked I told him he should just clean up the mess and restart from scratch so he know that no file has been altered. I could scan the site for him with tools like ...
0
votes
1answer
543 views

Create a new table on the database and save parameters from a contact form

I have a wordpress function in functions.php which gets parameters from a form I made and gets parameters like IP addresses and UTM tags (from the URL) and sends them to me by email. I want to get ...
0
votes
0answers
17 views

WordPress homepage not working

My WordPress site's homepage is not working. All the other pages are working. When I change the home page to another page, that page is then also not working. The problem is whatever page I make as a ...
0
votes
1answer
652 views

WordPress database error Duplicate entry for key 'slug'

I have just migrated to a new host and upgraded my Wordpress to 4.9.8 (from 3.9.x, embarrassing I know, plan to keep it up to date from now on). I also went through the process of replacing plugins ...
0
votes
1answer
1k views

why is my postmeta table is so heavy

One of my database is realy heavy (+100Mo) for a site with not so many content (like 40 pages & 10 posts)). I found in phpmyadmin that my table "postmeta" is 95Mo. So i wonder to know what are the ...

1
2 3 4 5
30