Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want get in my site this text info:
http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM
when the video is not found.
how i can writte the code?
i don't understand here:
https://developers.google.com/youtube/2.0/developers_guide_php?csw=1
thank you!
You can try checking the video is available or not with headers:
$headers = get_headers("http://gdata.youtube.com/feeds/api/videos/".$row['youtube']);
if (!strpos($headers[0], '200'))
{
echo "Video is not found";
}
Try this ;)
<?php
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM');
$is_ok = substr($headers[0], 9, 3) == 200;
if($is_ok){
echo 'Video is OK :)';
}
else{
echo 'Something is wrong :(';
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a form in HTML, i ask the user to enter a url, once that happens it comes back in plain text in PHP. What i want to happen is that when they enter their URL and submit the link that they have entered will become clickable. This is the code i have. I hope this helps.
<?php
$firstname = $_POST['firstname'];
$course = $_POST['course'];
$projecturl = $_POST['projecturl'];
echo "<p>You are <span class='textblue'> $firstname</span> and ";
echo "your course at the college is: <span class='textblue'> $course </span></p> ";
echo "your project url is: <span class='textblue'> $projecturl</span></p> ";
echo "a href=’google.com’>Google</a>” .
?>
Try to use parse_url, for example:
<?php
$url = '//www.example.com/path?googleguy=googley';
var_dump(parse_url($url));
?>
If you want to search more about this code:
https://www.php.net/manual/en/function.parse-url.php
change echo statements like this
echo "<p>You are <span class='textblue'>.'"$firstname"'.</span> and ";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to display a text with a specific tag in wordpress.
Ex: I have 2 tags: car and boat, and 2 text: "I have car and i want one bike", "I have boat and i am happy"
I want to display in header specific text when exist tag.
I try using tem exist in header.php but display text in all pages, not just in page where exist tag.
Ex:
<?php
$boat = term_exists('boat', 'post_tag');
if ($boat !== 0 && $boat !== null) {
echo "I have boat and i am happy!";
}
?>
If you have only two tags this will do.
<?php
if (is_tag( 'boat' )) {
echo "I have boat and i am happy!";
} elseif (is_tag('car')) {
echo "I have a car";
}
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
if ((isset($_GET['Menu']) && $_GET['Menu'] == "1" && $_GET['Overview']==1)
{
echo '$_GET['Overview']'
}
if statement to receive parameter from the URL
Because you cannot use if the way you do. Split up the echo, then it should work:
echo "<li><a " ;
if($_GET['Menu']==1) { echo 'class="select"'; }
echo " href=javascript:setParam('Menu',1);>Networks</a></li>";
$x="";
if($_GET['Menu']==1)
$x= 'class="select"';
echo "<li><a>".$x." href=javascript:setParam('Menu',1);>Networks</a></li>";
Im partial to sprintf for concatenation, but thats just me:
echo sprintf('<li><a %s href=javascript:setParam(\'Menu\',1);>Networks</a></li>',
$_GET['Menu']==1 ? 'class="select"' : '');
You need to echo every part of your code:
echo "<li><a ";
if($_GET['Menu']==1) { echo 'class="select"'; }
echo " href=javascript:setParam('Menu',1);>Networks</a></li>";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a form and am using json encode. It displays like the below.
[{"approveNight":"A","approve":"A","Comments":"bbb","Email":"email#email.com"}]
I am using this, but I would like it to display html. What am I missing?
<?php
$data = array($jsonData);
echo json_encode($data);
?>
I would like it to display as
Approve: yes or no
Approve: yes or no
comments: the comments
email: email address that they typed in
Try this and see if this helps:
$arrValues= json_decode($data);
print 'Approve: '.($arrValues['approve']=='A' ? 'Yes' : 'No').'<br />'
. 'Comments: '.$arrValues['Comments'].'<br />'
. 'Email: '.$arrValues['Email'].'<br />'
. 'Approve Night: '.($arrValues['approveNight']=='A' ? 'Yes' : 'No');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
<?php
$response = file_get_contents("http://api.trakt.tv/shows/trending.json/5d7588c188eeea0074b8d2664d12fffc");
$result = json_decode($response, true);
echo $result['title'][0];
echo "<br>";
echo $result['network'][0];
echo "<br>";
echo $result['air_day'][0];
echo "<br><img style='width:200px;' src='";
echo $result['images'][0]['poster'];
echo "'>";
?>
Ain't working. I don't know why.
I use the the trakt.tv shows API.
Write
echo $result[0]['title'];
instead of
echo $result['title'][0];
Besides, PHP's echo function will print integers and strings, but will fail with array-alike structures. You could use var_dump or var_export instead. Thanks to them, you could scan the structure and you wouldn't ask this question ;)