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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:10:00+00:00 2026-05-28T11:10:00+00:00

function GetMe(id) { DB.transaction( function (transaction) { transaction.executeSql(SELECT * FROM users WHERE id =

  • 0
function GetMe(id) {

DB.transaction(
    function (transaction) {

        transaction.executeSql("SELECT * FROM users WHERE id = ?", [id], function (transaction, results) {

            if(results.rows.length > 0) {

                var row = results.rows.item(0);

                return row.name;


            }

        }, errorHandler);
    }
);

}

alert(GetMe(1)); // id 5 exists in users table and alert shows empty

the above code dosent work so i tried the below codes

function GetMe(id) {

var retval;

DB.transaction(
    function (transaction) {

        transaction.executeSql("SELECT * FROM users WHERE id = ?", [id], function (transaction, results) {

            if(results.rows.length > 0) {

                var row = results.rows.item(0);

                retval = row.name;
                //alert('IN ' + retval); //works

            }

        }, errorHandler);
    }
);

//alert('OUT ' + retval); // undefined

return retval;  // undefined

}

alert(GetMe(1));  // undefined

the above code should work fine but it dosent i dont know whats wrong with it , i tried almost everything

can someone tell me whats wrong and help me fix this thanks 🙂

  • 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-05-28T11:10:01+00:00Added an answer on May 28, 2026 at 11:10 am

    This looks like it’s because DB.transaction is asynchronous. What you’ll need to do is pass in a callback function to your GetMe() function, e.g.

    GetMe(1, function (data) {
    
    });
    

    And then modify GetMe as follows:

    function GetMe(id, callback) {
        DB.transaction(function (transaction) {
            transaction.executeSql("SELECT * FROM users WHERE id = ?", [id], function (transaction, results) {
                if(results.rows.length > 0) {
                    var row = results.rows.item(0);
                    callback.call(null, row.name);
                }
            }, errorHandler);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function get_total_adults() { $sql = SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp; $result = mysql_query($sql)
I need, from within a function, to get it's name (actually I'm going up
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
I have a single item HTML select box on which I'd like to find
I am building a report from information received from a muti-select form element in
I've got a function that should return me a set of links based on
This is jQuery code to create a custom plugin. (function( $ ){ var methods
Is there a built-in function to get the ghi from www.abc.com/def/ghi in the BCL?

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.