Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:59:36+00:00 2026-06-11T05:59:36+00:00

I am trying to transfer data over from a WordPress database into a Codeigniter

  • 0

I am trying to transfer data over from a WordPress database into a Codeigniter project. I have a model method that returns a single value, but I keep getting the following:

Message: Undefined index: meta_value

Filename: models/transfer_model.php

Here’s the model:

 public function get_meta($post_id, $key)
    {
        $this->db->select('meta_value');
        $this->db->from('wp_postmeta');
        $this->db->where('post_id', $post_id);
        $this->db->where('meta_key', $key);
        $this->db->limit(1);

        $query = $this->db->get();

        $row = $query->row_array();

        return $row['meta_value'];
    }

If I print_r($row);, I get the following:

Array
(
    [meta_value] => The Data
)

How can I stop it from returning this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:59:38+00:00Added an answer on June 11, 2026 at 5:59 am

    where there record fetched you are getting return when there is no record fetched with query then there will be nothing means your row is empty to avoid this use key_exists or array_key_exists have look on php doc

    array_key_exists

    public function get_meta($post_id, $key)
        {
            $this->db->select('meta_value');
            $this->db->from('wp_postmeta');
            $this->db->where('post_id', $post_id);
            $this->db->where('meta_key', $key);
            $this->db->limit(1);
    
            $query = $this->db->get();
    
            $row = $query->row_array();
    
            $return = '';
            if(key_exists('meta_value',$row))
             $return = $row['meta_value'];
    
            return $return;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two databases that I'm trying to transfer data between. I'm working on
I'm trying to transfer data from a DataSet into an Excel workbook. Unfortunately, I
I'm trying to transfer some data from Access to SQL Server 2000 (there are
I'm trying to read the POST data from a request with Transfer-Encoding: chunked while
I am trying to migrate data from an Informix database to SQL Server 2008.
I'm trying to transfer the data from my production DB to my staging DB
I am trying to transfer a table from MySQL to MSSQL using the data
I'm trying to find the best way to transfer data from server -> client
Im trying to send multiple data items over a tcp socket from an android
I am trying to transfer data from one page to another but some problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.