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 8190719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:44:18+00:00 2026-06-07T03:44:18+00:00

I have a class: class Media { private $media; private $thumb; private $slug; private

  • 0

I have a class:

class Media {
    private $media;
    private $thumb;
    private $slug;
    private $info;
    private $type;
    private $link;
}

And I try to save it to the DB using PHP PDO:

$PDO = new PDO("mysql:host=".DBHOST.";dbname=".DB, DBUSER, DBPASS);

$options = array('media' => 'image.jpg',
            'thumb' => 'image_thumb.jpg');
$media = new Media($options);

$media = (array)$media;

$STH = $PDO->prepare('INSERT INTO media (media, thumb, slug, info, type, link) values (?, ?, ?, ?, ?, ? )');

$STH->bindParam(1, $media['Mediamedia']);
$STH->bindParam(2, $media['Mediaslug']);
$STH->bindParam(3, serialize($media['Mediainfo']));  //line 150
$STH->bindParam(4, $media['Mediathumb']);
$STH->bindParam(5, $media['Mediatype']);
$STH->bindParam(6, $media['Medialink']);

$STH->execute();

The code above produces 1 error:

Notice: Undefined index: Mediainfo in C:\wamp32\www\MM\index.php on line 150

But print_r($media); outputs:

Array
(
    [Mediamedia] => image.jpg
    [Mediathumb] => image_thumb.jpg
    [Mediaslug] => image
    [Mediainfo] => Array
    (
        [title] => image.jpg
        [alt] => image.jpg
        [description] => image.jpg
    )
    [Mediatype] => .jpg
    [Medialink] => 0
)

Edit: Fixed second error, quite dumb like @dleiftah said, but one persists.

  • 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-07T03:44:20+00:00Added an answer on June 7, 2026 at 3:44 am

    When you cast an object to an array, the private and protected members are mangled. The private members have null bytes \x00 surrounding the class name. To use them in this fashion, you would need:

    $STH->bindParam(1, $media["\x00Media\x00media"]);
    $STH->bindParam(2, $media["\x00Media\x00slug"]);
    $STH->bindParam(3, serialize($media["\x00Media\x00info"]));
    $STH->bindParam(4, $media["\x00Media\x00thumb"]);
    $STH->bindParam(5, $media["\x00Media\x00type"]);
    $STH->bindParam(6, $media["\x00Media\x00link"]);
    

    If they were protected members, they would start with \x00*\x00

    Also, it appears that the order you are binding parameters does not match the order of fields in your insert statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class Media and several derived classes, namely DVD , Book
I have a class of Entry, and a class of Media. They're both in
I have a bas class called Media with two classes that inherit from it,
I have a class, called Media, which represents coredata. If something changes in my
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'
I have class with back reference: public class Employee : Entity { private string
I have a class with an enumerated type GameStates. In the (public) constructor I
public class VideoDemo extends Activity { private VideoView video; private MediaController ctlr; File clip=new
I have this in my first activity: private AdapterView.OnItemClickListener _itemClickLis = new OnItemClickListener() {
I have an activity that is a service which plays audio using a media

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.