title: How To Resolve the Error: Object of class WP_Error could not be converted to string
body: <p>I am working on media upload to database with Ajax through the Following Function:</p>
  
  <pre><code>function addCustomer(){
  
  global $wpdb;
  
  /*require_once( ABSPATH . 'wp-admin/includes/image.php' );
  require_once( ABSPATH . 'wp-admin/includes/file.php' );
  require_once( ABSPATH . 'wp-admin/includes/media.php' );*/
  
  $user_id = $_POST["user_id"];
  $member_name = $_POST["member_name"];
  $member_title = $_POST["member_title"];
  $member_email = $_POST["member_email"];
  $member_twitter_url = $_POST["member_twitter_url"];
  $member_linkden_url = $_POST["member_linkden_url"];
  $member_image333 = $_POST["member_image"];
  $myText = (string)$member_image333;
  echo $member_image_id  = media_handle_upload('member_image', $myText);
  die();
  if($wpdb-&gt;insert(
    'gloriac_company_team',
     $test[] = array(
      'user_id' =&gt; $user_id,
      'member_name' =&gt; $member_name,
      'member_title' =&gt; $member_title,
      'member_email' =&gt; $member_email,
      'member_twitter_url' =&gt; $member_twitter_url,
      'member_linkedin_url' =&gt; $member_linkden_url,
      'member_image' =&gt; $member_image_id,
      'member_reg_date' =&gt; current_time( 'mysql' )
    )
  
  )===FALSE){
  
  echo "Error";
  
  }
  </code></pre>
  
  <p>But when i submit the form and action comes to this function its not uploaded the media to word press as well as its not storing the image ID to the database as it generates an error for me as follows:</p>
  
  <blockquote>
    <p>Catchable fatal error: Object of class WP_Error could not be converted
    to string in
    /home/mxcounte/public_html/gorilla-crowd/wp-content/themes/Impreza-child/functions.php
    on line 230</p>
  </blockquote>
  
  <p>I have tried to convert the Integer output to string as follows but still there is no luck can anyone help in fixing this issue.</p>
  
  <pre><code>$myText = (string)$member_image333;
  </code></pre>