How to print the user birthdate from Facebook_API [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I was successful in querying the Graph Api and receive the user birthday,but unable to print it.
My API call: /me?fields=id,name,picture,birthday{date};
echo $user['birthday'];
I am receiving this error while trying
Please help,i am newbie to PHP...

Use this to get birthday:
echo $user['birthday']->format("Y-m-d H:i:s");
you can't just echo ['birthday'] because it is a datetime object so you need to use a function of the DateTime object to convert to string.

What is the result of :
print_r($user)
Available indexes will be printed.
You would consider to test your variable with this 2 functions : is_array($user) and isset($user['birthday'])
http://php.net/manual/en/function.isset.php
http://php.net/manual/en/function.is-array.php

Related

Parsing definitions in json format from Wikipedia API in php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I was trying to build a script that could get me definitions of words from the wikipedia API in php.
I tried several obtaining the definitions in an array and displaying the first definition but it didn't work. Can anyone please help me out. Any help is appreciated
Which parameters did you use in your request?
You can take this as an example:
https://en.wikipedia.org/w/api.php?action=opensearch&search=PHP&limit=1&format=json
You said there that you want only the first definition, so you can put limit=1. The response is in json.

Convert database string to array [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a field in one of my database tables, a sample of this field looks like so ; ["1","4","7"]. Those are keys to a reference in another table. What i want to do is fetch the field and ideally loop through the values and get the data from the referenced table. As you will notice, ["1","4","7"] is PHP declaration for an array but for the life of me, I am unable to parse it as an array. How do i parse it as an array? What am I missing?
You should be able to decode and convert it into an array with PHP's json_decode function.
Example:
<?php
echo '<pre>';
print_r(json_decode('["1","4","7"]'));
echo '</pre>';
?>
If I understood your problem is that your database column store a string PHP array representation.
So you should use the function json_decode
By the way it's a strange way to store relation in a database

What is the purpose of using load(array) when checking to see if something exists? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am attempting to debug a php script I did not write. In order to check if a location already exists, they used the following:
$locTable = JTable::getInstance('Location', 'DPCalendarTable');
if ($locTable->load(array('latitude' => $data['latitude'],'longitude' => $data['longitude'])){
$_eventLocCache[$data['alias']] = (int)$locTable->id;
}
What is the purpose of "..->load(array..."?
Since you use Joomla it retrieves data from the table called Location
JTable::load() - Loads a row from the database and binds the fields
to the object properties.

how to $_GET when it has a ' in the text [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I pass a variable called txt from one query on a web page to another web page using
<?php echo $_GET['txt'];?>
the problem some time the text will have a word like don't in it. the (') causes things to just stop. I need to output the variable as read from the database which would include any text that was in the field
When using $_GET you should use urlencode() and urldecode().

convert time to Unix Time stamp [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I need to convert the following date in to Unix format using php code.
2014-06-10T11:05:10.723Z to Unix?
The reason this has so many downvotes is it takes a single in-built function to change a Date to a timestamp, using a single Google search to find.
echo strtotime("2014-06-10T11:05:10.723Z");
Outputs:
1402398310

Categories