So I am trying to store user likes from facebook in database
$likes_json=json_encode($user->likes->data);
echo($likes_json);
$query = "INSERT INTO users VALUES (' ','".$likes_json."', NOW())";
$mysqli->query($query);
“echo” prints out the expected string (of length 56000 characters)
[{"name":"The Next Web","category":"Website","id":"106976563522"....
But nothing is being stored in Database. When I change $likes_json='some other string'; it works fines(it gets inserted in the database)
Coloumn for likes is of type “mediumtext“
You need to escape $likes_json using mysql_real_escape_string
Your query ends up looking like this
See why that wouldn’t work? What if the data contains a ‘ ?