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

  • Home
  • SEARCH
  • 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 9240661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:13:44+00:00 2026-06-18T08:13:44+00:00

I was creating plugin with users photos Then the image was save to the

  • 0

I was creating plugin with users photos
Then the image was save to the database with BLOB

When im going to get the image to the database it was not workin.

My codes
user-management.php

<table cellpadding="5" cellspacing="0">
    <thead>
    <tr>
        <th>Username</th>
        <th>Email</th>
        <th>First Name</th>
        <th>Middle Name</th>
        <th>Last Name</th>
        <th>Status</th>
        <th>Photo</th>
        <th>Date</th>
        <th>Option</th>
     </tr>
    </thead>
    <tbody>
<?php
global $wpdb;
$myadmin = $wpdb->get_results( "SELECT * FROM jon_admin" );
$color1 = "#F8F8F8"; 
$color2 = "#FFFFFF"; 
$row_count = 0;
foreach ($myadmin as $admin) {
    $myadminphoto = $wpdb->get_row( "SELECT * FROM jon_admin_photo WHERE user_login = '".$admin->user_login."' " );
$row_color = ($row_count % 2) ? $color1 : $color2;
    ?>
        <tr>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->user_login; ?></td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->email; ?></td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->fname; ?></td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->mname; ?></td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->lname; ?></td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->user_status; ?></td>
            <td style="background-color:<? echo $row_color; ?>">
            <img src="<?php echo plugins_url( 'photo.php', __FILE__ ); ?>?pid=<?php echo $myadminphoto->apid; ?>&img=adminphoto" />                </td>
            <td style="background-color:<? echo $row_color; ?>"><?php echo $admin->date; ?></td>
            <td style="background-color:<? echo $row_color; ?>">edit view delete</td>
        </tr>
<?php
$row_count++;
}       
?>
    </tbody>
</table>

if you see this line <img src="<?php echo plugins_url( 'photo.php', __FILE__ ); ?>?pid=<?php echo $myadminphoto->apid; ?>&img=adminphoto" />
im calling the image via another page which is photo.php

then the file of photo.php was this

if ( $_GET['img'] == 'adminphoto' ) {
    global $wpdb;
        ## VIEW ADMIN PHOTO
        $id = $_GET['pid'];
        $get_photo =  $wpdb->get_row( "SELECT * FROM jon_admin_photo WHERE apid = '".$id."'" );

            $content = $get_photo->image;
            $filetype = $get_photo->imgcode;
            header('Content-type: $filetype');
            echo $content;

    }

There you go, there is no image display also there is no error display.

But when i do something like this,
I get the url of the photo then right click open to new tab
it the error said
Fatal error: Call to a member function get_row() on a non-object in C:\xampp\htdocs\web\advanced-nanny\wp-content\plugins\jon-user-management\photo.php on line 37

Is there something wrong with my codes?

Please tell me thank you…

  • 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-18T08:13:45+00:00Added an answer on June 18, 2026 at 8:13 am

    You’ll need to instanciate wordpress in your php file.

    I think the easiest way to do this in WordPress without breaking your logic is to define a function in your plugin like this to use it like an ajax call:

    function MY_FUNCTION() {
        if ( $_GET['img'] == 'adminphoto' ) {
            global $wpdb;
            ## VIEW ADMIN PHOTO
            $id = $_GET['pid'];
            $get_photo =  $wpdb->get_row( "SELECT * FROM jon_admin_photo WHERE apid = '".$id."'" );
    
                $content = $get_photo->image;
                $filetype = $get_photo->imgcode;
                header('Content-type: $filetype');
                echo $content;
    
        }
        exit();
    }
    add_action('wp_ajax_MY_FUNCTION', 'MY_FUNCTION');
    add_action('wp_ajax_nopriv_MY_FUNCTION', 'MY_FUNCTION');//for users that are not logged in
    

    Then you can call it this way :

    <img src="<?php echo admin_url('admin-ajax.php'); ?>?action=MY_FUNCTION&pid=<?php echo $myadminphoto->apid; ?>&img=adminphoto" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in creating a plugin that does this simple task: Steps 1. User
I am creating a user profile plugin in Joomla 2.5 to extend the standard
im creating a wordpress plugin that have users to login and upload the file
I'm creating a WordPress plugin that allows a user to select one of several
I'm creating a webpage which uses jquery.transit plugin. I download the .js file and
I'm reading some tutorials now about jQuery.. function creating,plugin creation etc. but these tutorials
So I'm creating a plugin for Ruby on Rails to make implemented addresses including
I'm creating a plugin for wordpress and I need to check if a post
I am creating a plugin for Sonar and I need to create a custom
Prior to Rails 3, creating a plugin to extend find was relatively easy: basically

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.