Inserting OAuth data into a database I am totally new to PHP. I just wrote a PHP script for google oauth to pull the data and insert into my database. I don't know if my code is vulnerable to SQL injection. Should I have used prepared statements and should I rewrite the code?

index.php

 &lt;?php ini_set('display_errors', 1);
    error_reporting(E_ALL ^ E_NOTICE); ?&gt;


    &lt;?php 

    include_once("config.php");
    include_once("includes/functions.php");

    //print_r($_GET);die;

    if(isset($_REQUEST['code'])){
      $gClient-&gt;authenticate();
      $_SESSION['token'] = $gClient-&gt;getAccessToken();
      header('Location: ' . filter_var($redirect_url, FILTER_SANITIZE_URL));
    }

    if (isset($_SESSION['token'])) {
      $gClient-&gt;setAccessToken($_SESSION['token']);
    }



    if ($gClient-&gt;getAccessToken()) {
      $userProfile = $google_oauthV2-&gt;userinfo-&gt;get();
      //DB Insert
      //$gUser-&gt;setApprovalPrompt ("auto");

      $gUser = new Users();
      // As of PHP 5.3.0

      $gUser-&gt;checkUser('google',$userProfile['id'],$userProfile['given_name'],$userProfile['family_name'],$userProfile['email'],$userProfile['gender'],$userProfile['locale'],$userProfile['link'],$userProfile['picture'],$username);
      $_SESSION['google_data'] = $userProfile; // Storing Google User Data in Session
      header("location: feed.php");

      $_SESSION['token'] = $gClient-&gt;getAccessToken();
    } else {
      $authUrl = $gClient-&gt;createAuthUrl();
    }

      $email  = $_SESSION['google_data']['email'];
      $user = strstr($email, '@', true);
      $username = $user; 
?&gt;


functions.php

 &lt;?php ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE); ?&gt;

&lt;?php
 session_start();
class Users {
    public $tableName = 'users';

 function __construct(){
        //database configuration
        $dbServer = 'localhost'; //Define database server host
        $dbUsername = 'root'; //Define database username
        $dbPassword = ''; //Define database password
        $dbName = 'livelor'; //Define database name

        //connect databse
        $con = mysqli_connect($dbServer,$dbUsername,$dbPassword,$dbName);
        if(mysqli_connect_errno()){
            die("Failed to connect with MySQL: ".mysqli_connect_error());
        }else{
            $this-&gt;connect = $con;
        }
    }

    function checkUser($oauth_provider,$oauth_uid,$fname,$lname,$email,$gender,$locale,$link,$picture,$username){
        $prevQuery = mysqli_query($this-&gt;connect,"SELECT * FROM $this-&gt;tableName WHERE oauth_provider = '".$oauth_provider."' AND oauth_uid = '".$oauth_uid."'") or die(mysqli_error($this-&gt;connect));
        if(mysqli_num_rows($prevQuery) &gt; 0){
            $update = mysqli_query($this-&gt;connect,"UPDATE $this-&gt;tableName SET oauth_provider = '".$oauth_provider."', oauth_uid = '".$oauth_uid."' ,fname = '".$fname."', lname = '".$lname."', email = '".$email."', gender = '".$gender."', locale = '".$locale."', picture = '".$picture."', gpluslink = '".$link."', modified = '".date("Y-m-d H:i:s")."' WHERE oauth_provider = '".$oauth_provider."' AND oauth_uid = '".$oauth_uid."'") or die(mysqli_error($this-&gt;connect));
        }else{
            $insert = mysqli_query($this-&gt;connect,"INSERT INTO $this-&gt;tableName SET oauth_provider = '".$oauth_provider."', oauth_uid = '".$oauth_uid."', fname = '".$fname."', lname = '".$lname."', email = '".$email."', gender = '".$gender."', locale = '".$locale."', picture = '".$picture."', gpluslink = '".$link."', created = '".date("Y-m-d H:i:s")."', modified = '".date("Y-m-d H:i:s")."' ,  username='".$username."' ") or die(mysqli_error($this-&gt;connect));
        }

        $query = mysqli_query($this-&gt;connect,"SELECT * FROM $this-&gt;tableName WHERE oauth_provider = '".$oauth_provider."' AND oauth_uid = '".$oauth_uid."'") or die(mysqli_error($this-&gt;connect));
        $result = mysqli_fetch_array($query);
        return $result;

    }
}
I don't know that my code is vulnerable to SQL injection.


Yes, it is. 

You should never put any variables directly into SQL statements. Even if you think that the variables may possibly be safe, it's just really bad practice, and you will mess it up sooner or later. In your case, an attacker could use the profile fields, which would very likely lead to SQL injection (this depends a bit on the input filter for the profile fields, but I would be surprised if it caught all injections, and you should definitely not rely on it).


  Should I have to use prepared statements and rewrite the code. 


Yes. Prepared statements are the only reliable way to prevent SQL injection, and you should never write any SQL statements without prepared statements. It is bad style and very insecure.

Misc


You really don't want to display errors in production. 
You have too much vertical whitespace.
Some may disagree, but 2 spaces for indentation makes code harder to read. If you need this because your code is too nested, remove some levels of nesting instead of removing indentation. 
functions.php is quite a generic name. It also doesn't fit it's content at all. As it contains a class, it should have the same name as the class (possibly with .class added).
You should create your database connection only once, and then pass it to the functions needing it, instead of creating a new connection for each object needing it.
don't shorten variable names, just write them out.
don't die in functions, it makes it hard for the calling code to handle.