“sufficient permissions” error for admin after duplicating WP database to new install

So you’ve duplicated the tables in the DB, with the new set having the dev_ prefix? In that case, the problem is probably that you have not updated the fields within the duplicated tables that inherit that prefix. For instance, dev_usermeta will now have a meta_key called wp_capabilities. This needs to be dev_capabilities. Also, dev_options … Read more

accessing wordpress serialized data outside wp

Use PHP’s unserialize function: <?php $data=”a:2:{i:0;s:12:”Sample array”;i:1;a:2:{i:0;s:5:”Apple”;i:1;s:6:”Orange”;}}”; $unserialized = unserialize($data); echo ‘<pre>’; print_r($unserialized); echo ‘</pre>’; ?> Result: Array ( [0] => Sample array [1] => Array ( [0] => Apple [1] => Orange ) ) Got the sample data over at unserialize.com, a handy little site if you want to quickly check what’s inside that … Read more

Database create or redirect

Not having cPanel doesn’t mean you can’t create a database, but if you are trying to install WordPress on a server without a database server, that is your biggest problem. I would consider other hosting. Your questions in order: cPanel is a convenience. So are Plesk and other similar pieces of software. If you have … Read more

Fetch a single row from a custom table for to a given ID

$wpdb->wp_philosophy_philosopher won’t work here because it has not been defined. $wpdb->table_name works only with default tables. You can create your own using: $wpdb->philosophy_philosopher = $wpdb->prefix . “philosophy_philosopher”; Note that the wp_ is just the table prefix and has been omitted here because different installations can have different prefixes and that your code stop to work … Read more

Second ezSQL initialization for MSSQL

I apologize for the late reply, I was transferred to a new project and forgot about it. I ended up using a standard PHP PDO connection. Here is an example: // connection variables $servername = “localhost”; $database = “database”; $user = “username”; $pass = “password”; try { //create connection $DBH = new PDO(‘sqlsrv:Server=”.$servername.”;Database=”.$database, $user, $pass); … Read more

add_post_meta — not working

What user34296 said is update_post_meta() will update the value of the existing meta key (custom field) for the specified post. If it does not already exist it will call add_post_meta($post_id, $meta_key, $meta_value) instead. That’s why you should use it. EDIT: in this case it should work, error is coming from another part of the code. … Read more

select a single val though a table in wordpress

Use the method get_var() instead. I’ve also tidied up your code (if you’re gonna use double quotes, take advantage of them!) & added data escaping with the handy prepare() method. global $wpdb; $cat_id = $wpdb->get_var( $wpdb->prepare( “SELECT category_id FROM {$wpdb->prefix}awpcp_categories WHERE category_name = %s”, $ad_cat ) );