Jump to content

Error for storing FB data into local DB


Timmy9ja

Recommended Posts

Hello guys, i  have implemebted facebook login for my website. However, tring to store the data into my local db seems to be a problem. I'll need a little assistance with the coding. 

 

Thanks in advance.

 

 

 BELOW IS THE ERROR MESSAGE I GET

 

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 16

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 17

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 20

 

 

MY CODE

 

<?php
//require 'dbconfig.php';
 $DBhost = "localhost";
  $DBuser = "xxxx";
  $DBpass = "xxxx";
  $DBname = "xxxx";
  
  $DBcon = new MySQLi($DBhost,$DBuser,$DBpass,$DBname);
    
     if ($DBcon->connect_errno) {
         die("ERROR : -> ".$DBcon->connect_error);
     }
     
     
function checkuser($fbid,$fbfullname,$femail){
  LINE 16:   $check = mysqli_query("select from Users where Fuid='$fbid'");    
LINE 17:  $check = mysqli_num_rows($check);
if (empty($check)) { // if new user . Insert a new record
$query = "INSERT INTO Users (Fuid,Ffname,Femail) VALUES ('$fbid','$fbfullname','$femail')";
mysqli_query($query);
} else {   // If Returned user . update the user record
$query = "UPDATE Users SET Ffname='$fbfullname', Femail='$femail' where Fbid='$fuid'";
LINE 20:    mysqli_query($query);
}
}?>
 
 
I'll be grateful for all the help i can get.
Link to comment
Share on other sites

The error messages look pretty clear to me: When a function expects 2 parameters, you can't provide less than 2. It seems you're trying to translate old mysql_* function calls to myqli by appending the letter “i” everywhere. This doesn't work.

 

Even worse: Your code is wide open to SQL injection attacks, because you just insert all variables straight into the queries. Don't do that. Use prepared statements with parameters.

 

Actually, I would recommend you forget about mysqli (you don't know it anyway) and learn PDO instead. PDO is much more versatile and user-friendly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.