Questions tagged [mysql]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
602 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 ...
1
vote
1answer
2k views

How to insert data into MySQL database from the form created in WordPress site

How can I insert the data entered into the form in WordPress site to the MySQL database? I have created a form in the site. I am able to run PHP codes using snippets but I don't know how to update the ...
1
vote
1answer
622 views

How to securely provide a $_POST var in WP_Query with PHP 7?

In PHP 5.5 you had the function mysql_real_escape_string() and I always did htmlspecialchars(mysql_real_escape_string($_POST['...])); to secure against SQL-Injection. With PHP 7 ...
0
votes
1answer
521 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
1answer
527 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
vote
2answers
571 views

Mysql SELECT posts

how i can get posts via MYSQL from posts where language is 'en' and 'ru' I have this query $sql = "SELECT p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1 ON ( wm1.post_id = p1....
0
votes
1answer
20 views

How to do database for download stats?

So I have a existing wordpress site and we are building now download section for it. Downloads will be custom post type and files. Now we need to have some stats, like number of downloads per cpt (...
1
vote
1answer
566 views

PHP script can't connect to Database on port 3307

I can connect to mysql just fine with my port number through the command line like so: mysql -h ##.##.##.## -P 3307 -u wpuser -p I have a php file that tries to connect to the DB, <?php ...
0
votes
0answers
16 views

How to install Wordpress from hosting service with mysql database from Compute Engine GCP?

I own a wordpress website (website.com) that running well with hosting service (cpanel). So i want to create a new subdomain (new.website.com) and install wordpress in there but for the database i ...
0
votes
0answers
11 views

Unable to save or update posts with Emoji

I host my WordPress (v5.4.2) blog on 000webhost.com and I am unable to save any post with emoji characters. I get this error Updating failed. Could not update post in the database I have tried ...
-1
votes
0answers
20 views

How to make sure WordPress database doesn't have any problems?

I'm transferring a WordPress site to a new server. On the new server, getting things ready, I was using the "Optimize Database after Deleting Revisions" plugin to maintain the database ...
0
votes
1answer
27 views

Can I split a huge wp_postmeta table across different databases or servers?

This question doesn't have any codes, it's more of a theoretical question. I need guidance on what method to look for. I've searched on google before but found nothing on this specific case. I have 2 ...
1
vote
1answer
543 views

Hacked Wordpress website /Homepage redirect

I am very sorry about the length of the post, please bear with me as I am going to try and list everything I've done so far. I am dealing with a hacked WordPress site which had been left without ...
1
vote
1answer
11 views

Show MySQL errors that occur when I excute $wpdb->insert()

I have the same problem as Nathan ($wpdb->last_error doesn't show the query on error), obviously, the solution to the specific case was to change the type of data to the column that caused the ...
0
votes
1answer
15 views

Run Username SQL Query from WordPress Child Theme Functions File

Having an admin account, I can change everything except the username (which happens to be the login name). I am therefore wondering how to change the username using the functions file. Running the ...
1
vote
2answers
529 views

Wordpress Backend HA (Automatic failover)

Out setup is multiple Front Ends (replicated) and 2 Backend MYSQL servers (Master-Master replication). We're looking to achieve HA automatic failover for wordpress. We've got the front ends covered ...
0
votes
1answer
535 views

Insert double entry in DB

I created plugin and my plugin create new Table in DB. My problem is when user type something in field firstname, lastname... and click on button Submit, that go to my table and that is ok.. but then ...
0
votes
1answer
2k views

How do I merge WooCommerce categories with the same name?

I have duplicate product categories - they share the same name but different slugs eg., The category 'Adhesives' has a slug of "adhesives" but since updating my products via CSV import, there is now ...
1
vote
1answer
639 views

UPDATE on SELECT results. A SQL query to swap Author with Meta Box value

I inherited a project where, for some reason, the previous developer make a custom post type for authors and a custom select listing all those authors cpt titles in the post edit screen. This led to a ...
1
vote
2answers
877 views

$wpdb select all meta for each post

I'm running the following query trying to get the data and associated meta data of a huge number of posts: SELECT wp_posts.post_title, wp_posts.post_date, wp_posts.ID, wp_postmeta.post_id, ...
0
votes
1answer
16 views

How can I add a new row in a separate database when someone registers via Wordpress?

Apologies if this is question is too general or in the wrong location but I am new to SQL, Wordpress and web hosting. So I am a game developer using Unity C# to create a multiplayer game. I am using ...
0
votes
1answer
579 views

Plugin MySQL SELECT custom data and filter on user meta

I'm porting a custom PHP feature to be part of a Wordpress plugin. At present, my USERS table has a field (let's call it FLAG) which my MySQL query needs to filter on, eg: SELECT custom-data FROM ...
1
vote
1answer
528 views

MySql Query very slow

I have a problem with a query on my website. When I load the page it is incredibly slow and only after over 12 seconds the content starts showing. I have installed a debug plugin and found the query ...
0
votes
2answers
735 views

How can I export posts with featured images, without download them

Exporting posts with featured images without downloading them. I work with a site that has 10000 media in a blob and nothing is allocated in the uploads folder. How do I export the posts without ...
0
votes
1answer
30 views

I can't separate the array by commas

I have a problem I cannot separate the array by commas if I put the implode it only shows the first number and not the second in database i need insert in database 500,756 global $wpdb; $arg=array(...
0
votes
0answers
15 views

how to get data from two different table from wordpress database

I have two different table in wordpress one is custom table and another is wp_usermeta table. one email is matched from both table so i want to get data from both table using email address is matched. ...
0
votes
1answer
40 views

WordPress fails to install with “Can't Select Database” Error (WAMPServer)

UPDATE: 2020-07-12 I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that either there is a bug in WAMPServer 3.2.0 ...
0
votes
2answers
1k views

$wpdb->get_var not returning count

I'm trying to do a count for pagination and its returning NULL why the query returns results correctly. In this case $total returns NULL which is not correct why? (I didn't include the $args as they ...
0
votes
0answers
21 views

When I add metadata, metavalue length is added in to the value in some cases

When I use the following code: update_post_meta($new_post_id, '_test_metakey1', 'a:1:1;'); update_post_meta($new_post_id, '_test_metakey2', 'a:1;'); The database adds the keys as follows: Why does ...
2
votes
3answers
9k views

“#1067 - Invalid default value for 'post_date'” when trying to reset AI after backup

I've restored my Wordpress database from an sql backup. However, in doing so, all of the tables have lost auto increment. When I try to add it back in with this sql ALTER TABLE `mercury_posts` ...
0
votes
0answers
12 views

Changing stock value from txt file using PHP

I have a txt file that stores info (sku, name, stock) from products. Is it possible to read from this file and insert only the stock value to wp database using php? Thanks
0
votes
0answers
23 views

MySQL query to select Advanced custom fields (ACF) in WordPress from the database

MySQL query to select Advanced custom fields (ACF) in WordPress from the database. I have a simple WordPress website with custom fields i want to select(query) all the custom fields data from ...
1
vote
1answer
884 views

mySQL statment count of post in each category and sub category

im trying to get a count of all post for each Categorty and sub category it should show main_cat 10 -a1 5 -a2 5 i have tried this but my counts are all of and im getting ...
0
votes
2answers
5k views

Replace existing pages with new pages, keep menu links

I basically want a plugin or method that would give the same functionality as 'Enable Media Replace' but for replacing pages and posts, instead of redirecting, or manually editing. I've searched high ...
0
votes
2answers
51 views

Huge wp_options table

I have a problem on a WP site. Website crashes because there is no more available disk space. Searching, i detect that wp_options table size is 12GB, but only have 1100 rows aprox: Any ideas? Thanks ...
1
vote
1answer
12 views

When Wordpress Default table, Echo Success. When Plugin Table, Echo Blank

When I used this code, the result/echo display as I wanted. <?php $user_checks = $wpdb->get_results( " SELECT ID, user_nicename FROM $wpdb->users " ); foreach ( $...
1
vote
0answers
559 views

Is it safe to convert tables from MyISAM to InnoDB?

I have inherited a WP site (with WP5.1 and WooCommerce 2.6.14, LearnDash 2.5.4 and few other smaller plugins). From screenshot you can see that it is a mix and match of MyISAM and InnoDB tables. ...
0
votes
0answers
15 views

504 Gateway Time-out after custom plugin inserts data into mysql database

I have a custom plugin that inserts multiple rows into a custom table in the wordpress database. After about 50 seconds I get a 504 Gateway Time-out error. The 50 seconds is around about the time it ...
1
vote
2answers
762 views

Get user categories with most posts in it

I am trying to make a query to take first 3 categories with most posts per user, but no luck so far. This is where I am now: SELECT DISTINCT(terms.term_id) as term_ID, terms.name, terms.slug, posts....
1
vote
1answer
249 views

How to solve slow WordPress site caused by attachment_metadata

My WordPress sites starting to become slower by time, after two years they become very slow. I tried many things, such as: improved my DB, used cache plugins (WP Rocket and W3 Total Cache) which both ...
0
votes
1answer
671 views

WP Database generate content for post_name column

I ran a query that deleted all content in post_name (used for SEO-friendly URLs) column. UPDATE wp_posts SET post_name = '' I thought that WordPress would automatically populate new ones if I update ...
0
votes
0answers
37 views

Custom Options - Cant save more than 167 items

In a custom options page I've repeatable fields that I want to save their data. For some reason it can only save 167 items inside the serialized array. Is there a limitation? Note When I run my site ...
0
votes
1answer
810 views

Add value to array in database

I have a custom database in my WordPress site where I want to save multiple values to one row. Let's say I have an entry: id: auto increment pageid: id of current page time: text (is an array ...
3
votes
5answers
20k views

Convert WordPress posts to products in WooCommerce

Is there anyway I could convert all the posts e have right now on our WordPress install into products using some MySQL query or something like that?
0
votes
0answers
12 views

Can I use the main Multisite as a backend only?

I need to implement an admin solution to manage a multitude of existing sites that each lives on an individual subdirectory on the same domain, with their own respective databases, users, themes, etc. ...
0
votes
1answer
590 views

SQL Query Search page

I am trying to create a Wordpress webpage that has an input text box and a button. what I want to do is take the input text from the text box and use it as a parameter to search a table I put into the ...
0
votes
1answer
47 views

Insert, update or remove data from database (usermeta)

I have a situation here. I'm writing a custom plugin for WordPress. I'm dealing with an issue: I'v created a metabox for Custom Post Type with add_meta_box and with a callback function where I ...
0
votes
1answer
554 views

Migration of wordpress database from mariadb 10.0.20 to 5.5.50

I have been struggling with this one and cannot find an answer. I am not an expert with databases and had an issue that is a pain. I am attempting to migrate a wordpress database to a different ...
0
votes
1answer
602 views

how to insert missing tags into the posts through mySQL?

I am looking for a SQL query to insert a tag to multiple posts from a specific category. A pseudo query looks something like this: INSERT INTO POSTS VALUES TAG = "tagName" where Posts in_category("...
1
vote
2answers
3k views

How to get last updated row or ID in wordpress

How to get last updated row or ID in wordpress. Like : $wpdb->insert_id;

1
2 3 4 5
29