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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:35:54+00:00 2026-06-16T03:35:54+00:00

Using PHP 5.3.3 and Drupal 7.17 I’ve created a short custom PHP script, in

  • 0

Using PHP 5.3.3 and Drupal 7.17 I’ve created a short custom PHP script, in which I’d like to call Drupal’s function – which in turn expects an object having a pass property:

function user_check_password($password, $account) {
  if (substr($account->pass, 0, 2) == 'U$') {
    $stored_hash = substr($account->pass, 1);
    $password = md5($password);
  }
  .....
}

So in my script I try to create such an object “on the fly”:

<?php

require_once('/path/to/drupal/includes/password.inc');
........
$sth = $db->prepare(SQL);
$sth->execute(array($username));
if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
        if (user_check_password($password, array('pass' => $row['pass']))) {
                header('Content-Type: application/json; charset=utf-8');
                print json_encode($row);
        }
}

However this gives me an error: Trying to get property of non-object

Which probably means: PHP doesn’t accept my array, it wants an object there.

How could I create an anonymous object “on the fly” then to make it happy?

  • 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-16T03:35:56+00:00Added an answer on June 16, 2026 at 3:35 am

    You are getting an error, because Array is not an Object. If you don’t want to manually create an object (as in the answer by @adityamenon), then you can simply cast your array to object:

    user_check_password($password, (object)array('pass' => $row['pass']))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to include a php file .module file like this using hook_init function
I've created a simple Drupal module which is using a singleton design pattern to
I'm using Drupal 7. My bg image in page.tpl.php file and image get to
Using PHP I echo out table rows in a loop like this: <?php /*
Using PHP I would like to be able to list root's crontab. I am
Using php I am trying to get some data from a .csv file which
Using php and mysql (and Drupal), I want to generate an index based on
I am using NetBeans 7.2.1 on a Windows machine for PHP (Drupal) development. I
I'm making a Drupal/PHP Module to upload information to Taleo (Talent Management) database using
I've created many websites using PHP,XHTML, CSS and MySQL, and everytime I want to

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.