Wordpress not reflecting changed of the database - php

my problems started when I moved my website to another folder (from /dev/ to /).
I have gone through the whole database in order to change all the hardcoded /dev/ into / but I still notice that wordpress, somehow, still uses the old values.
Basically the website uses information that are not there anymore.
I checked my own and the server cache and they all seem to be clean (the server doesn't even seem to have that feature on).
So, I am pretty much lost...

When you move a wordpress install, you need to change the site URL throughout your database. To do this you'll need to export your current database via PHP MyAdmin, and then use a tool like:
http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
...to do a search and replace on the entire database.
Search for:
www.yourwebsite.com/dev
replace with:
www.yourwebsite.com
Then import the new database, open your Wordpress site via wp-admin and re-save permalinks.

Run this query in your database
set #oldurl = 'http://oldwp-url.com', #newurl = 'http://newwp-url.com';
UPDATE wp_options SET option_value = replace(option_value, #oldurl, #newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, CONCAT('src="', #oldurl), CONCAT('src="', #newurl));
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl) WHERE post_type = 'attachment';
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, #oldurl, #newurl);

Related

Permalink issue after adding wordpress website live

We got an permalink issue after adding a wordpress website live (from dev to live website I mean)
I got this error line on all pages except the welcome page :
Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /var/www/vhosts/xxxxxxxx.com/httpdocs/wp-includes/class-wp.php on line 223
Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /var/www/vhosts/xxxxxxxx.com/httpdocs/wp-includes/class-wp.php on line 224
I f I go to setting/permalinks and I change for plain, error lines are not showing anymore. But if I go back to post name or custom structure and save these options, problem come back...
Could you help me with this issue? Everything was working good on dev...I don t understand what happened after the live migration...
Thx for your help.
Try to change url in .htaccess file, check if there is folder written.
Change old url to new url in database, here is the way you can do with query:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

How to fix wp-config.php to upload pictures in WordPress?

I have the following site http://imosigbroker.ro/. Logo and some pictures have been broken after I migrated the localhost site on the host. I tried to add these photos manually in WP via Media > Select Files and I got the following message error: "Missing a temporary file."
I set all DB files from localhost to my site with a plugin. This is not the issue of the website right now.
The debug shown the following:
Notice: Constant WP_DEBUG already defined in /home/imosigbr/public_html/wp-config.php on line 96
Notice: Constant SCRIPT_DEBUG already defined in /home/imosigbr/public_html/wp-config.php on line 97
Warning: Cannot modify header information - headers already sent by (output started at /home/imosigbr/public_html/wp-config.php:96) in /home/imosigbr/public_html/wp-admin/includes/misc.php on line 1196
I followed these tutorials [1]: https://www.wpbeginner.com/wp-tutorials/how-to-fix-missing-a-temporary-folder-error-in-wordpress/ [2]:https://www.wpbeginner.com/beginners-guide/how-to-fix-file-and-folder-permissions-error-in-wordpress/ and although the pictures were not fixed.
Hi the other commenters are right. Go to PHPMyadmin on your control panel and select your database then in the SQL box at the top paste :
UPDATE wp_options SET option_value = replace(option_value, 'http://localhost', 'http://imosigbroker.ro/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.localhost','http://imosigbroker.ro/');
UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost', 'http://imosigbroker.ro/');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost','http://imosigbroker.ro/');
then click run. It will do a proper job of updating your URLS throughout the site.

Changing the wordpress uploads default directory structure

My wordpress uploads folder is structured in the default way (year/month)
I have successfully changed the uploads directory location.
But the problem is that I have 10000+ posts and I am looking for a solution so that I can also move the existing medias to the the new location.
I know doing this will also require me to change the path of the medias at the database level.
Does any one know any plugin or script for doing so.
Thanks.
There are a couple of different options mentioned here, most of them are either using an already configured plugin, or running SQL scripts.
Most useful answer that was on that link that I found involved changing the old URLs found on each wp table in your MySQL database
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL')
WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');
UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing
URL','New URL');
And keep in mind the MySQL replace command can replace part of the URL string, it doesn't have to replace the entire URL string. So in your case, if the original url was
'http://yourdomain.com/wp-content/uploads/2010/10/img.jpg' you could replace the URL as
UPDATE wp_links set link_url = replace(link_url, 'http://yourdomain.com/wp-
content/uploads/2010/10/', 'http://yourdomain.com/wp-content/uploads/') where
link_url like 'http://yourdomain.com/wp-content/uploads/2010/10/%'
You would have to do this for each year and month, but scripting it out this way would be a lot easier than manually updating every URL!

URL is changing in magento

Here I want to ask two question.
I upload my magento website from localhost to main server. My website link is this
http://bigtechideas.com/dope
Problem:1 - When I open url http://bigtechideas.com/dope/admin it returns this http://bigtechideas.com/dopeindex.php/admin
Why it add index.php in url ?
Problem:2 - When I open http://bigtechideas.com/dope it returns me https://bigtechideas.com/dope
Why it add HTTPS in url?
This is all configured through the Magento backend. You have to set an URL for unecrypted and encrypted pages (http & https) in the settings. If you move a Magento installation from one server to anther you have to edit those URLs.
You could also use the following SQL snippets to directly modify the settings in the database. (I can't guarantee that it is complete, but it should)
-- move Magento to another server
SET #shop_domain = 'YOUR_NEW_DOMAIN_WITHOUT_HTTP_HERE',
#secure_protocol = 'https://'; -- set to http:// if no certificate is available
UPDATE `core_config_data` SET `value` = CONCAT('http://', #shop_domain, '/') WHERE `path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT(#secure_protocol, #shop_domain, '/') WHERE `path` = 'web/secure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT('http://', #shop_domain, '/media/') WHERE `path` = 'web/unsecure/base_media_url';
UPDATE `core_config_data` SET `value` = CONCAT(#secure_protocol, #shop_domain, '/media/') WHERE `path` = 'web/secure/base_media_url';
UPDATE `core_config_data` SET `value` = #shop_domain WHERE `path` = 'web/cookie/cookie_domain';
You also have to clear the cache after those changes.
Do The Following
in production db,in its core_config_data table, you should find every records containing the url of your local installation, then you need to update those values
this query may help you
SELECT *
FROM `core_config_data`
WHERE `value` LIKE 'http://%';
Do not forget to delete var folder contents

WordPress deactivate a plugin via database?

I have a wordpress script, wp-supercache, that I need to disable (as its cached on a nasty error), however, the error is causing the wp-admin redirect to fail, which means I can't get into the site to disable the plugin.
Any advice? I can access the database via cpanel.
Try re-naming the folder of the plugin and then see if error is gone (make backup first of course.). If that does not help, here is the solution then.
To disable a specific plugin, you have to remove it from the serialized string that stores the list of all plugins - that's set in the option_value column of the wp_options table as discussed by #TimDurden. The specific format change you have to make is, taken shamelessly from teh Internet:
a:4:{
i:0;s:19:"akismet/akismet.php";
i:1;s:36:"google-sitemap-generator/sitemap.php";
i:2;s:55:"google-syntax-highlighter/google_syntax_highlighter.php";
i:3;s:29:"wp-swfobject/wp-swfobject.php";
}
That first set of characters - a:4 - designates an array and its length. Note also that each line in the list of plugins has an index. So:
Decrement the index (from 4 to 3 in this case)
In each line, decrement the number after the i:
Remove the specific plugin you want to disable.
Update the value in the db using the new string you constructed from these steps:
update wp_options set option_value=<new value> where option_id=<id of this option>
Note that your table name might not be wp_options - you might have a prefix to add.
You only need to rename the folder in /wp-content/plugins/ and the plugin will be automatically de-activated. Once it is de-activated, you will be able to login.
Backup database or just the wp_options table
SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';
Copy selected string (serialized string) and paste in the left side at https://serializededitor.com/
Remove the line which plugin you want to deactivate
Copy the serialized result string from the right side and update active_plugins value with it.
UPDATE wp_options
SET option_value = 'THE_NEW_SERIALIZED_STRING'
WHERE option_name = 'active_plugins' LIMIT 1;
I wrote a little exe in .dot to repair/remove options string from database.
Download exe here
Run on MySQL server
SELECT * FROM wp_options WHERE option_name = 'active_plugins';
Paste Results in textbox, press parse.
Remove the ones you don't want.
Click output, it copies output to clipboard
replace brackets inside the single quotes below with output and Run on MySQL server
UPDATE wp_options SET option_value = '[replace inside single quotes with your output' WHERE option_name = 'active_plugins';
No warranties... I don't claim to be programmer
To disable all Wordpress plugins on your site:
Login to your database management tool (e.g. PHPMyAdmin)
Execute the following query:
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
Another way to do this is you can backup the site and then just rename the folder of the plugin under /wp-content/plugins/ to some other name . So the plugin will be disabled.
I wont prefer deleting the plugin folder as it may cause errors.
After the step is done log in to your wordpress site and delete the plugin from there
You just need to change the values in the record "active_plugins" in the database. You can find the process Here
Late answer,but answering as it will be useful to someone in the future. All the plugins are stored in the wp_options table in a serialized manner. U can edit this field manually. Or if you unserialize it using a function like in php using unserialize(), you will get an array. just modify it to remove the plugin you want to remove from that array, and serialize it back. then update the table. Thats it. If you want to know more about it here is a good article. It explains all about this.
Using this code you can activate your plugin from the functions.php:
function activate_plugin_via_php() {
$active_plugins = get_option( 'active_plugins' );
array_push($active_plugins, 'unyson/unyson.php'); /* Here just replace unyson plugin directory and plugin file*/
update_option( 'active_plugins', $active_plugins );
}
add_action( 'init', 'activate_plugin_via_php' );

Categories