将FB生日插入到Mysql中给出NULL [英] Insert FB birthday into Mysql gives NULL

查看:145
本文介绍了将FB生日插入到Mysql中给出NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ graph_url =https:// graph,当我在MYSQL中插入生日和当前时间时,我获得NULL。 facebook.com/me?access_token=\".$params['access_token'].\"&format=json&fields=birthday; 
$ user = json_decode(file_get_contents($ graph_url),true);
echo(birthday is。$ user ['birthday']);

SQL

  $ queryip =insert into table(birthday,currenttime)values(。$ user ['birthday']。','。CURDATE()。); 
$ resultip = mysql_query($ queryip);

MYSQL结构
生日,当前时间字段都是Type DATE

解决方案

您需要申请 birthday_date 列,而不是生日,因为它总是以相同的格式,DDMMYYY。
之后,您需要将以下内容添加到INSERT查询中:

  STR_TO_DATE('。mysql_real_escape_string($用户['birthday_date'])','%m /%d /%Y')


I Get NULL when i insert the Birthday and current time in MYSQL

$graph_url = "https://graph.facebook.com/me?access_token=".$params['access_token']."&format=json&fields=birthday";
$user = json_decode(file_get_contents($graph_url),true);
     echo("birthday is " . $user['birthday']);

SQL

$queryip = "insert into table (birthday,currenttime) values (".$user['birthday'].','.CURDATE().")";
                $resultip = mysql_query($queryip);

MYSQL Structure Both the birthday,currenttime fields are Type DATE

解决方案

You need to request the birthday_date column, not birthday, because it's always in the same format, DDMMYYY. After that, you need to add the following to your INSERT query:

STR_TO_DATE('" . mysql_real_escape_string ($user ['birthday_date']) . "', '%m/%d/%Y')

这篇关于将FB生日插入到Mysql中给出NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆