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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:15:15+00:00 2026-06-17T08:15:15+00:00

OK, assume I have a working database connection and table to insert a name

  • 0

OK, assume I have a working database connection and table to insert a name and an image taken with the camera. When I try to insert the records I have tested it with the following statements.

    function insertRecord(){
    userName;
    imagePath;
    if(userName=='' || imagePath==''){insert the stuff}// this won't run the insert statement
    if(userName!='' && imagePath!=''){insert the stuff} //this is giving me results but undefined

So, I think I am right is saying that they have some kind of value that isn’t null. Yet, when I SELECT * FROM USERS I get ID: 1 name: undefined imagepath: undefined. I don’t think this is a problem with scope because I have gone through it and it should be ok. Could it have to do with my html inputs. At the moment my html inputs for both look like this:

    <input id="placeImage" type="image" onclick="getPhoto();" style="width:60px;height:60px" /> 
<p></p>

<input id="userName" type="text" placeholder="FirstName" onchange="getName();"> name<br>

<input id="saveProfile" type="button" value="Save" onClick="insertRecord(dbtx);"> <br>

As you can see, the image input merely calls the camera to get the picture and passes the resulting path to the success function which I am assigning to the global variable imagePath (which is used in the insertRecord)

    function getPhoto() {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
    quality: 50, 
    destinationType: navigator.camera.DestinationType.FILE_URI,
    sourceType: pictureSource
});
}

function onPhotoURISuccess(imageURI){
console.log('calling success function');
    placeImage = document.getElementById('placeImage');
  if(placeImage==''){
        alert('Please take a photo');
}else{
        placeImage.src = imageURI;
    alert(placeImage.src);
    placeImage.style.display = 'block';
    imagePath=placeImage.src;
}
  console.log(imageURI);
    }

    function onFail(message) {
       alert('Failed because: ' + message);
    }

Similarly, with my the name input I am now using onchange=”getName();” to call this code

    function getName(){
    userName= document.getElementById('userName').value;
        if(userName==''){
        alert('Please enter a name');
    }
}

I can’t see any reason why the userName and imagePath are still undefined when they go into the db. Am I not giving them values correctly? I know I am calling the getPhoto(); for the pic, but that in turn calls the onPhotoURISuccess(); (Could this be a problem?) Am I using onchange correctly. Should I have a similar test on the image input? Any help or direction appreciated.

  • 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-17T08:15:16+00:00Added an answer on June 17, 2026 at 8:15 am

    i didn’t see name attr in your input.. if in case you are posting it..

     <input id="placeImage" name="imagePath" type="image" onclick="getPhoto();" style="width:60px;height:60px" /> 
    <p></p>
    
    <input id="userName" type="text" name="userName" placeholder="FirstName" onchange="getName();"> name<br>
    
    <input id="saveProfile" type="button" value="Save" onClick="insertRecord(dbtx);"> <br>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table with N records, each of which needs to be
Assume the following association among three tables in a database: //working with three tables
Assume I have two tables, Student Test Id Name TestId Type StudentId -- ----
Assume I have the following ; def test(): while 1: a = b time.sleep(60)
Assume I have an image uploaded to a store on Shopify called 'logo.png'. In
Assume I have one threadpool and each thread is running following method: void runMe(HashMap
I'm working on a component which works with a database, and the database connection
I'm working on a MYSQL/PHP system where I have the following: -- a set
Assume I have an enumerable object enum and now I want to get the
Assume you have a function read_key and normally it does some stuff. You someone

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.