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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:19:16+00:00 2026-05-27T06:19:16+00:00

I use this function to check whether the record exists in my database and

  • 0

I use this function to check whether the record exists in my database and act accordingly. There is some error in the second part when the data is not matched: it is supposed to insert a new record, but it does not insert new data, and it returns empty data. Where am I going wrong?

 class User {

function checkUser($uid, $oauth_provider, $username,$email,$twitter_otoken,$twitter_otoken_secret) 
{

     // Define database connection constants
define('DB_HOST', 'localhost');
define('DB_USER', '*********');
define('DB_PASSWORD', '********');
define('DB_NAME', '******');
    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    $query ="SELECT * FROM si_table WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'";
    $data=mysqli_query($dbc,$query);
    $result = mysqli_fetch_array($data);
    if (!empty($result)) {

        # User is already present
    } else {

        #user not present. Insert a new Record

     $query2 ="INSERT INTO si_table (oauth_provider, oauth_uid, user_name,email_id,twitter_oauth_token,twitter_oauth_token_secret) VALUES ('$oauth_provider',$uid,'$username','$email')";
        mysqli_query($dbc,$query2);
        $query1 ="SELECT * FROM si_table WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'";
        $data1=mysqli_query($dbc,$query1);
        $row = mysqli_fetch_array($data1);

        return $row;

    }
    return $result;
}



}
  • 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-27T06:19:17+00:00Added an answer on May 27, 2026 at 6:19 am

    You have an error in your insert query: you are providing just 4 values for 6 fields.

    Do some error checking on the return value of mysqli_query($dbc, $query2);

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

Sidebar

Related Questions

I use the following jquery statements but i get error in this function onGetDataSuccess(result)
Writing a jquery function to check whether password user enters is already in use.
I use the following code to check whether or not a certain div exists.
I need a function to check whether a function in jQuery exists and if
I have the following function which I use to check whether or not an
I currently use this function to wrap executing commands and logging their execution, and
I am trying to use this function from a COM API which enables the
I want to use this function EnumWindows(EnumWindowsProc, NULL);. The EnumWindowsProc is a Callback function:
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I use this script to equalize heights of elements: (function ($) { $.fn.autoheight =

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.