Timmy9ja Posted November 12, 2016 Share Posted November 12, 2016 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 17Warning: 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. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 12, 2016 Share Posted November 12, 2016 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. Quote Link to comment Share on other sites More sharing options...
Timmy9ja Posted November 12, 2016 Author Share Posted November 12, 2016 Thanks for the advice. I'm still brushing up my SQL skills, i'm sure i would get there with more effort. However, the situation at hand would require your help. Could you assist with the code? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 12, 2016 Share Posted November 12, 2016 Who said anything about SQL skills? I'm talking specifically about your problem. If you missed that, you might want to read the post again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.