I have to retrieve data from linkedin using CallAPI function and then store this data into my database.The code is fetching the data in json format even displaying it but the storage part isnt working.
我必须使用CallAPI函数从linkedin检索数据,然后将这些数据存储到我的数据库中。代码是以json格式获取数据,甚至显示它,但存储部分不工作。
This is my db.php code
这是我的db.php代码
$check = $this->db->query("SELECT * FROM $this->userTable WHERE oauth_uid = '".$oauth_uid."' AND email = '".$email."'");
if(mysqli_num_rows($check) > 0){
$result = $check->fetch_array(MYSQLI_ASSOC);
$query = "UPDATE $this->userTable SET fname = '".$userdata->firstName."', lname = '".$userdata->lastName."', email = '".$userdata->emailAddress."' WHERE id = ".$result['id'];
$this->db->query($query);
return $result['id'];
}else{
$query = "INSERT INTO $this->userTable(oauth_provider,oauth_uid,fname,lname,email,location,country,picture_url,profile_url,created,modified) VALUES('linkedin','".$userdata->id."','".$userdata->firstName."','".$userdata->lastName."','".$userdata->emailAddress."')";
$this->db->query($query);
return $this->db->insert_id;
}
The program has an insert query still data isnt being stored anywhere.
该程序有一个插入查询,仍然没有数据存储在任何地方。
1 个解决方案
#1
0
In you inserting query you are trying to insert 5 values
在插入查询时,您尝试插入5个值
VALUES('linkedin','".$userdata->id."','".$userdata->firstName."','".$userdata->lastName."','".$userdata->emailAddress."')
VALUES( 'LinkedIn', ' “$ userdata->的ID。”' ' “$ userdata->您的名字。”', ' “$ userdata-> lastName的。”''”。$ userdata-> EMAILADDRESS “。”)
in 10 columns:
在10列中:
(oauth_provider,oauth_uid,fname,lname,email,location,country,picture_url,profile_url,created,modified)
(oauth_provider,oauth_uid,FNAME,LNAME,电子邮件,位置,国家,picture_url,PROFILE_URL,创建,修改)
So just arrange it to have the same numbers of columns and values to have it work properly
因此,只需将其排列为具有相同数量的列和值即可使其正常工作
#1
0
In you inserting query you are trying to insert 5 values
在插入查询时,您尝试插入5个值
VALUES('linkedin','".$userdata->id."','".$userdata->firstName."','".$userdata->lastName."','".$userdata->emailAddress."')
VALUES( 'LinkedIn', ' “$ userdata->的ID。”' ' “$ userdata->您的名字。”', ' “$ userdata-> lastName的。”''”。$ userdata-> EMAILADDRESS “。”)
in 10 columns:
在10列中:
(oauth_provider,oauth_uid,fname,lname,email,location,country,picture_url,profile_url,created,modified)
(oauth_provider,oauth_uid,FNAME,LNAME,电子邮件,位置,国家,picture_url,PROFILE_URL,创建,修改)
So just arrange it to have the same numbers of columns and values to have it work properly
因此,只需将其排列为具有相同数量的列和值即可使其正常工作